@quantakrypto/core 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (314) hide show
  1. package/README.md +76 -27
  2. package/dist/cbom-merge.d.ts +9 -0
  3. package/dist/cbom-merge.d.ts.map +1 -0
  4. package/dist/cbom-merge.js +121 -0
  5. package/dist/cbom-merge.js.map +1 -0
  6. package/dist/cbom.d.ts +5 -0
  7. package/dist/cbom.d.ts.map +1 -1
  8. package/dist/cbom.js +132 -37
  9. package/dist/cbom.js.map +1 -1
  10. package/dist/comments.d.ts +6 -26
  11. package/dist/comments.d.ts.map +1 -1
  12. package/dist/comments.js +77 -38
  13. package/dist/comments.js.map +1 -1
  14. package/dist/dependencies.d.ts.map +1 -1
  15. package/dist/dependencies.js +1 -1
  16. package/dist/dependencies.js.map +1 -1
  17. package/dist/detect-utils.d.ts +59 -21
  18. package/dist/detect-utils.d.ts.map +1 -1
  19. package/dist/detect-utils.js +143 -8
  20. package/dist/detect-utils.js.map +1 -1
  21. package/dist/detectors/age.d.ts +16 -0
  22. package/dist/detectors/age.d.ts.map +1 -0
  23. package/dist/detectors/age.js +40 -0
  24. package/dist/detectors/age.js.map +1 -0
  25. package/dist/detectors/ansible.d.ts +13 -0
  26. package/dist/detectors/ansible.d.ts.map +1 -0
  27. package/dist/detectors/ansible.js +108 -0
  28. package/dist/detectors/ansible.js.map +1 -0
  29. package/dist/detectors/bicep.d.ts +20 -0
  30. package/dist/detectors/bicep.d.ts.map +1 -0
  31. package/dist/detectors/bicep.js +74 -0
  32. package/dist/detectors/bicep.js.map +1 -0
  33. package/dist/detectors/c.d.ts +4 -2
  34. package/dist/detectors/c.d.ts.map +1 -1
  35. package/dist/detectors/c.js +222 -4
  36. package/dist/detectors/c.js.map +1 -1
  37. package/dist/detectors/cicd.d.ts +27 -0
  38. package/dist/detectors/cicd.d.ts.map +1 -0
  39. package/dist/detectors/cicd.js +129 -0
  40. package/dist/detectors/cicd.js.map +1 -0
  41. package/dist/detectors/cloud-kms.d.ts +24 -0
  42. package/dist/detectors/cloud-kms.d.ts.map +1 -0
  43. package/dist/detectors/cloud-kms.js +99 -0
  44. package/dist/detectors/cloud-kms.js.map +1 -0
  45. package/dist/detectors/cloudformation.d.ts +38 -0
  46. package/dist/detectors/cloudformation.d.ts.map +1 -0
  47. package/dist/detectors/cloudformation.js +201 -0
  48. package/dist/detectors/cloudformation.js.map +1 -0
  49. package/dist/detectors/codesign.d.ts +50 -0
  50. package/dist/detectors/codesign.d.ts.map +1 -0
  51. package/dist/detectors/codesign.js +143 -0
  52. package/dist/detectors/codesign.js.map +1 -0
  53. package/dist/detectors/csharp.d.ts.map +1 -1
  54. package/dist/detectors/csharp.js +13 -3
  55. package/dist/detectors/csharp.js.map +1 -1
  56. package/dist/detectors/dart.d.ts +35 -0
  57. package/dist/detectors/dart.d.ts.map +1 -0
  58. package/dist/detectors/dart.js +177 -0
  59. package/dist/detectors/dart.js.map +1 -0
  60. package/dist/detectors/database.d.ts +19 -0
  61. package/dist/detectors/database.d.ts.map +1 -0
  62. package/dist/detectors/database.js +97 -0
  63. package/dist/detectors/database.js.map +1 -0
  64. package/dist/detectors/dkim.d.ts +54 -0
  65. package/dist/detectors/dkim.d.ts.map +1 -0
  66. package/dist/detectors/dkim.js +92 -0
  67. package/dist/detectors/dkim.js.map +1 -0
  68. package/dist/detectors/dnssec.d.ts +55 -0
  69. package/dist/detectors/dnssec.d.ts.map +1 -0
  70. package/dist/detectors/dnssec.js +116 -0
  71. package/dist/detectors/dnssec.js.map +1 -0
  72. package/dist/detectors/elixir.d.ts +20 -0
  73. package/dist/detectors/elixir.d.ts.map +1 -0
  74. package/dist/detectors/elixir.js +227 -0
  75. package/dist/detectors/elixir.js.map +1 -0
  76. package/dist/detectors/java.d.ts.map +1 -1
  77. package/dist/detectors/java.js +34 -4
  78. package/dist/detectors/java.js.map +1 -1
  79. package/dist/detectors/jose.d.ts +20 -0
  80. package/dist/detectors/jose.d.ts.map +1 -0
  81. package/dist/detectors/jose.js +72 -0
  82. package/dist/detectors/jose.js.map +1 -0
  83. package/dist/detectors/jwk.d.ts +25 -0
  84. package/dist/detectors/jwk.d.ts.map +1 -0
  85. package/dist/detectors/jwk.js +131 -0
  86. package/dist/detectors/jwk.js.map +1 -0
  87. package/dist/detectors/k8s.d.ts +17 -0
  88. package/dist/detectors/k8s.d.ts.map +1 -0
  89. package/dist/detectors/k8s.js +88 -0
  90. package/dist/detectors/k8s.js.map +1 -0
  91. package/dist/detectors/keystore.d.ts +19 -0
  92. package/dist/detectors/keystore.d.ts.map +1 -0
  93. package/dist/detectors/keystore.js +76 -0
  94. package/dist/detectors/keystore.js.map +1 -0
  95. package/dist/detectors/mesh.d.ts +34 -0
  96. package/dist/detectors/mesh.d.ts.map +1 -0
  97. package/dist/detectors/mesh.js +91 -0
  98. package/dist/detectors/mesh.js.map +1 -0
  99. package/dist/detectors/messaging.d.ts +16 -0
  100. package/dist/detectors/messaging.d.ts.map +1 -0
  101. package/dist/detectors/messaging.js +79 -0
  102. package/dist/detectors/messaging.js.map +1 -0
  103. package/dist/detectors/objc.d.ts +41 -0
  104. package/dist/detectors/objc.d.ts.map +1 -0
  105. package/dist/detectors/objc.js +146 -0
  106. package/dist/detectors/objc.js.map +1 -0
  107. package/dist/detectors/openpgp.d.ts +20 -0
  108. package/dist/detectors/openpgp.d.ts.map +1 -0
  109. package/dist/detectors/openpgp.js +151 -0
  110. package/dist/detectors/openpgp.js.map +1 -0
  111. package/dist/detectors/pem.d.ts.map +1 -1
  112. package/dist/detectors/pem.js +33 -1
  113. package/dist/detectors/pem.js.map +1 -1
  114. package/dist/detectors/php.d.ts +25 -0
  115. package/dist/detectors/php.d.ts.map +1 -0
  116. package/dist/detectors/php.js +171 -0
  117. package/dist/detectors/php.js.map +1 -0
  118. package/dist/detectors/pkcs11.d.ts +17 -0
  119. package/dist/detectors/pkcs11.d.ts.map +1 -0
  120. package/dist/detectors/pkcs11.js +87 -0
  121. package/dist/detectors/pkcs11.js.map +1 -0
  122. package/dist/detectors/proxy.d.ts +52 -0
  123. package/dist/detectors/proxy.d.ts.map +1 -0
  124. package/dist/detectors/proxy.js +157 -0
  125. package/dist/detectors/proxy.js.map +1 -0
  126. package/dist/detectors/pulumi.d.ts +19 -0
  127. package/dist/detectors/pulumi.d.ts.map +1 -0
  128. package/dist/detectors/pulumi.js +80 -0
  129. package/dist/detectors/pulumi.js.map +1 -0
  130. package/dist/detectors/python.d.ts.map +1 -1
  131. package/dist/detectors/python.js +70 -0
  132. package/dist/detectors/python.js.map +1 -1
  133. package/dist/detectors/rust.d.ts.map +1 -1
  134. package/dist/detectors/rust.js +73 -0
  135. package/dist/detectors/rust.js.map +1 -1
  136. package/dist/detectors/secrets.d.ts +24 -0
  137. package/dist/detectors/secrets.d.ts.map +1 -0
  138. package/dist/detectors/secrets.js +63 -0
  139. package/dist/detectors/secrets.js.map +1 -0
  140. package/dist/detectors/solidity.d.ts +50 -0
  141. package/dist/detectors/solidity.d.ts.map +1 -0
  142. package/dist/detectors/solidity.js +108 -0
  143. package/dist/detectors/solidity.js.map +1 -0
  144. package/dist/detectors/source.d.ts.map +1 -1
  145. package/dist/detectors/source.js +243 -53
  146. package/dist/detectors/source.js.map +1 -1
  147. package/dist/detectors/spire.d.ts +49 -0
  148. package/dist/detectors/spire.d.ts.map +1 -0
  149. package/dist/detectors/spire.js +77 -0
  150. package/dist/detectors/spire.js.map +1 -0
  151. package/dist/detectors/ssh-ca.d.ts +72 -0
  152. package/dist/detectors/ssh-ca.d.ts.map +1 -0
  153. package/dist/detectors/ssh-ca.js +119 -0
  154. package/dist/detectors/ssh-ca.js.map +1 -0
  155. package/dist/detectors/stateful-hbs.d.ts.map +1 -1
  156. package/dist/detectors/stateful-hbs.js +9 -6
  157. package/dist/detectors/stateful-hbs.js.map +1 -1
  158. package/dist/detectors/supply-chain.d.ts +17 -0
  159. package/dist/detectors/supply-chain.d.ts.map +1 -0
  160. package/dist/detectors/supply-chain.js +89 -0
  161. package/dist/detectors/supply-chain.js.map +1 -0
  162. package/dist/detectors/swift.d.ts +22 -0
  163. package/dist/detectors/swift.d.ts.map +1 -0
  164. package/dist/detectors/swift.js +120 -0
  165. package/dist/detectors/swift.js.map +1 -0
  166. package/dist/detectors/terraform.d.ts +21 -0
  167. package/dist/detectors/terraform.d.ts.map +1 -0
  168. package/dist/detectors/terraform.js +150 -0
  169. package/dist/detectors/terraform.js.map +1 -0
  170. package/dist/detectors/vault.d.ts +15 -0
  171. package/dist/detectors/vault.d.ts.map +1 -0
  172. package/dist/detectors/vault.js +97 -0
  173. package/dist/detectors/vault.js.map +1 -0
  174. package/dist/detectors/vpn.d.ts +22 -0
  175. package/dist/detectors/vpn.d.ts.map +1 -0
  176. package/dist/detectors/vpn.js +73 -0
  177. package/dist/detectors/vpn.js.map +1 -0
  178. package/dist/detectors/weak-hash.d.ts +71 -0
  179. package/dist/detectors/weak-hash.d.ts.map +1 -0
  180. package/dist/detectors/weak-hash.js +116 -0
  181. package/dist/detectors/weak-hash.js.map +1 -0
  182. package/dist/detectors/webauthn.d.ts +61 -0
  183. package/dist/detectors/webauthn.d.ts.map +1 -0
  184. package/dist/detectors/webauthn.js +109 -0
  185. package/dist/detectors/webauthn.js.map +1 -0
  186. package/dist/detectors/xmldsig.d.ts +23 -0
  187. package/dist/detectors/xmldsig.d.ts.map +1 -0
  188. package/dist/detectors/xmldsig.js +84 -0
  189. package/dist/detectors/xmldsig.js.map +1 -0
  190. package/dist/evidence.d.ts +79 -4
  191. package/dist/evidence.d.ts.map +1 -1
  192. package/dist/evidence.js +76 -0
  193. package/dist/evidence.js.map +1 -1
  194. package/dist/index.d.ts +17 -9
  195. package/dist/index.d.ts.map +1 -1
  196. package/dist/index.js +21 -9
  197. package/dist/index.js.map +1 -1
  198. package/dist/inventory.d.ts +0 -2
  199. package/dist/inventory.d.ts.map +1 -1
  200. package/dist/inventory.js +15 -6
  201. package/dist/inventory.js.map +1 -1
  202. package/dist/policy.d.ts +67 -0
  203. package/dist/policy.d.ts.map +1 -0
  204. package/dist/policy.js +115 -0
  205. package/dist/policy.js.map +1 -0
  206. package/dist/registry.d.ts +9 -4
  207. package/dist/registry.d.ts.map +1 -1
  208. package/dist/registry.js +81 -4
  209. package/dist/registry.js.map +1 -1
  210. package/dist/remediate-pipeline.d.ts +0 -3
  211. package/dist/remediate-pipeline.d.ts.map +1 -1
  212. package/dist/remediate-pipeline.js +23 -2
  213. package/dist/remediate-pipeline.js.map +1 -1
  214. package/dist/remediation.d.ts +10 -0
  215. package/dist/remediation.d.ts.map +1 -1
  216. package/dist/remediation.js +32 -0
  217. package/dist/remediation.js.map +1 -1
  218. package/dist/report.d.ts +9 -0
  219. package/dist/report.d.ts.map +1 -1
  220. package/dist/report.js +38 -1
  221. package/dist/report.js.map +1 -1
  222. package/dist/scan-worker.js +5 -3
  223. package/dist/scan-worker.js.map +1 -1
  224. package/dist/scan.d.ts.map +1 -1
  225. package/dist/scan.js +35 -6
  226. package/dist/scan.js.map +1 -1
  227. package/dist/standards-profiles.d.ts +58 -0
  228. package/dist/standards-profiles.d.ts.map +1 -0
  229. package/dist/standards-profiles.js +100 -0
  230. package/dist/standards-profiles.js.map +1 -0
  231. package/dist/standards.d.ts +96 -0
  232. package/dist/standards.d.ts.map +1 -0
  233. package/dist/standards.js +107 -0
  234. package/dist/standards.js.map +1 -0
  235. package/dist/types.d.ts +6 -5
  236. package/dist/types.d.ts.map +1 -1
  237. package/dist/types.js.map +1 -1
  238. package/dist/version.d.ts +1 -1
  239. package/dist/version.js +1 -1
  240. package/dist/version.js.map +1 -1
  241. package/dist/vex.d.ts +39 -0
  242. package/dist/vex.d.ts.map +1 -0
  243. package/dist/vex.js +87 -0
  244. package/dist/vex.js.map +1 -0
  245. package/dist/walk.d.ts +8 -3
  246. package/dist/walk.d.ts.map +1 -1
  247. package/dist/walk.js +32 -1
  248. package/dist/walk.js.map +1 -1
  249. package/package.json +1 -1
  250. package/src/cbom-merge.ts +146 -0
  251. package/src/cbom.ts +153 -39
  252. package/src/comments.ts +84 -39
  253. package/src/dependencies.ts +2 -1
  254. package/src/detect-utils.ts +146 -12
  255. package/src/detectors/age.ts +60 -0
  256. package/src/detectors/ansible.ts +140 -0
  257. package/src/detectors/bicep.ts +107 -0
  258. package/src/detectors/c.ts +240 -6
  259. package/src/detectors/cicd.ts +171 -0
  260. package/src/detectors/cloud-kms.ts +141 -0
  261. package/src/detectors/cloudformation.ts +250 -0
  262. package/src/detectors/codesign.ts +214 -0
  263. package/src/detectors/csharp.ts +13 -3
  264. package/src/detectors/dart.ts +237 -0
  265. package/src/detectors/database.ts +141 -0
  266. package/src/detectors/dkim.ts +172 -0
  267. package/src/detectors/dnssec.ts +195 -0
  268. package/src/detectors/elixir.ts +268 -0
  269. package/src/detectors/java.ts +39 -4
  270. package/src/detectors/jose.ts +110 -0
  271. package/src/detectors/jwk.ts +170 -0
  272. package/src/detectors/k8s.ts +115 -0
  273. package/src/detectors/keystore.ts +109 -0
  274. package/src/detectors/mesh.ts +130 -0
  275. package/src/detectors/messaging.ts +106 -0
  276. package/src/detectors/objc.ts +209 -0
  277. package/src/detectors/openpgp.ts +194 -0
  278. package/src/detectors/pem.ts +31 -1
  279. package/src/detectors/php.ts +230 -0
  280. package/src/detectors/pkcs11.ts +113 -0
  281. package/src/detectors/proxy.ts +236 -0
  282. package/src/detectors/pulumi.ts +106 -0
  283. package/src/detectors/python.ts +71 -0
  284. package/src/detectors/rust.ts +76 -0
  285. package/src/detectors/secrets.ts +103 -0
  286. package/src/detectors/solidity.ts +176 -0
  287. package/src/detectors/source.ts +283 -73
  288. package/src/detectors/spire.ts +143 -0
  289. package/src/detectors/ssh-ca.ts +215 -0
  290. package/src/detectors/stateful-hbs.ts +9 -6
  291. package/src/detectors/supply-chain.ts +117 -0
  292. package/src/detectors/swift.ts +149 -0
  293. package/src/detectors/terraform.ts +188 -0
  294. package/src/detectors/vault.ts +120 -0
  295. package/src/detectors/vpn.ts +103 -0
  296. package/src/detectors/weak-hash.ts +217 -0
  297. package/src/detectors/webauthn.ts +205 -0
  298. package/src/detectors/xmldsig.ts +115 -0
  299. package/src/evidence.ts +138 -4
  300. package/src/index.ts +50 -12
  301. package/src/inventory.ts +15 -7
  302. package/src/policy.ts +180 -0
  303. package/src/registry.ts +81 -4
  304. package/src/remediate-pipeline.ts +26 -3
  305. package/src/remediation.ts +39 -0
  306. package/src/report.ts +43 -1
  307. package/src/scan-worker.ts +5 -3
  308. package/src/scan.ts +41 -6
  309. package/src/standards-profiles.ts +136 -0
  310. package/src/standards.ts +186 -0
  311. package/src/types.ts +11 -4
  312. package/src/version.ts +1 -1
  313. package/src/vex.ts +122 -0
  314. package/src/walk.ts +33 -2
@@ -0,0 +1,107 @@
1
+ /**
2
+ * IaC detector: classical asymmetric cryptography and legacy TLS declared in Azure
3
+ * Bicep (`.bicep`) — Azure's native IaC DSL, distinct from the ARM/CloudFormation
4
+ * JSON the cloudformation detector already covers (Bicep is the *source*; ARM JSON is
5
+ * its compiled output). Bicep provisions the same Key Vault keys and TLS floors, but
6
+ * in its own single-quoted-string syntax that the JSON detector never sees.
7
+ *
8
+ * Covered (gated to `.bicep` files):
9
+ * - `Microsoft.KeyVault/vaults/keys` `kty: 'RSA' | 'RSA-HSM' | 'EC' | 'EC-HSM'` — a
10
+ * classical Key Vault key. RSA is KEM (HNDL); EC feeds ECDSA + ECDH (the ECDH path
11
+ * is HNDL). Gated to a `Microsoft.KeyVault` marker so a stray `kty` elsewhere in a
12
+ * template does not fire.
13
+ * - `minimumTlsVersion: 'TLS1_0' | 'TLS1_1'` — a deprecated TLS floor on storage /
14
+ * app-service / other resources (RFC 8996). Not HNDL (a config weakness), category
15
+ * "tls".
16
+ */
17
+ import type { Detector, Finding, RuleMeta } from "../types.js";
18
+ import {
19
+ eachMatch,
20
+ findingFromRule,
21
+ hasExtension,
22
+ maskBlockComments,
23
+ maskCommentLines,
24
+ } from "../detect-utils.js";
25
+ import { CWE_BROKEN_CRYPTO, CWE_WEAK_STRENGTH } from "../cwe.js";
26
+
27
+ const BICEP_EXTENSIONS: readonly string[] = [".bicep"];
28
+
29
+ // Bicep string values are single-quoted. `kty: 'RSA'` / `'RSA-HSM'` (KEM) and
30
+ // `kty: 'EC'` / `'EC-HSM'` (EC). The `(?<![\w-])` lookbehind stops a longer key name
31
+ // from matching on a `kty` suffix; the value bound keeps `'EC'` from matching `'ECX'`.
32
+ const RE_BICEP_KTY_RSA = /(?<![\w-])kty\s*:\s*'RSA(?:-HSM)?'/g;
33
+ const RE_BICEP_KTY_EC = /(?<![\w-])kty\s*:\s*'EC(?:-HSM)?'/g;
34
+ // Legacy TLS floor. `TLS1_0` / `TLS1_1` are deprecated; `TLS1_2` / `TLS1_3` are fine,
35
+ // and the closing quote keeps this from matching them.
36
+ const RE_BICEP_MIN_TLS = /(?<![\w])minimumTlsVersion\s*:\s*'TLS1_[01]'/g;
37
+
38
+ const RULE_BICEP_KTY_RSA: RuleMeta = {
39
+ id: "bicep-keyvault-rsa",
40
+ title: "Bicep Azure Key Vault RSA key",
41
+ description: "Azure Bicep Microsoft.KeyVault key with kty: 'RSA'",
42
+ category: "kem",
43
+ severity: "high",
44
+ confidence: "high",
45
+ algorithm: "RSA",
46
+ hndl: true,
47
+ cwe: CWE_BROKEN_CRYPTO,
48
+ message: "Bicep provisions a classical RSA Azure Key Vault key, which is not quantum-safe.",
49
+ remediation: "Plan migration to PQC (ML-KEM-768 for encryption, ML-DSA-65 for signatures).",
50
+ };
51
+ const RULE_BICEP_KTY_EC: RuleMeta = {
52
+ id: "bicep-keyvault-ec",
53
+ title: "Bicep Azure Key Vault EC key",
54
+ description: "Azure Bicep Microsoft.KeyVault key with kty: 'EC'",
55
+ category: "key-exchange",
56
+ severity: "high",
57
+ confidence: "high",
58
+ algorithm: "ECDH",
59
+ hndl: true,
60
+ cwe: CWE_BROKEN_CRYPTO,
61
+ message:
62
+ "Bicep provisions a classical EC Azure Key Vault key; EC keys feed ECDSA signatures and ECDH key agreement (the ECDH path is harvest-now-decrypt-later exposed).",
63
+ remediation:
64
+ "For key agreement: hybrid X25519MLKEM768 (ML-KEM-768). For signatures: ML-DSA-65 (FIPS 204).",
65
+ };
66
+ const RULE_BICEP_MIN_TLS: RuleMeta = {
67
+ id: "bicep-min-tls-legacy",
68
+ title: "Bicep legacy minimum TLS version",
69
+ description: "Azure Bicep resource pins minimumTlsVersion to TLS 1.0/1.1",
70
+ category: "tls",
71
+ severity: "medium",
72
+ confidence: "high",
73
+ hndl: false,
74
+ cwe: CWE_WEAK_STRENGTH,
75
+ message: "Bicep resource pins a deprecated TLS floor (TLS 1.0/1.1); require TLS 1.2+ (1.3).",
76
+ remediation: "Set minimumTlsVersion: 'TLS1_2' and prefer PQC-hybrid key exchange as it lands.",
77
+ };
78
+
79
+ /** Detects classical asymmetric crypto and legacy TLS declared in Azure Bicep. */
80
+ export const bicepDetector: Detector = {
81
+ id: "bicep-crypto",
82
+ description: "Classical asymmetric crypto and legacy TLS declared in Azure Bicep (IaC)",
83
+ scope: "config",
84
+ language: "any",
85
+ rules: [RULE_BICEP_KTY_RSA, RULE_BICEP_KTY_EC, RULE_BICEP_MIN_TLS],
86
+ appliesTo: (f) => hasExtension(f, BICEP_EXTENSIONS),
87
+ detect({ file, content }): Finding[] {
88
+ // Bicep comments are `//` and `/* … */`; mask block comments (multi-line) then
89
+ // whole `//` comment lines so a commented-out resource can't fire. Offsets preserved.
90
+ const scan = maskCommentLines(maskBlockComments(content), ["//"]);
91
+ const findings: Finding[] = [];
92
+ const add = (re: RegExp, rule: RuleMeta) =>
93
+ eachMatch(re, scan, (m) =>
94
+ findings.push(
95
+ findingFromRule(rule, { file, content, index: m.index, matchLength: m[0].length }),
96
+ ),
97
+ );
98
+ // The bare `kty` field is generic; only treat it as a Key Vault key when the
99
+ // resource type is actually present, mirroring the cloudformation ARM gate.
100
+ if (content.includes("Microsoft.KeyVault")) {
101
+ add(RE_BICEP_KTY_RSA, RULE_BICEP_KTY_RSA);
102
+ add(RE_BICEP_KTY_EC, RULE_BICEP_KTY_EC);
103
+ }
104
+ add(RE_BICEP_MIN_TLS, RULE_BICEP_MIN_TLS);
105
+ return findings;
106
+ },
107
+ };
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Source-code detector for classical asymmetric cryptography in C / C++ using
3
- * OpenSSL (the dominant crypto library for the ecosystem). Lexical, same
4
- * strategy as the other packs; the OpenSSL function names are distinctive.
3
+ * OpenSSL (the dominant crypto library for the ecosystem), libsodium, and — for
4
+ * the embedded / firmware / IoT niche Mbed TLS (`mbedtls_*`) and wolfSSL /
5
+ * wolfCrypt (`wc_*`). Lexical, same strategy as the other packs; every library's
6
+ * function names are distinctive enough to keep the false-positive risk low.
5
7
  *
6
8
  * NOTE: scanning OpenSSL's OWN source/headers will naturally light up (the
7
9
  * library declares these symbols) — that is inherent to lexical scanning of a
@@ -46,8 +48,28 @@ const RE_C_RSA_VERIFY = /\bRSA_verify\s*\(/g;
46
48
  const RE_C_RSA_CRYPT = /\bRSA_public_encrypt\s*\(|\bRSA_private_decrypt\s*\(/g;
47
49
  // C/OpenSSL legacy TLS configuration (mirrors source.ts tlsDetector): forcing a
48
50
  // deprecated protocol version or disabling certificate verification.
49
- const RE_C_TLS_VERSION = /\bTLSv1_method\b|\bSSLv3_method\b/g;
51
+ // TLSv1_method / TLSv1_1_method (+ the client/server-specific variants) and the
52
+ // SSLv2/SSLv3 method constructors — all pin a deprecated protocol (RFC 8996).
53
+ const RE_C_TLS_VERSION = /\b(?:TLSv1(?:_1)?|SSLv2|SSLv3)(?:_client|_server)?_method\b/g;
50
54
  const RE_C_TLS_VERIFY_NONE = /\bSSL_VERIFY_NONE\b/g;
55
+ // Embedded C crypto libraries (the "embedded" niche): Mbed TLS and wolfSSL /
56
+ // wolfCrypt. Both use highly-distinctive `mbedtls_*` / `wc_*` prefixes, so the
57
+ // false-positive risk is low. These dominate firmware / IoT / RTOS builds where
58
+ // OpenSSL is too heavy — a codebase surface qScan previously missed entirely.
59
+ const RE_C_MBEDTLS_RSA = /\bmbedtls_rsa_gen_key\s*\(/g;
60
+ const RE_C_MBEDTLS_EC = /\bmbedtls_ecp_gen_key(?:pair)?\s*\(/g;
61
+ const RE_C_MBEDTLS_ECDSA =
62
+ /\bmbedtls_ecdsa_(?:sign|write_signature|read_signature|verify)\w*\s*\(/g;
63
+ const RE_C_MBEDTLS_ECDH = /\bmbedtls_ecdh_(?:compute_shared|calc_secret)\s*\(/g;
64
+ const RE_C_MBEDTLS_DH = /\bmbedtls_dhm_(?:make_public|make_params|calc_secret)\s*\(/g;
65
+ const RE_C_WOLF_RSA =
66
+ /\bwc_MakeRsaKey\s*\(|\bwc_RsaPublicEncrypt\s*\(|\bwc_RsaPrivateDecrypt\s*\(/g;
67
+ const RE_C_WOLF_ECC = /\bwc_ecc_make_key(?:_ex)?\s*\(/g;
68
+ const RE_C_WOLF_ECDSA = /\bwc_ecc_sign_hash\s*\(|\bwc_ecc_verify_hash\s*\(/g;
69
+ const RE_C_WOLF_ECDH = /\bwc_ecc_shared_secret\s*\(/g;
70
+ const RE_C_WOLF_DH = /\bwc_DhGenerateKeyPair\s*\(|\bwc_DhAgree\s*\(/g;
71
+ const RE_C_WOLF_CURVE25519 = /\bwc_curve25519_(?:make_key|shared_secret)\s*\(/g;
72
+ const RE_C_WOLF_ED25519 = /\bwc_ed25519_(?:make_key|sign_msg|verify_msg)\s*\(/g;
51
73
 
52
74
  const RULE_C_RSA: RuleMeta = {
53
75
  id: "c-rsa-keygen",
@@ -275,11 +297,173 @@ const RULE_C_TLS_VERIFY_NONE: RuleMeta = {
275
297
  message: "SSL_VERIFY_NONE disables TLS certificate verification (MITM risk).",
276
298
  remediation: "Use SSL_VERIFY_PEER and verify certificates properly.",
277
299
  };
300
+ // --- Mbed TLS (embedded) ---
301
+ const RULE_C_MBEDTLS_RSA: RuleMeta = {
302
+ id: "c-mbedtls-rsa-keygen",
303
+ title: "Mbed TLS RSA key generation",
304
+ description: "Mbed TLS mbedtls_rsa_gen_key",
305
+ category: "kem",
306
+ severity: "high",
307
+ confidence: "high",
308
+ algorithm: "RSA",
309
+ hndl: true,
310
+ cwe: CWE_BROKEN_CRYPTO,
311
+ message: "Generates a classical RSA key pair (Mbed TLS, embedded), which is not quantum-safe.",
312
+ };
313
+ const RULE_C_MBEDTLS_EC: RuleMeta = {
314
+ id: "c-mbedtls-ec-keygen",
315
+ title: "Mbed TLS EC key generation",
316
+ description: "Mbed TLS mbedtls_ecp_gen_key / mbedtls_ecp_gen_keypair",
317
+ category: "key-exchange",
318
+ severity: "high",
319
+ confidence: "high",
320
+ algorithm: "ECDH",
321
+ hndl: true,
322
+ cwe: CWE_BROKEN_CRYPTO,
323
+ message:
324
+ "Generates a classical EC key pair (Mbed TLS, embedded). EC keys feed BOTH ECDSA signatures and ECDH key agreement; the ECDH path is harvest-now-decrypt-later exposed.",
325
+ remediation:
326
+ "For key agreement: hybrid X25519MLKEM768 (ML-KEM-768). For signatures: ML-DSA-65 (FIPS 204).",
327
+ };
328
+ const RULE_C_MBEDTLS_ECDSA: RuleMeta = {
329
+ id: "c-mbedtls-ecdsa",
330
+ title: "Mbed TLS ECDSA signature",
331
+ description: "Mbed TLS mbedtls_ecdsa_sign / write_signature / read_signature / verify",
332
+ category: "signature",
333
+ severity: "high",
334
+ confidence: "high",
335
+ algorithm: "ECDSA",
336
+ hndl: false,
337
+ cwe: CWE_BROKEN_CRYPTO,
338
+ message: "Classical ECDSA (Mbed TLS, embedded) is forgeable by a quantum attacker.",
339
+ remediation: "ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)",
340
+ };
341
+ const RULE_C_MBEDTLS_ECDH: RuleMeta = {
342
+ id: "c-mbedtls-ecdh",
343
+ title: "Mbed TLS ECDH key agreement",
344
+ description: "Mbed TLS mbedtls_ecdh_compute_shared / mbedtls_ecdh_calc_secret",
345
+ category: "key-exchange",
346
+ severity: "high",
347
+ confidence: "high",
348
+ algorithm: "ECDH",
349
+ hndl: true,
350
+ cwe: CWE_BROKEN_CRYPTO,
351
+ message:
352
+ "Elliptic-curve Diffie-Hellman (Mbed TLS, embedded) is broken by Shor's algorithm (harvest-now-decrypt-later).",
353
+ };
354
+ const RULE_C_MBEDTLS_DH: RuleMeta = {
355
+ id: "c-mbedtls-dh",
356
+ title: "Mbed TLS Diffie-Hellman key exchange",
357
+ description: "Mbed TLS mbedtls_dhm_make_public / make_params / calc_secret",
358
+ category: "key-exchange",
359
+ severity: "high",
360
+ confidence: "high",
361
+ algorithm: "DH",
362
+ hndl: true,
363
+ cwe: CWE_BROKEN_CRYPTO,
364
+ message:
365
+ "Finite-field Diffie-Hellman (Mbed TLS, embedded) is broken by Shor's algorithm (harvest-now-decrypt-later).",
366
+ };
367
+ // --- wolfSSL / wolfCrypt (embedded) ---
368
+ const RULE_C_WOLF_RSA: RuleMeta = {
369
+ id: "c-wolfssl-rsa",
370
+ title: "wolfSSL RSA key/usage",
371
+ description: "wolfCrypt wc_MakeRsaKey / wc_RsaPublicEncrypt / wc_RsaPrivateDecrypt",
372
+ category: "kem",
373
+ severity: "high",
374
+ confidence: "high",
375
+ algorithm: "RSA",
376
+ hndl: true,
377
+ cwe: CWE_BROKEN_CRYPTO,
378
+ message:
379
+ "Classical RSA key generation / encryption (wolfSSL, embedded) is harvest-now-decrypt-later exposed.",
380
+ };
381
+ const RULE_C_WOLF_ECC: RuleMeta = {
382
+ id: "c-wolfssl-ecc-keygen",
383
+ title: "wolfSSL EC key generation",
384
+ description: "wolfCrypt wc_ecc_make_key / wc_ecc_make_key_ex",
385
+ category: "key-exchange",
386
+ severity: "high",
387
+ confidence: "high",
388
+ algorithm: "ECDH",
389
+ hndl: true,
390
+ cwe: CWE_BROKEN_CRYPTO,
391
+ message:
392
+ "Generates a classical EC key pair (wolfSSL, embedded). EC keys feed BOTH ECDSA signatures and ECDH key agreement; the ECDH path is harvest-now-decrypt-later exposed.",
393
+ remediation:
394
+ "For key agreement: hybrid X25519MLKEM768 (ML-KEM-768). For signatures: ML-DSA-65 (FIPS 204).",
395
+ };
396
+ const RULE_C_WOLF_ECDSA: RuleMeta = {
397
+ id: "c-wolfssl-ecdsa",
398
+ title: "wolfSSL ECDSA signature",
399
+ description: "wolfCrypt wc_ecc_sign_hash / wc_ecc_verify_hash",
400
+ category: "signature",
401
+ severity: "high",
402
+ confidence: "high",
403
+ algorithm: "ECDSA",
404
+ hndl: false,
405
+ cwe: CWE_BROKEN_CRYPTO,
406
+ message: "Classical ECDSA (wolfSSL, embedded) is forgeable by a quantum attacker.",
407
+ remediation: "ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)",
408
+ };
409
+ const RULE_C_WOLF_ECDH: RuleMeta = {
410
+ id: "c-wolfssl-ecdh",
411
+ title: "wolfSSL ECDH key agreement",
412
+ description: "wolfCrypt wc_ecc_shared_secret",
413
+ category: "key-exchange",
414
+ severity: "high",
415
+ confidence: "high",
416
+ algorithm: "ECDH",
417
+ hndl: true,
418
+ cwe: CWE_BROKEN_CRYPTO,
419
+ message:
420
+ "Elliptic-curve Diffie-Hellman (wolfSSL, embedded) is broken by Shor's algorithm (harvest-now-decrypt-later).",
421
+ };
422
+ const RULE_C_WOLF_DH: RuleMeta = {
423
+ id: "c-wolfssl-dh",
424
+ title: "wolfSSL Diffie-Hellman key exchange",
425
+ description: "wolfCrypt wc_DhGenerateKeyPair / wc_DhAgree",
426
+ category: "key-exchange",
427
+ severity: "high",
428
+ confidence: "high",
429
+ algorithm: "DH",
430
+ hndl: true,
431
+ cwe: CWE_BROKEN_CRYPTO,
432
+ message:
433
+ "Finite-field Diffie-Hellman (wolfSSL, embedded) is broken by Shor's algorithm (harvest-now-decrypt-later).",
434
+ };
435
+ const RULE_C_WOLF_CURVE25519: RuleMeta = {
436
+ id: "c-wolfssl-curve25519",
437
+ title: "wolfSSL X25519 key agreement",
438
+ description: "wolfCrypt wc_curve25519_make_key / wc_curve25519_shared_secret",
439
+ category: "key-exchange",
440
+ severity: "medium",
441
+ confidence: "high",
442
+ algorithm: "X25519",
443
+ hndl: true,
444
+ cwe: CWE_BROKEN_CRYPTO,
445
+ message:
446
+ "X25519 key agreement (wolfSSL, embedded) is modern but classical, and harvest-now-decrypt-later exposed.",
447
+ };
448
+ const RULE_C_WOLF_ED25519: RuleMeta = {
449
+ id: "c-wolfssl-ed25519",
450
+ title: "wolfSSL Ed25519 signature",
451
+ description: "wolfCrypt wc_ed25519_make_key / wc_ed25519_sign_msg / wc_ed25519_verify_msg",
452
+ category: "signature",
453
+ severity: "low",
454
+ confidence: "high",
455
+ algorithm: "EdDSA",
456
+ hndl: false,
457
+ cwe: CWE_BROKEN_CRYPTO,
458
+ message:
459
+ "Ed25519 signatures (wolfSSL, embedded) are classical and forgeable by a quantum attacker.",
460
+ remediation: "ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)",
461
+ };
278
462
 
279
463
  /** Detects classical asymmetric crypto in C/C++ (OpenSSL). */
280
464
  export const cDetector: Detector = {
281
465
  id: "c-crypto",
282
- description: "Classical asymmetric crypto in C/C++ (OpenSSL)",
466
+ description: "Classical asymmetric crypto in C/C++ (OpenSSL, libsodium, Mbed TLS, wolfSSL)",
283
467
  scope: "source",
284
468
  language: "c",
285
469
  rules: [
@@ -300,6 +484,18 @@ export const cDetector: Detector = {
300
484
  RULE_C_RSA_CRYPT,
301
485
  RULE_C_TLS_VERSION,
302
486
  RULE_C_TLS_VERIFY_NONE,
487
+ RULE_C_MBEDTLS_RSA,
488
+ RULE_C_MBEDTLS_EC,
489
+ RULE_C_MBEDTLS_ECDSA,
490
+ RULE_C_MBEDTLS_ECDH,
491
+ RULE_C_MBEDTLS_DH,
492
+ RULE_C_WOLF_RSA,
493
+ RULE_C_WOLF_ECC,
494
+ RULE_C_WOLF_ECDSA,
495
+ RULE_C_WOLF_ECDH,
496
+ RULE_C_WOLF_DH,
497
+ RULE_C_WOLF_CURVE25519,
498
+ RULE_C_WOLF_ED25519,
303
499
  ],
304
500
  appliesTo: (f) => hasExtension(f, C_EXTENSIONS),
305
501
  detect({ file, content }): Finding[] {
@@ -317,9 +513,35 @@ export const cDetector: Detector = {
317
513
  add(RE_C_DSA, RULE_C_DSA);
318
514
  add(RE_C_DH, RULE_C_DH);
319
515
  add(RE_C_EVP_KEYGEN, RULE_C_EVP_KEYGEN);
320
- add(RE_C_EVP_DERIVE, RULE_C_EVP_DERIVE);
516
+ // `EVP_PKEY_derive` is OpenSSL's entry point for BOTH (EC)DH key agreement and the
517
+ // symmetric KDFs (HKDF/scrypt/TLS1-PRF). Real (EC)DH always sets a peer key via
518
+ // `EVP_PKEY_derive_set_peer`; a KDF never does. So only treat it as classical key
519
+ // agreement when a peer is set, or when no KDF context marker is present.
520
+ const hasKdfCtx = /\bEVP_PKEY_(?:HKDF|SCRYPT|TLS1_PRF)\b/.test(content);
521
+ if (content.includes("EVP_PKEY_derive_set_peer") || !hasKdfCtx) {
522
+ add(RE_C_EVP_DERIVE, RULE_C_EVP_DERIVE);
523
+ }
321
524
  add(RE_C_EVP_CRYPT, RULE_C_EVP_CRYPT);
322
- add(RE_C_EVP_SIGN, RULE_C_EVP_SIGN);
525
+ // `EVP_DigestSign*` also drives HMAC/CMAC (a symmetric MAC keyed by
526
+ // `EVP_PKEY_new_mac_key(EVP_PKEY_HMAC/CMAC, …)`), which is NOT a classical
527
+ // asymmetric signature. Suppress a `DigestSign*` match ONLY when a MAC key setup
528
+ // sits just before it — per-match, so a real RSA/ECDSA sign elsewhere in the same
529
+ // file is still reported. `DigestVerify*` (no MAC form here) is never suppressed.
530
+ eachMatch(RE_C_EVP_SIGN, content, (m) => {
531
+ const isSign = m[0].includes("DigestSign");
532
+ if (isSign) {
533
+ const back = content.slice(Math.max(0, m.index - 300), m.index);
534
+ if (/EVP_PKEY_new_mac_key|EVP_PKEY_(?:HMAC|CMAC)\b/.test(back)) return;
535
+ }
536
+ findings.push(
537
+ findingFromRule(RULE_C_EVP_SIGN, {
538
+ file,
539
+ content,
540
+ index: m.index,
541
+ matchLength: m[0].length,
542
+ }),
543
+ );
544
+ });
323
545
  add(RE_C_SODIUM_BOX, RULE_C_SODIUM_BOX);
324
546
  add(RE_C_SODIUM_SIGN, RULE_C_SODIUM_SIGN);
325
547
  add(RE_C_ECDSA_VERIFY, RULE_C_ECDSA_VERIFY);
@@ -327,6 +549,18 @@ export const cDetector: Detector = {
327
549
  add(RE_C_RSA_CRYPT, RULE_C_RSA_CRYPT);
328
550
  add(RE_C_TLS_VERSION, RULE_C_TLS_VERSION);
329
551
  add(RE_C_TLS_VERIFY_NONE, RULE_C_TLS_VERIFY_NONE);
552
+ add(RE_C_MBEDTLS_RSA, RULE_C_MBEDTLS_RSA);
553
+ add(RE_C_MBEDTLS_EC, RULE_C_MBEDTLS_EC);
554
+ add(RE_C_MBEDTLS_ECDSA, RULE_C_MBEDTLS_ECDSA);
555
+ add(RE_C_MBEDTLS_ECDH, RULE_C_MBEDTLS_ECDH);
556
+ add(RE_C_MBEDTLS_DH, RULE_C_MBEDTLS_DH);
557
+ add(RE_C_WOLF_RSA, RULE_C_WOLF_RSA);
558
+ add(RE_C_WOLF_ECC, RULE_C_WOLF_ECC);
559
+ add(RE_C_WOLF_ECDSA, RULE_C_WOLF_ECDSA);
560
+ add(RE_C_WOLF_ECDH, RULE_C_WOLF_ECDH);
561
+ add(RE_C_WOLF_DH, RULE_C_WOLF_DH);
562
+ add(RE_C_WOLF_CURVE25519, RULE_C_WOLF_CURVE25519);
563
+ add(RE_C_WOLF_ED25519, RULE_C_WOLF_ED25519);
330
564
  return findings;
331
565
  },
332
566
  };
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Config detector: classical signing of build artifacts and code in CI/CD
3
+ * pipelines (GitHub Actions, GitLab CI, Jenkins, Azure Pipelines, CircleCI).
4
+ *
5
+ * Artifact and code signatures are the signature-side analogue of "harvest now,
6
+ * decrypt later": a release signed today with a classical key is *forgeable* once
7
+ * a CRQC exists, and long-lived artifacts (container images, released binaries,
8
+ * SBOM attestations) keep verifying against that classical public key for years.
9
+ * So these are flagged `hndl:false` (a signature is not confidentiality — nothing
10
+ * to harvest) but remain real quantum-migration debt.
11
+ *
12
+ * Covered command invocations (distinctive enough inside a CI file that the
13
+ * false-positive risk is low):
14
+ * - `cosign sign|attest|generate-key-pair` → sigstore/cosign uses ECDSA P-256
15
+ * (both key-based and keyless/Fulcio).
16
+ * - `gpg --detach-sign|--clearsign|--sign` → GnuPG, classically RSA.
17
+ * - `jarsigner` → Java JAR signing (RSA/DSA/EC).
18
+ * - `codesign --sign|-s` → Apple code signing (RSA).
19
+ * - `minisign` → Ed25519 signatures.
20
+ *
21
+ * Gated to CI/CD pipeline files so `gpg`/`cosign` mentioned in a shell script or
22
+ * doc does not fire; the surface here is specifically the release pipeline.
23
+ */
24
+ import type { Detector, Finding, RuleMeta } from "../types.js";
25
+ import { eachMatch, findingFromRule, maskCommentLines } from "../detect-utils.js";
26
+ import { CWE_BROKEN_CRYPTO } from "../cwe.js";
27
+
28
+ /** True for the CI/CD pipeline definition files this detector inspects. */
29
+ function isCiPipelineFile(filePath: string): boolean {
30
+ const lower = filePath.toLowerCase();
31
+ const base = lower.split("/").pop() ?? lower;
32
+ return (
33
+ (lower.includes(".github/workflows/") && (lower.endsWith(".yml") || lower.endsWith(".yaml"))) ||
34
+ base === ".gitlab-ci.yml" ||
35
+ lower.endsWith(".gitlab-ci.yml") ||
36
+ base === "jenkinsfile" ||
37
+ lower.endsWith(".jenkinsfile") ||
38
+ base === "azure-pipelines.yml" ||
39
+ base === "azure-pipelines.yaml" ||
40
+ (lower.includes(".circleci/") && (lower.endsWith(".yml") || lower.endsWith(".yaml")))
41
+ );
42
+ }
43
+
44
+ interface CiRule {
45
+ re: RegExp;
46
+ meta: RuleMeta;
47
+ }
48
+
49
+ const CI_RULES: CiRule[] = [
50
+ {
51
+ // `sign-blob` precedes `sign` so the longer subcommand wins — otherwise `sign`
52
+ // matches first and the trailing `\b` succeeds at the `-`, never reaching `sign-blob`.
53
+ re: /\bcosign\s+(?:sign-blob|sign|attest|generate-key-pair)\b/g,
54
+ meta: {
55
+ id: "ci-cosign-ecdsa",
56
+ title: "cosign artifact signing (ECDSA)",
57
+ description: "sigstore/cosign signing in a CI pipeline",
58
+ category: "signature",
59
+ severity: "medium",
60
+ confidence: "high",
61
+ algorithm: "ECDSA",
62
+ hndl: false,
63
+ cwe: CWE_BROKEN_CRYPTO,
64
+ message:
65
+ "CI pipeline signs artifacts with cosign (ECDSA P-256, key-based or keyless/Fulcio); classical signatures are forgeable once a CRQC exists.",
66
+ remediation:
67
+ "Track sigstore's post-quantum signing roadmap (ML-DSA); plan hybrid signing for long-lived release artifacts.",
68
+ },
69
+ },
70
+ {
71
+ // Bound the span to the gpg invocation ([^\n&|;] stops it crossing `&&`/`|`/`;`
72
+ // into another command's flag), and `(?![\w-])` stops `--sign` matching the
73
+ // `--sign` prefix of an unrelated flag like `--sign-artifacts`. The short forms
74
+ // `-s` (sign) / `-b` (detach-sign) are safe inside the bounded gpg span.
75
+ re: /\bgpg\b[^\n&|;]{0,120}?\s(?:-[sb]\b|--(?:detach-sign|clearsign|sign)(?![\w-]))/g,
76
+ meta: {
77
+ id: "ci-gpg-sign",
78
+ title: "GPG signing (RSA)",
79
+ description: "GnuPG detached/clear signing in a CI pipeline",
80
+ category: "signature",
81
+ severity: "medium",
82
+ confidence: "high",
83
+ algorithm: "RSA",
84
+ hndl: false,
85
+ cwe: CWE_BROKEN_CRYPTO,
86
+ message:
87
+ "CI pipeline signs with GPG, classically an RSA signing key; forgeable once a CRQC exists.",
88
+ remediation: "Plan migration to ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205) signatures.",
89
+ },
90
+ },
91
+ {
92
+ re: /\bjarsigner\b/g,
93
+ meta: {
94
+ id: "ci-jarsigner",
95
+ title: "Java jarsigner (classical)",
96
+ description: "JDK jarsigner code signing in a CI pipeline",
97
+ category: "signature",
98
+ severity: "medium",
99
+ confidence: "high",
100
+ algorithm: "RSA",
101
+ hndl: false,
102
+ cwe: CWE_BROKEN_CRYPTO,
103
+ message:
104
+ "CI pipeline signs JARs with jarsigner (classical RSA/DSA/EC signing key); forgeable once a CRQC exists.",
105
+ remediation:
106
+ "Plan migration to a PQC signature scheme (ML-DSA-65 / SLH-DSA) as the JDK adds support.",
107
+ },
108
+ },
109
+ {
110
+ // Allow intervening flags (the common `codesign --force --options runtime --sign`
111
+ // form), bounded to the codesign invocation so it can't latch onto a later
112
+ // command's `--sign` across `&&`/`|`/`;`.
113
+ re: /\bcodesign\b[^\n&|;]{0,120}?\s(?:-s\b|--sign\b)/g,
114
+ meta: {
115
+ id: "ci-codesign",
116
+ title: "Apple codesign (RSA)",
117
+ description: "Apple codesign in a CI pipeline",
118
+ category: "signature",
119
+ severity: "medium",
120
+ confidence: "high",
121
+ algorithm: "RSA",
122
+ hndl: false,
123
+ cwe: CWE_BROKEN_CRYPTO,
124
+ message:
125
+ "CI pipeline signs with Apple codesign (classical RSA signing identity); forgeable once a CRQC exists.",
126
+ remediation: "Classical only today; track Apple's PQC signing support and plan migration.",
127
+ },
128
+ },
129
+ {
130
+ re: /\bminisign\b/g,
131
+ meta: {
132
+ id: "ci-minisign",
133
+ title: "minisign (Ed25519)",
134
+ description: "minisign signing in a CI pipeline",
135
+ category: "signature",
136
+ severity: "low",
137
+ confidence: "high",
138
+ algorithm: "EdDSA",
139
+ hndl: false,
140
+ cwe: CWE_BROKEN_CRYPTO,
141
+ message:
142
+ "CI pipeline signs with minisign (Ed25519); modern but classical and forgeable once a CRQC exists.",
143
+ remediation: "Plan migration to ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205).",
144
+ },
145
+ },
146
+ ];
147
+
148
+ /** Detects classical artifact / code signing in CI/CD pipeline definitions. */
149
+ export const cicdDetector: Detector = {
150
+ id: "cicd-signing",
151
+ description: "Classical artifact / code signing in CI/CD pipelines",
152
+ scope: "config",
153
+ language: "any",
154
+ rules: CI_RULES.map((r) => r.meta),
155
+ appliesTo: isCiPipelineFile,
156
+ detect({ file, content }): Finding[] {
157
+ const findings: Finding[] = [];
158
+ // A commented-out CI step (`# - run: cosign sign …`, or a `//` line in a
159
+ // Jenkinsfile) is not an active signing step. Mask comment lines first; offsets
160
+ // are preserved so the snippet from the original `content` stays correct.
161
+ const scan = maskCommentLines(content, ["#", "//"]);
162
+ for (const rule of CI_RULES) {
163
+ eachMatch(rule.re, scan, (m) => {
164
+ findings.push(
165
+ findingFromRule(rule.meta, { file, content, index: m.index, matchLength: m[0].length }),
166
+ );
167
+ });
168
+ }
169
+ return findings;
170
+ },
171
+ };