@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 @@
1
+ {"version":3,"file":"weak-hash.js","sourceRoot":"","sources":["../../src/detectors/weak-hash.ts"],"names":[],"mappings":"AAiEA,OAAO,EACL,cAAc,EACd,SAAS,EACT,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,kFAAkF;AAClF,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,MAAM,YAAY,GAAG,mCAAmC,CAAC;AACzD,iDAAiD;AACjD,MAAM,YAAY,GAAG,mEAAmE,CAAC;AACzF,kFAAkF;AAClF,6DAA6D;AAC7D,MAAM,WAAW,GAAG,2EAA2E,CAAC;AAChG,kFAAkF;AAClF,oFAAoF;AACpF,gFAAgF;AAChF,kFAAkF;AAClF,qFAAqF;AACrF,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA,kDAAkD,CAAC;AAClF,MAAM,eAAe,GAAG,IAAI,MAAM,CAChC,qBAAqB,YAAY,sDAAsD,YAAY,EAAE,EACrG,IAAI,CACL,CAAC;AACF,kFAAkF;AAClF,kFAAkF;AAClF,kEAAkE;AAClE,4EAA4E;AAC5E,kEAA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E,GAAG,EAAE,IAAI,eAAe,EAAE,CAAC;YAC5C,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;gBACrB,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CACxB,QAAQ,CAAC,IAAI,CACX,eAAe,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CACnF,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC","sourcesContent":["/**\n * Config/source detector: weak hash functions (SHA-1, MD5) used specifically in\n * a DIGITAL-SIGNATURE or X.509 CERTIFICATE algorithm — NOT generic hashing and\n * NOT password hashing.\n *\n * WHY THIS LIVES IN A PQC-READINESS TOOL (quantum-adjacent, not quantum-broken).\n * SHA-1/MD5 are not \"quantum-broken\" — Grover only halves preimage strength and\n * a CRQC does not conjure signature-hash collisions. We flag them anyway, and\n * frame them as *quantum-adjacent: same migration window*:\n * - NIST SP 800-131A Rev 3 disallows SHA-1 for generating digital signatures\n * and retires SHA-1 entirely by 2030 — the SAME transition window the same\n * document sets for the classical→PQC migration. One standard, one deadline.\n * - CNSA 2.0 pairs its PQC mandate (ML-KEM / ML-DSA) with SHA-384/512; a\n * CNSA-2.0 target that re-keys to PQC must also drop SHA-1 from its\n * signature/certificate chain in the same effort.\n * - A quantum-readiness migration RE-KEYS and RE-SIGNS every certificate and\n * signature anyway. Surfacing weak signature hashes in that same pass costs\n * nothing extra and closes a today-exploitable gap (SHA-1/MD5 signature\n * forgery via chosen-prefix collisions) alongside the future one.\n * We deliberately do NOT claim these hashes are broken by quantum computers.\n *\n * WHY THE SCOPE IS NARROW (signature/certificate ONLY).\n * A bare `sha1(x)` or `sha1sum file` is often a perfectly acceptable\n * non-security checksum (ETags, cache keys, content addressing, Git object ids).\n * PASSWORD hashing with a weak/fast hash is a real weakness too, but it is a\n * DIFFERENT weakness (CWE-916, needs a slow KDF like Argon2/bcrypt/scrypt), a\n * different remediation, and — crucially — is NOT on the PQC migration path, so\n * it does not belong in this detector. We only fire when the weak hash is bound\n * to a signature/certificate algorithm, where \"move to SHA-256+ while you re-key\n * for PQC\" is exactly the right, single remediation. That binding is enforced by\n * a file-level fast-reject marker (see `hasSignatureMarker`) plus regexes that\n * only match signature/cert *algorithm identifiers*, never a lone hash call.\n *\n * SURFACES COVERED (all verified signature/certificate contexts):\n * 1. Java JCA standard names — `Signature.getInstance(\"SHA1withRSA\")`,\n * `\"MD5withRSA\"`, `\"SHA1withDSA\"`, `\"SHA1withECDSA\"` (JDK Standard Algorithm\n * Names). Regex anchors on the `…with(RSA|DSA|ECDSA)` shape, so the token is\n * unambiguously a signature algorithm, never a bare digest.\n * 2. .NET signing calls — a weak hash passed to `.SignData(…)` / `.SignHash(…)`\n * as `HashAlgorithmName.SHA1` or the legacy string `\"SHA1\"` (e.g.\n * `RSACryptoServiceProvider.SignData(data, \"SHA1\")`). Matched only INSIDE the\n * sign call, so an unrelated `HashAlgorithmName.SHA1` used for a checksum is\n * not flagged.\n * 3. X.509 / ASN.1 signature-algorithm identifiers — the OID *names*\n * (`sha1WithRSAEncryption`, `md5WithRSAEncryption`, `ecdsa-with-SHA1`,\n * `dsaWithSHA1`) and their dotted OIDs (`1.2.840.113549.1.1.5` =\n * sha1WithRSAEncryption, `1.2.840.113549.1.1.4` = md5WithRSAEncryption,\n * `1.2.840.10045.4.1` = ecdsa-with-SHA1). These are certificate\n * signatureAlgorithm values by definition.\n * 4. OpenSSL CLI in a signing/cert context — `-sha1` / `-md5` on the same line\n * as `openssl` AND a certificate/signing subcommand or flag\n * (`req` / `x509` / `ca` / `-sign` / `-signkey`). A bare `openssl dgst -sha1\n * file` (a checksum, no `-sign`) is intentionally NOT matched.\n *\n * NOT DUPLICATED: XML-DSig `rsa-sha1` (see `xmldsig.ts`) and DKIM `rsa-sha1`\n * (see `dkim.ts`) already emit SIGNATURE findings on their own surfaces; this\n * detector deliberately does not touch those and focuses on the Java / .NET /\n * X.509 / OpenSSL surfaces above.\n *\n * Category is `hash` (weak/pre-quantum hash usage — the previously-unused\n * category). `hndl: false` — a signature has no confidentiality to harvest.\n * `algorithm: \"unknown\"` — the weak *hash* is not itself an asymmetric family;\n * the signature it weakens is (RSA/ECDSA/DSA), but the finding is about the hash.\n */\nimport type { Detector, Finding, RuleMeta } from \"../types.js\";\nimport {\n DOC_EXTENSIONS,\n eachMatch,\n findingFromRule,\n hasExtension,\n maskBlockComments,\n maskCommentLines,\n} from \"../detect-utils.js\";\nimport { CWE_BROKEN_CRYPTO } from \"../cwe.js\";\n\n// --- SHA-1 in a signature/certificate algorithm identifier ---------------------\n// Java JCA standard names: `SHA1withRSA`, `SHA1withDSA`, `SHA1withECDSA`. The\n// `…with(RSA|DSA|ECDSA)` shape makes the token unambiguously a signature alg.\n// `-?` tolerates the `SHA-1` spelling; `i` covers case variation in real code.\nconst RE_SHA1_JAVA = /\\bSHA-?1with(?:RSA|DSA|ECDSA)\\b/gi;\n// X.509 / ASN.1 signature-algorithm OID *names*.\nconst RE_SHA1_X509 = /\\b(?:sha-?1WithRSAEncryption|ecdsa-with-SHA-?1|dsaWithSHA-?1)\\b/gi;\n// X.509 signature-algorithm dotted OIDs (sha1WithRSAEncryption, ecdsa-with-SHA1).\n// Lookarounds keep the id from matching inside a longer OID.\nconst RE_SHA1_OID = /(?<![\\d.])(?:1\\.2\\.840\\.113549\\.1\\.1\\.5|1\\.2\\.840\\.10045\\.4\\.1)(?![\\d.])/g;\n// OpenSSL CLI: `-sha1` on the same line as `openssl` AND an actual SIGNING marker\n// (`req` / `ca` subcommand, or `-sign`/`-signkey`/`-CA`/`-CAkey`), in either order.\n// A bare `x509` subcommand is NOT a signing marker — `openssl x509 -fingerprint\n// -sha1` / `-subject_hash` are read-only thumbprint/identifier ops, not signature\n// generation (audit M1). `openssl dgst -sha1 file` (checksum) is likewise unmatched.\nconst OPENSSL_SIGN = String.raw`(?:\\breq\\b|\\bca\\b|-sign(?:key)?\\b|-CA(?:key)?\\b)`;\nconst RE_SHA1_OPENSSL = new RegExp(\n `openssl\\\\b[^\\\\n]*?${OPENSSL_SIGN}[^\\\\n]*?-sha1\\\\b|openssl\\\\b[^\\\\n]*?-sha1\\\\b[^\\\\n]*?${OPENSSL_SIGN}`,\n \"gi\",\n);\n// .NET: a weak hash bound to a signing call (`.SignData(…)` / `.SignHash(…)`), as\n// `HashAlgorithmName.SHA1` or the legacy `\"SHA1\"` string arg. Bounded by `;` (the\n// statement), NOT `)` — the first argument is often itself a call\n// (`.SignData(Encoding.UTF8.GetBytes(m), HashAlgorithmName.SHA1, …)`), so a\n// `[^)]` span would stop at the inner `)` and miss it (audit H3).\nconst RE_SHA1_DOTNET =\n /\\.Sign(?:Data|Hash)\\s*\\([^;]*?(?:HashAlgorithmName\\.SHA-?1|[\"']SHA-?1[\"'])/gi;\n\n// --- MD5 in a signature/certificate algorithm identifier -----------------------\nconst RE_MD5_JAVA = /\\bMD5with(?:RSA|DSA|ECDSA)\\b/gi;\nconst RE_MD5_X509 = /\\bmd5WithRSAEncryption\\b/gi;\nconst RE_MD5_OID = /(?<![\\d.])1\\.2\\.840\\.113549\\.1\\.1\\.4(?![\\d.])/g;\nconst RE_MD5_OPENSSL = new RegExp(\n `openssl\\\\b[^\\\\n]*?${OPENSSL_SIGN}[^\\\\n]*?-md5\\\\b|openssl\\\\b[^\\\\n]*?-md5\\\\b[^\\\\n]*?${OPENSSL_SIGN}`,\n \"gi\",\n);\nconst RE_MD5_DOTNET = /\\.Sign(?:Data|Hash)\\s*\\([^;]*?(?:HashAlgorithmName\\.MD5|[\"']MD5[\"'])/gi;\n\nconst RULE_SHA1: RuleMeta = {\n id: \"weak-hash-sha1-signature\",\n title: \"SHA-1 in a signature / certificate algorithm\",\n description:\n \"SHA-1 used in a digital-signature or X.509 certificate algorithm (Java/.NET/X.509/OpenSSL)\",\n category: \"hash\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"unknown\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"SHA-1 used in a digital-signature/certificate algorithm; SHA-1 is disallowed for signatures (NIST SP 800-131A Rev 3, fully retired 2030 — the same window as the PQC migration) and enables collision-based signature forgery. Quantum-adjacent: migrate the hash alongside the signature algorithm.\",\n remediation:\n \"Move signature/certificate hashes to SHA-256 or stronger (SHA-384/512 for CNSA 2.0 targets) and re-issue affected certificates; fold the PQC signature migration (ML-DSA) into the same re-key/re-sign effort.\",\n};\nconst RULE_MD5: RuleMeta = {\n id: \"weak-hash-md5-signature\",\n title: \"MD5 in a signature / certificate algorithm\",\n description:\n \"MD5 used in a digital-signature or X.509 certificate algorithm (Java/.NET/X.509/OpenSSL)\",\n category: \"hash\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"unknown\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"MD5 used in a digital-signature/certificate algorithm; MD5 signatures are catastrophically broken today (practical chosen-prefix collisions have forged CA certificates) and must be replaced immediately. Quantum-adjacent: migrate the hash alongside the signature algorithm in the PQC re-sign pass.\",\n remediation:\n \"Replace MD5 signature/certificate hashes with SHA-256 or stronger (SHA-384/512 for CNSA 2.0 targets) and re-issue affected certificates immediately; fold the PQC signature migration (ML-DSA) into the same re-key/re-sign effort.\",\n};\n\ninterface WeakHashRule {\n meta: RuleMeta;\n res: readonly RegExp[];\n}\n\nconst WEAK_HASH_RULES: readonly WeakHashRule[] = [\n {\n meta: RULE_SHA1,\n res: [RE_SHA1_JAVA, RE_SHA1_X509, RE_SHA1_OID, RE_SHA1_OPENSSL, RE_SHA1_DOTNET],\n },\n { meta: RULE_MD5, res: [RE_MD5_JAVA, RE_MD5_X509, RE_MD5_OID, RE_MD5_OPENSSL, RE_MD5_DOTNET] },\n];\n\n/**\n * True when `content` carries a signature/certificate marker — a signal that any\n * weak hash present is bound to a signature or cert, not a bare checksum. This is\n * the guard that keeps `sha1(x)` / `sha1sum` / a password hash from ever firing:\n * without one of these markers the file is not scanned at all.\n */\nfunction hasSignatureMarker(content: string): boolean {\n if (\n /with\\s?RSA|with\\s?DSA|with\\s?ECDSA|WithRSAEncryption|ecdsa-with-SHA-?1|dsaWithSHA-?1/i.test(\n content,\n )\n ) {\n return true;\n }\n if (/1\\.2\\.840\\.113549\\.1\\.1\\.[45]|1\\.2\\.840\\.10045\\.4\\.1/.test(content)) return true;\n if (/Signature\\.getInstance|\\.Sign(?:Data|Hash)\\s*\\(/.test(content)) return true;\n // OpenSSL only counts as a marker with a cert/signing subcommand or flag.\n if (/openssl/i.test(content) && /\\b(?:req|x509|ca|-signkey|-sign|dgst)\\b/i.test(content)) {\n return true;\n }\n return false;\n}\n\n/**\n * Detects SHA-1 / MD5 used specifically in signature or certificate algorithms\n * (Java JCA, .NET signing calls, X.509 OID names/OIDs, OpenSSL cert/signing CLI).\n */\nexport const weakHashDetector: Detector = {\n id: \"weak-hash-signature\",\n description: \"Weak hash (SHA-1/MD5) in a digital-signature or X.509 certificate algorithm\",\n scope: \"config\",\n language: \"any\",\n rules: WEAK_HASH_RULES.map((r) => r.meta),\n // Skip prose/docs: a page explaining `SHA1withRSA` is not live config/code.\n appliesTo: (f) => !hasExtension(f, DOC_EXTENSIONS),\n detect({ file, content }): Finding[] {\n // Fast reject on the ORIGINAL content: only scan files whose weak hash is\n // bound to a signature/cert context. A lone `sha1(...)` checksum or a\n // password hash has no such marker and is skipped wholesale.\n if (!hasSignatureMarker(content)) return [];\n\n // Mask C-style block comments and `//` / `#` / `;` line comments so a\n // commented-out algorithm can't fire. Offsets are preserved, so finding\n // line/column/snippet for the live lines stay exact.\n const scan = maskCommentLines(maskBlockComments(content), [\"//\", \"#\", \";\"]);\n const findings: Finding[] = [];\n for (const { meta, res } of WEAK_HASH_RULES) {\n for (const re of res) {\n eachMatch(re, scan, (m) =>\n findings.push(\n findingFromRule(meta, { file, content, index: m.index, matchLength: m[0].length }),\n ),\n );\n }\n }\n return findings;\n },\n};\n"]}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Config detector: classical asymmetric signature algorithms pinned by
3
+ * WebAuthn / FIDO2 / passkey attestation & assertion, expressed as COSE
4
+ * algorithm identifiers in relying-party code and config
5
+ * (@simplewebauthn/server, py_webauthn, go-webauthn, webauthn4j).
6
+ *
7
+ * WHY WebAuthn is PQC-relevant: a WebAuthn credential is an asymmetric key
8
+ * pair whose PUBLIC key the authenticator returns (COSE-encoded) at
9
+ * registration; every subsequent assertion is a classical signature over the
10
+ * authentication challenge, and attestation statements are classical
11
+ * signatures over the credential. These are AUTHENTICATION signatures, not
12
+ * confidentiality — there is nothing to "harvest now" — but the moment a
13
+ * cryptographically-relevant quantum computer (CRQC) exists, an attacker who
14
+ * has a user's registered public key (or an attestation CA's key) can FORGE
15
+ * assertions/attestations and impersonate the user or a genuine authenticator.
16
+ * So every finding here is `category: "signature"`, `hndl: false`.
17
+ *
18
+ * The relying party pins which algorithms it will accept: `pubKeyCredParams`
19
+ * (registration) and `supportedAlgorithmIDs` (verification) enumerate COSE
20
+ * `alg` values, and the classical ones — ES256 (COSE -7, ECDSA P-256),
21
+ * RS256 (-257, RSA), EdDSA (-8) and their P-384/P-521/RSA-2048+ siblings — are
22
+ * exactly the ones a PQC migration must inventory and replace once FIDO/COSE
23
+ * standardise post-quantum algorithm identifiers.
24
+ *
25
+ * WHY numeric COSE ids need their own detector: the existing JWT/JOSE rule
26
+ * only matches QUOTED alg strings (`"ES256"`, `"RS256"`). WebAuthn libraries
27
+ * almost never write those strings — they use the NUMERIC COSE ids
28
+ * (`alg: -7`, `supportedAlgorithmIDs: [-7, -257]`) and language-level enum
29
+ * identifiers (`COSEAlgorithmIdentifier.ES256`, `webauthncose.AlgES256`,
30
+ * `COSEAlgorithmIdentifier.EDDSA`). None of those carry the quote characters
31
+ * the JWT rule keys off, so the entire WebAuthn surface is invisible today.
32
+ *
33
+ * Two independent match shapes per family, both gated by a file-level WebAuthn
34
+ * marker (see `hasWebauthnMarker`) so the generic numeric `alg: -7` form can't
35
+ * fire on unrelated code that happens to assign a small negative number:
36
+ *
37
+ * 1. NUMERIC form — the COSE `alg` value as an integer, either as an object
38
+ * member (`alg: -7`, `alg = -257`) or inside a `supportedAlgorithmIDs`
39
+ * array (`supportedAlgorithmIDs: [-7, -257]`). Restricted to the classical
40
+ * COSE numbers only; symmetric / KDF / "direct" ids (e.g. -6, HS*) are
41
+ * never in the alternation, so they cannot match.
42
+ * 2. ENUM form — the COSE algorithm's identifier as written in each library:
43
+ * `COSEAlgorithmIdentifier.ES256|RS256|EdDSA|ECDSA_SHA_256` (webauthn4j,
44
+ * py_webauthn) and Go's `webauthncose.AlgES256` / `AlgRS256` / `AlgEdDSA`
45
+ * constants.
46
+ *
47
+ * COSE algorithm numbers → {@link AlgorithmFamily} (per the COSE registry, using
48
+ * the mapping this detector is specified against):
49
+ * - ES256 (-7), ES384 (-35), ES512 (-36) → ECDSA
50
+ * - RS256 (-257), RS384 (-258), RS512 (-259) → RSA
51
+ * - EdDSA (-8) → EdDSA
52
+ *
53
+ * Fast reject: `detect()` bails unless the file carries a distinctive WebAuthn
54
+ * API token (`pubKeyCredParams`, `PublicKeyCredential`, `webauthn`,
55
+ * `COSEAlgorithm`, `supportedAlgorithmIDs`, `navigator.credentials`). Those
56
+ * tokens are the marker gate ONLY — they never produce a standalone finding.
57
+ */
58
+ import type { Detector } from "../types.js";
59
+ /** Detects classical COSE signature algorithms pinned by WebAuthn/FIDO2 relying parties. */
60
+ export declare const webauthnDetector: Detector;
61
+ //# sourceMappingURL=webauthn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webauthn.d.ts","sourceRoot":"","sources":["../../src/detectors/webauthn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AAwH/D,4FAA4F;AAC5F,eAAO,MAAM,gBAAgB,EAAE,QA0B9B,CAAC"}
@@ -0,0 +1,109 @@
1
+ import { DOC_EXTENSIONS, eachMatch, findingFromRule, hasExtension, maskBlockComments, maskCommentLines, } from "../detect-utils.js";
2
+ import { CWE_BROKEN_CRYPTO } from "../cwe.js";
3
+ // Classical COSE algorithm numbers, grouped by family (see module docstring).
4
+ const NUM_ECDSA = "7|35|36"; // ES256, ES384, ES512
5
+ const NUM_RSA = "257|258|259"; // RS256, RS384, RS512
6
+ const NUM_EDDSA = "8"; // EdDSA
7
+ // --- NUMERIC form: a COSE `alg` value written as an integer. ---
8
+ // (a) object member: `alg: -7`, `alg = -257` (JS/JSON, Python `alg=-7`).
9
+ // `["']?alg["']?` tolerates the JSON/serialized form `"alg": -7` (the WebAuthn
10
+ // options object is JSON-serializable and often stored/transmitted/tested as JSON
11
+ // with a quoted key), as well as the unquoted `alg: -7` / `alg = -7` (audit M2).
12
+ const RE_NUM_ECDSA = new RegExp(`["']?\\balg\\b["']?\\s*[:=]\\s*-(?:${NUM_ECDSA})\\b`, "g");
13
+ const RE_NUM_RSA = new RegExp(`["']?\\balg\\b["']?\\s*[:=]\\s*-(?:${NUM_RSA})\\b`, "g");
14
+ const RE_NUM_EDDSA = new RegExp(`["']?\\balg\\b["']?\\s*[:=]\\s*-(?:${NUM_EDDSA})\\b`, "g");
15
+ // (b) `supportedAlgorithmIDs: [-7, -257]` array (@simplewebauthn verify option).
16
+ // `[^\]]*` stays inside a single array literal; one match per family even when
17
+ // the array lists several ids of that family.
18
+ const RE_IDS_ECDSA = new RegExp(`supportedAlgorithmIDs\\s*[:=]\\s*\\[[^\\]]*-(?:${NUM_ECDSA})\\b`, "g");
19
+ const RE_IDS_RSA = new RegExp(`supportedAlgorithmIDs\\s*[:=]\\s*\\[[^\\]]*-(?:${NUM_RSA})\\b`, "g");
20
+ const RE_IDS_EDDSA = new RegExp(`supportedAlgorithmIDs\\s*[:=]\\s*\\[[^\\]]*-(?:${NUM_EDDSA})\\b`, "g");
21
+ // --- ENUM form: the COSE algorithm's language-level identifier. ---
22
+ // webauthn4j / py_webauthn: `COSEAlgorithmIdentifier.<name>`; go-webauthn:
23
+ // `webauthncose.Alg<name>` (matched bare as `Alg<name>`).
24
+ const RE_ENUM_ECDSA = /\bCOSEAlgorithmIdentifier\.(?:ES(?:256|384|512)|ECDSA_SHA_(?:256|384|512))\b|\bAlgES(?:256|384|512)\b/g;
25
+ const RE_ENUM_RSA = /\bCOSEAlgorithmIdentifier\.(?:RS(?:256|384|512)|RSASSA_[A-Za-z0-9_]+)\b|\bAlgRS(?:256|384|512)\b/g;
26
+ const RE_ENUM_EDDSA = /\bCOSEAlgorithmIdentifier\.(?:EdDSA|EDDSA)\b|\bAlgEdDSA\b/g;
27
+ const REMEDIATION = "WebAuthn/FIDO2 is standardizing PQC COSE algorithms; inventory the classical attestation/assertion algs now and plan migration.";
28
+ const RULE_WEBAUTHN_ECDSA = {
29
+ id: "webauthn-ecdsa",
30
+ title: "WebAuthn ECDSA COSE algorithm",
31
+ description: "WebAuthn/FIDO2 credential pins a classical ECDSA COSE algorithm (ES256/ES384/ES512)",
32
+ category: "signature",
33
+ severity: "medium",
34
+ confidence: "high",
35
+ algorithm: "ECDSA",
36
+ hndl: false,
37
+ cwe: CWE_BROKEN_CRYPTO,
38
+ message: "WebAuthn/FIDO2 relying party accepts a classical ECDSA COSE algorithm (ES256/ES384/ES512); attestation/assertion signatures become forgeable once a CRQC exists.",
39
+ remediation: REMEDIATION,
40
+ };
41
+ const RULE_WEBAUTHN_RSA = {
42
+ id: "webauthn-rsa",
43
+ title: "WebAuthn RSA COSE algorithm",
44
+ description: "WebAuthn/FIDO2 credential pins a classical RSA COSE algorithm (RS256/RS384/RS512)",
45
+ category: "signature",
46
+ severity: "medium",
47
+ confidence: "high",
48
+ algorithm: "RSA",
49
+ hndl: false,
50
+ cwe: CWE_BROKEN_CRYPTO,
51
+ message: "WebAuthn/FIDO2 relying party accepts a classical RSA COSE algorithm (RS256/RS384/RS512); attestation/assertion signatures become forgeable once a CRQC exists.",
52
+ remediation: REMEDIATION,
53
+ };
54
+ const RULE_WEBAUTHN_EDDSA = {
55
+ id: "webauthn-eddsa",
56
+ title: "WebAuthn EdDSA COSE algorithm",
57
+ description: "WebAuthn/FIDO2 credential pins the classical EdDSA COSE algorithm (COSE -8)",
58
+ category: "signature",
59
+ severity: "medium",
60
+ confidence: "high",
61
+ algorithm: "EdDSA",
62
+ hndl: false,
63
+ cwe: CWE_BROKEN_CRYPTO,
64
+ message: "WebAuthn/FIDO2 relying party accepts the classical EdDSA COSE algorithm (Ed25519); modern but still classical — attestation/assertion signatures become forgeable once a CRQC exists.",
65
+ remediation: REMEDIATION,
66
+ };
67
+ const WEBAUTHN_RULES = [
68
+ { meta: RULE_WEBAUTHN_ECDSA, res: [RE_NUM_ECDSA, RE_IDS_ECDSA, RE_ENUM_ECDSA] },
69
+ { meta: RULE_WEBAUTHN_RSA, res: [RE_NUM_RSA, RE_IDS_RSA, RE_ENUM_RSA] },
70
+ { meta: RULE_WEBAUTHN_EDDSA, res: [RE_NUM_EDDSA, RE_IDS_EDDSA, RE_ENUM_EDDSA] },
71
+ ];
72
+ /**
73
+ * True when `content` carries a distinctive WebAuthn API token. Used ONLY as
74
+ * the fast-reject marker gate — none of these tokens produce a finding — so the
75
+ * generic numeric `alg: -7` form can't fire on unrelated code.
76
+ */
77
+ function hasWebauthnMarker(content) {
78
+ return (content.includes("pubKeyCredParams") ||
79
+ content.includes("PublicKeyCredential") ||
80
+ content.includes("COSEAlgorithm") ||
81
+ content.includes("supportedAlgorithmIDs") ||
82
+ content.includes("navigator.credentials") ||
83
+ /webauthn/i.test(content));
84
+ }
85
+ /** Detects classical COSE signature algorithms pinned by WebAuthn/FIDO2 relying parties. */
86
+ export const webauthnDetector = {
87
+ id: "webauthn-crypto",
88
+ description: "Classical COSE signature algorithms in WebAuthn/FIDO2/passkey relying-party code",
89
+ scope: "config",
90
+ language: "any",
91
+ rules: WEBAUTHN_RULES.map((r) => r.meta),
92
+ appliesTo: (f) => !hasExtension(f, DOC_EXTENSIONS),
93
+ detect({ file, content }) {
94
+ if (!hasWebauthnMarker(content))
95
+ return [];
96
+ // Mask C-style (`//`, `/* */`) and hash (`#`) comments so a commented-out
97
+ // options object can't fire. Offsets are preserved so finding locations stay
98
+ // exact.
99
+ const scan = maskCommentLines(maskBlockComments(content), ["//", "#"]);
100
+ const findings = [];
101
+ for (const { meta, res } of WEBAUTHN_RULES) {
102
+ for (const re of res) {
103
+ eachMatch(re, scan, (m) => findings.push(findingFromRule(meta, { file, content, index: m.index, matchLength: m[0].length })));
104
+ }
105
+ }
106
+ return findings;
107
+ },
108
+ };
109
+ //# sourceMappingURL=webauthn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webauthn.js","sourceRoot":"","sources":["../../src/detectors/webauthn.ts"],"names":[],"mappings":"AA0DA,OAAO,EACL,cAAc,EACd,SAAS,EACT,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,8EAA8E;AAC9E,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,sBAAsB;AACnD,MAAM,OAAO,GAAG,aAAa,CAAC,CAAC,sBAAsB;AACrD,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,QAAQ;AAE/B,kEAAkE;AAClE,yEAAyE;AACzE,+EAA+E;AAC/E,kFAAkF;AAClF,iFAAiF;AACjF,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,sCAAsC,SAAS,MAAM,EAAE,GAAG,CAAC,CAAC;AAC5F,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,sCAAsC,OAAO,MAAM,EAAE,GAAG,CAAC,CAAC;AACxF,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,sCAAsC,SAA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E,CAAC,CAAC,YAAY,CAAC,CAAC,EAAE,cAAc,CAAC;IAClD,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;QACtB,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC;YAAE,OAAO,EAAE,CAAC;QAE3C,0EAA0E;QAC1E,6EAA6E;QAC7E,SAAS;QACT,MAAM,IAAI,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;QACvE,MAAM,QAAQ,GAAc,EAAE,CAAC;QAC/B,KAAK,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,cAAc,EAAE,CAAC;YAC3C,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;gBACrB,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CACxB,QAAQ,CAAC,IAAI,CACX,eAAe,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CACnF,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC","sourcesContent":["/**\n * Config detector: classical asymmetric signature algorithms pinned by\n * WebAuthn / FIDO2 / passkey attestation & assertion, expressed as COSE\n * algorithm identifiers in relying-party code and config\n * (@simplewebauthn/server, py_webauthn, go-webauthn, webauthn4j).\n *\n * WHY WebAuthn is PQC-relevant: a WebAuthn credential is an asymmetric key\n * pair whose PUBLIC key the authenticator returns (COSE-encoded) at\n * registration; every subsequent assertion is a classical signature over the\n * authentication challenge, and attestation statements are classical\n * signatures over the credential. These are AUTHENTICATION signatures, not\n * confidentiality — there is nothing to \"harvest now\" — but the moment a\n * cryptographically-relevant quantum computer (CRQC) exists, an attacker who\n * has a user's registered public key (or an attestation CA's key) can FORGE\n * assertions/attestations and impersonate the user or a genuine authenticator.\n * So every finding here is `category: \"signature\"`, `hndl: false`.\n *\n * The relying party pins which algorithms it will accept: `pubKeyCredParams`\n * (registration) and `supportedAlgorithmIDs` (verification) enumerate COSE\n * `alg` values, and the classical ones — ES256 (COSE -7, ECDSA P-256),\n * RS256 (-257, RSA), EdDSA (-8) and their P-384/P-521/RSA-2048+ siblings — are\n * exactly the ones a PQC migration must inventory and replace once FIDO/COSE\n * standardise post-quantum algorithm identifiers.\n *\n * WHY numeric COSE ids need their own detector: the existing JWT/JOSE rule\n * only matches QUOTED alg strings (`\"ES256\"`, `\"RS256\"`). WebAuthn libraries\n * almost never write those strings — they use the NUMERIC COSE ids\n * (`alg: -7`, `supportedAlgorithmIDs: [-7, -257]`) and language-level enum\n * identifiers (`COSEAlgorithmIdentifier.ES256`, `webauthncose.AlgES256`,\n * `COSEAlgorithmIdentifier.EDDSA`). None of those carry the quote characters\n * the JWT rule keys off, so the entire WebAuthn surface is invisible today.\n *\n * Two independent match shapes per family, both gated by a file-level WebAuthn\n * marker (see `hasWebauthnMarker`) so the generic numeric `alg: -7` form can't\n * fire on unrelated code that happens to assign a small negative number:\n *\n * 1. NUMERIC form — the COSE `alg` value as an integer, either as an object\n * member (`alg: -7`, `alg = -257`) or inside a `supportedAlgorithmIDs`\n * array (`supportedAlgorithmIDs: [-7, -257]`). Restricted to the classical\n * COSE numbers only; symmetric / KDF / \"direct\" ids (e.g. -6, HS*) are\n * never in the alternation, so they cannot match.\n * 2. ENUM form — the COSE algorithm's identifier as written in each library:\n * `COSEAlgorithmIdentifier.ES256|RS256|EdDSA|ECDSA_SHA_256` (webauthn4j,\n * py_webauthn) and Go's `webauthncose.AlgES256` / `AlgRS256` / `AlgEdDSA`\n * constants.\n *\n * COSE algorithm numbers → {@link AlgorithmFamily} (per the COSE registry, using\n * the mapping this detector is specified against):\n * - ES256 (-7), ES384 (-35), ES512 (-36) → ECDSA\n * - RS256 (-257), RS384 (-258), RS512 (-259) → RSA\n * - EdDSA (-8) → EdDSA\n *\n * Fast reject: `detect()` bails unless the file carries a distinctive WebAuthn\n * API token (`pubKeyCredParams`, `PublicKeyCredential`, `webauthn`,\n * `COSEAlgorithm`, `supportedAlgorithmIDs`, `navigator.credentials`). Those\n * tokens are the marker gate ONLY — they never produce a standalone finding.\n */\nimport type { Detector, Finding, RuleMeta } from \"../types.js\";\nimport {\n DOC_EXTENSIONS,\n eachMatch,\n findingFromRule,\n hasExtension,\n maskBlockComments,\n maskCommentLines,\n} from \"../detect-utils.js\";\nimport { CWE_BROKEN_CRYPTO } from \"../cwe.js\";\n\n// Classical COSE algorithm numbers, grouped by family (see module docstring).\nconst NUM_ECDSA = \"7|35|36\"; // ES256, ES384, ES512\nconst NUM_RSA = \"257|258|259\"; // RS256, RS384, RS512\nconst NUM_EDDSA = \"8\"; // EdDSA\n\n// --- NUMERIC form: a COSE `alg` value written as an integer. ---\n// (a) object member: `alg: -7`, `alg = -257` (JS/JSON, Python `alg=-7`).\n// `[\"']?alg[\"']?` tolerates the JSON/serialized form `\"alg\": -7` (the WebAuthn\n// options object is JSON-serializable and often stored/transmitted/tested as JSON\n// with a quoted key), as well as the unquoted `alg: -7` / `alg = -7` (audit M2).\nconst RE_NUM_ECDSA = new RegExp(`[\"']?\\\\balg\\\\b[\"']?\\\\s*[:=]\\\\s*-(?:${NUM_ECDSA})\\\\b`, \"g\");\nconst RE_NUM_RSA = new RegExp(`[\"']?\\\\balg\\\\b[\"']?\\\\s*[:=]\\\\s*-(?:${NUM_RSA})\\\\b`, \"g\");\nconst RE_NUM_EDDSA = new RegExp(`[\"']?\\\\balg\\\\b[\"']?\\\\s*[:=]\\\\s*-(?:${NUM_EDDSA})\\\\b`, \"g\");\n// (b) `supportedAlgorithmIDs: [-7, -257]` array (@simplewebauthn verify option).\n// `[^\\]]*` stays inside a single array literal; one match per family even when\n// the array lists several ids of that family.\nconst RE_IDS_ECDSA = new RegExp(\n `supportedAlgorithmIDs\\\\s*[:=]\\\\s*\\\\[[^\\\\]]*-(?:${NUM_ECDSA})\\\\b`,\n \"g\",\n);\nconst RE_IDS_RSA = new RegExp(`supportedAlgorithmIDs\\\\s*[:=]\\\\s*\\\\[[^\\\\]]*-(?:${NUM_RSA})\\\\b`, \"g\");\nconst RE_IDS_EDDSA = new RegExp(\n `supportedAlgorithmIDs\\\\s*[:=]\\\\s*\\\\[[^\\\\]]*-(?:${NUM_EDDSA})\\\\b`,\n \"g\",\n);\n\n// --- ENUM form: the COSE algorithm's language-level identifier. ---\n// webauthn4j / py_webauthn: `COSEAlgorithmIdentifier.<name>`; go-webauthn:\n// `webauthncose.Alg<name>` (matched bare as `Alg<name>`).\nconst RE_ENUM_ECDSA =\n /\\bCOSEAlgorithmIdentifier\\.(?:ES(?:256|384|512)|ECDSA_SHA_(?:256|384|512))\\b|\\bAlgES(?:256|384|512)\\b/g;\nconst RE_ENUM_RSA =\n /\\bCOSEAlgorithmIdentifier\\.(?:RS(?:256|384|512)|RSASSA_[A-Za-z0-9_]+)\\b|\\bAlgRS(?:256|384|512)\\b/g;\nconst RE_ENUM_EDDSA = /\\bCOSEAlgorithmIdentifier\\.(?:EdDSA|EDDSA)\\b|\\bAlgEdDSA\\b/g;\n\nconst REMEDIATION =\n \"WebAuthn/FIDO2 is standardizing PQC COSE algorithms; inventory the classical attestation/assertion algs now and plan migration.\";\n\nconst RULE_WEBAUTHN_ECDSA: RuleMeta = {\n id: \"webauthn-ecdsa\",\n title: \"WebAuthn ECDSA COSE algorithm\",\n description:\n \"WebAuthn/FIDO2 credential pins a classical ECDSA COSE algorithm (ES256/ES384/ES512)\",\n category: \"signature\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"ECDSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"WebAuthn/FIDO2 relying party accepts a classical ECDSA COSE algorithm (ES256/ES384/ES512); attestation/assertion signatures become forgeable once a CRQC exists.\",\n remediation: REMEDIATION,\n};\nconst RULE_WEBAUTHN_RSA: RuleMeta = {\n id: \"webauthn-rsa\",\n title: \"WebAuthn RSA COSE algorithm\",\n description: \"WebAuthn/FIDO2 credential pins a classical RSA COSE algorithm (RS256/RS384/RS512)\",\n category: \"signature\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"WebAuthn/FIDO2 relying party accepts a classical RSA COSE algorithm (RS256/RS384/RS512); attestation/assertion signatures become forgeable once a CRQC exists.\",\n remediation: REMEDIATION,\n};\nconst RULE_WEBAUTHN_EDDSA: RuleMeta = {\n id: \"webauthn-eddsa\",\n title: \"WebAuthn EdDSA COSE algorithm\",\n description: \"WebAuthn/FIDO2 credential pins the classical EdDSA COSE algorithm (COSE -8)\",\n category: \"signature\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"EdDSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"WebAuthn/FIDO2 relying party accepts the classical EdDSA COSE algorithm (Ed25519); modern but still classical — attestation/assertion signatures become forgeable once a CRQC exists.\",\n remediation: REMEDIATION,\n};\n\ninterface WebauthnRule {\n meta: RuleMeta;\n res: readonly RegExp[];\n}\n\nconst WEBAUTHN_RULES: readonly WebauthnRule[] = [\n { meta: RULE_WEBAUTHN_ECDSA, res: [RE_NUM_ECDSA, RE_IDS_ECDSA, RE_ENUM_ECDSA] },\n { meta: RULE_WEBAUTHN_RSA, res: [RE_NUM_RSA, RE_IDS_RSA, RE_ENUM_RSA] },\n { meta: RULE_WEBAUTHN_EDDSA, res: [RE_NUM_EDDSA, RE_IDS_EDDSA, RE_ENUM_EDDSA] },\n];\n\n/**\n * True when `content` carries a distinctive WebAuthn API token. Used ONLY as\n * the fast-reject marker gate — none of these tokens produce a finding — so the\n * generic numeric `alg: -7` form can't fire on unrelated code.\n */\nfunction hasWebauthnMarker(content: string): boolean {\n return (\n content.includes(\"pubKeyCredParams\") ||\n content.includes(\"PublicKeyCredential\") ||\n content.includes(\"COSEAlgorithm\") ||\n content.includes(\"supportedAlgorithmIDs\") ||\n content.includes(\"navigator.credentials\") ||\n /webauthn/i.test(content)\n );\n}\n\n/** Detects classical COSE signature algorithms pinned by WebAuthn/FIDO2 relying parties. */\nexport const webauthnDetector: Detector = {\n id: \"webauthn-crypto\",\n description: \"Classical COSE signature algorithms in WebAuthn/FIDO2/passkey relying-party code\",\n scope: \"config\",\n language: \"any\",\n rules: WEBAUTHN_RULES.map((r) => r.meta),\n appliesTo: (f) => !hasExtension(f, DOC_EXTENSIONS),\n detect({ file, content }): Finding[] {\n if (!hasWebauthnMarker(content)) return [];\n\n // Mask C-style (`//`, `/* */`) and hash (`#`) comments so a commented-out\n // options object can't fire. Offsets are preserved so finding locations stay\n // exact.\n const scan = maskCommentLines(maskBlockComments(content), [\"//\", \"#\"]);\n const findings: Finding[] = [];\n for (const { meta, res } of WEBAUTHN_RULES) {\n for (const re of res) {\n eachMatch(re, scan, (m) =>\n findings.push(\n findingFromRule(meta, { file, content, index: m.index, matchLength: m[0].length }),\n ),\n );\n }\n }\n return findings;\n },\n};\n"]}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Config detector: classical crypto in XML Digital Signature / XML Encryption
3
+ * (W3C XML-DSig / XML-Enc), the algorithm layer under SAML SSO, WS-Security /
4
+ * SOAP, and signed XML documents. Enterprise identity is ubiquitous and its IdP
5
+ * signing keys are long-lived, so a forged SAML assertion is a prime quantum
6
+ * forgery surface; an encrypted SAML assertion (RSA key transport) is
7
+ * harvest-now-decrypt-later exposed.
8
+ *
9
+ * Detection keys off the W3C algorithm URIs, which are globally-unique constant
10
+ * strings (RFC-precise, so a lexical match is exact):
11
+ * - `…xmldsig#rsa-sha1` / `…xmldsig-more#rsa-sha256` … → RSA signature (forgeable)
12
+ * - `…xmldsig11#dsa-sha256` / `…xmldsig#dsa-sha1` → DSA signature
13
+ * - `…xmldsig-more#ecdsa-sha256` … → ECDSA signature
14
+ * - `…xmlenc#rsa-oaep(-mgf1p)` / `…xmlenc#rsa-1_5` → RSA key transport (HNDL)
15
+ *
16
+ * These URIs appear both in XML config (`.xml`) and as string constants in SAML
17
+ * library code (python3-saml, xml-crypto, OpenSAML), so the detector runs on any
18
+ * non-doc file.
19
+ */
20
+ import type { Detector } from "../types.js";
21
+ /** Detects classical XML-DSig / XML-Enc algorithms (SAML, WS-Security, signed XML). */
22
+ export declare const xmldsigDetector: Detector;
23
+ //# sourceMappingURL=xmldsig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xmldsig.d.ts","sourceRoot":"","sources":["../../src/detectors/xmldsig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AAsE/D,uFAAuF;AACvF,eAAO,MAAM,eAAe,EAAE,QAwB7B,CAAC"}
@@ -0,0 +1,84 @@
1
+ import { DOC_EXTENSIONS, eachMatch, findingFromRule, hasExtension } from "../detect-utils.js";
2
+ import { CWE_BROKEN_CRYPTO } from "../cwe.js";
3
+ // The `#fragment` of the W3C XML-DSig / XML-Enc algorithm URIs. Anchored on the
4
+ // namespace fragment (`xmldsig…#` / `xmlenc#`) so a bare `rsa-sha256` elsewhere
5
+ // doesn't misfire.
6
+ const RE_XMLDSIG_RSA = /\bxmldsig(?:-more|11)?#rsa-sha(?:1|224|256|384|512)\b/g;
7
+ const RE_XMLDSIG_DSA = /\bxmldsig(?:11)?#dsa-sha(?:1|256)\b/g;
8
+ const RE_XMLDSIG_ECDSA = /\bxmldsig-more#ecdsa-sha(?:1|224|256|384|512)\b/g;
9
+ const RE_XMLENC_RSA = /\bxmlenc#rsa-(?:oaep(?:-mgf1p)?|1_5)\b/g;
10
+ const RULE_XMLDSIG_RSA = {
11
+ id: "xmldsig-rsa-sign",
12
+ title: "XML-DSig RSA signature",
13
+ description: "XML Digital Signature with an RSA-SHA* algorithm (SAML/WS-Security)",
14
+ category: "signature",
15
+ severity: "medium",
16
+ confidence: "high",
17
+ algorithm: "RSA",
18
+ hndl: false,
19
+ cwe: CWE_BROKEN_CRYPTO,
20
+ message: "XML signatures (SAML / WS-Security) use classical RSA (rsa-sha*); a quantum attacker could forge assertions signed with this key.",
21
+ remediation: "Track PQC XML-DSig / SAML profiles (ML-DSA); rotate to a PQC signing key as tooling and IdPs add support.",
22
+ };
23
+ const RULE_XMLDSIG_DSA = {
24
+ id: "xmldsig-dsa-sign",
25
+ title: "XML-DSig DSA signature",
26
+ description: "XML Digital Signature with a DSA-SHA* algorithm",
27
+ category: "signature",
28
+ severity: "medium",
29
+ confidence: "high",
30
+ algorithm: "DSA",
31
+ hndl: false,
32
+ cwe: CWE_BROKEN_CRYPTO,
33
+ message: "XML signatures use classical DSA (dsa-sha*) — deprecated and quantum-forgeable.",
34
+ remediation: "Migrate off DSA now; track PQC XML-DSig profiles (ML-DSA).",
35
+ };
36
+ const RULE_XMLDSIG_ECDSA = {
37
+ id: "xmldsig-ecdsa-sign",
38
+ title: "XML-DSig ECDSA signature",
39
+ description: "XML Digital Signature with an ECDSA-SHA* algorithm",
40
+ category: "signature",
41
+ severity: "medium",
42
+ confidence: "high",
43
+ algorithm: "ECDSA",
44
+ hndl: false,
45
+ cwe: CWE_BROKEN_CRYPTO,
46
+ message: "XML signatures use classical ECDSA (ecdsa-sha*); forgeable by a quantum attacker.",
47
+ remediation: "Track PQC XML-DSig / SAML profiles (ML-DSA); rotate the signing key when supported.",
48
+ };
49
+ const RULE_XMLENC_RSA = {
50
+ id: "xmlenc-rsa-keytransport",
51
+ title: "XML-Enc RSA key transport",
52
+ description: "XML Encryption with RSA-OAEP / RSA-1_5 key transport (encrypted SAML assertions)",
53
+ category: "kem",
54
+ severity: "high",
55
+ confidence: "high",
56
+ algorithm: "RSA",
57
+ hndl: true,
58
+ cwe: CWE_BROKEN_CRYPTO,
59
+ message: "XML Encryption wraps the content key with classical RSA (rsa-oaep / rsa-1_5); encrypted XML (e.g. SAML assertions) is harvest-now-decrypt-later exposed.",
60
+ remediation: "Plan migration to a post-quantum KEM (ML-KEM-768) for key transport as XML-Enc / SAML PQC profiles mature.",
61
+ };
62
+ /** Detects classical XML-DSig / XML-Enc algorithms (SAML, WS-Security, signed XML). */
63
+ export const xmldsigDetector = {
64
+ id: "xmldsig-crypto",
65
+ description: "Classical XML-DSig / XML-Enc algorithms (SAML, WS-Security, signed XML)",
66
+ scope: "config",
67
+ language: "any",
68
+ // Skip prose/docs: a page explaining the SAML algorithm URIs is not live config.
69
+ appliesTo: (f) => !hasExtension(f, DOC_EXTENSIONS),
70
+ rules: [RULE_XMLDSIG_RSA, RULE_XMLDSIG_DSA, RULE_XMLDSIG_ECDSA, RULE_XMLENC_RSA],
71
+ detect({ file, content }) {
72
+ // Fast reject: only proceed if an XML-DSig / XML-Enc namespace fragment is present.
73
+ if (!content.includes("xmldsig") && !content.includes("xmlenc"))
74
+ return [];
75
+ const findings = [];
76
+ const add = (re, rule) => eachMatch(re, content, (m) => findings.push(findingFromRule(rule, { file, content, index: m.index, matchLength: m[0].length })));
77
+ add(RE_XMLDSIG_RSA, RULE_XMLDSIG_RSA);
78
+ add(RE_XMLDSIG_DSA, RULE_XMLDSIG_DSA);
79
+ add(RE_XMLDSIG_ECDSA, RULE_XMLDSIG_ECDSA);
80
+ add(RE_XMLENC_RSA, RULE_XMLENC_RSA);
81
+ return findings;
82
+ },
83
+ };
84
+ //# sourceMappingURL=xmldsig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xmldsig.js","sourceRoot":"","sources":["../../src/detectors/xmldsig.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,gFAAgF;AAChF,gFAAgF;AAChF,mBAAmB;AACnB,MAAM,cAAc,GAAG,wDAAwD,CAAC;AAChF,MAAM,cAA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,eAAe,CAAC,CAAC;QACpC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC","sourcesContent":["/**\n * Config detector: classical crypto in XML Digital Signature / XML Encryption\n * (W3C XML-DSig / XML-Enc), the algorithm layer under SAML SSO, WS-Security /\n * SOAP, and signed XML documents. Enterprise identity is ubiquitous and its IdP\n * signing keys are long-lived, so a forged SAML assertion is a prime quantum\n * forgery surface; an encrypted SAML assertion (RSA key transport) is\n * harvest-now-decrypt-later exposed.\n *\n * Detection keys off the W3C algorithm URIs, which are globally-unique constant\n * strings (RFC-precise, so a lexical match is exact):\n * - `…xmldsig#rsa-sha1` / `…xmldsig-more#rsa-sha256` … → RSA signature (forgeable)\n * - `…xmldsig11#dsa-sha256` / `…xmldsig#dsa-sha1` → DSA signature\n * - `…xmldsig-more#ecdsa-sha256` … → ECDSA signature\n * - `…xmlenc#rsa-oaep(-mgf1p)` / `…xmlenc#rsa-1_5` → RSA key transport (HNDL)\n *\n * These URIs appear both in XML config (`.xml`) and as string constants in SAML\n * library code (python3-saml, xml-crypto, OpenSAML), so the detector runs on any\n * non-doc file.\n */\nimport type { Detector, Finding, RuleMeta } from \"../types.js\";\nimport { DOC_EXTENSIONS, eachMatch, findingFromRule, hasExtension } from \"../detect-utils.js\";\nimport { CWE_BROKEN_CRYPTO } from \"../cwe.js\";\n\n// The `#fragment` of the W3C XML-DSig / XML-Enc algorithm URIs. Anchored on the\n// namespace fragment (`xmldsig…#` / `xmlenc#`) so a bare `rsa-sha256` elsewhere\n// doesn't misfire.\nconst RE_XMLDSIG_RSA = /\\bxmldsig(?:-more|11)?#rsa-sha(?:1|224|256|384|512)\\b/g;\nconst RE_XMLDSIG_DSA = /\\bxmldsig(?:11)?#dsa-sha(?:1|256)\\b/g;\nconst RE_XMLDSIG_ECDSA = /\\bxmldsig-more#ecdsa-sha(?:1|224|256|384|512)\\b/g;\nconst RE_XMLENC_RSA = /\\bxmlenc#rsa-(?:oaep(?:-mgf1p)?|1_5)\\b/g;\n\nconst RULE_XMLDSIG_RSA: RuleMeta = {\n id: \"xmldsig-rsa-sign\",\n title: \"XML-DSig RSA signature\",\n description: \"XML Digital Signature with an RSA-SHA* algorithm (SAML/WS-Security)\",\n category: \"signature\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"XML signatures (SAML / WS-Security) use classical RSA (rsa-sha*); a quantum attacker could forge assertions signed with this key.\",\n remediation:\n \"Track PQC XML-DSig / SAML profiles (ML-DSA); rotate to a PQC signing key as tooling and IdPs add support.\",\n};\nconst RULE_XMLDSIG_DSA: RuleMeta = {\n id: \"xmldsig-dsa-sign\",\n title: \"XML-DSig DSA signature\",\n description: \"XML Digital Signature with a DSA-SHA* algorithm\",\n category: \"signature\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"DSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"XML signatures use classical DSA (dsa-sha*) — deprecated and quantum-forgeable.\",\n remediation: \"Migrate off DSA now; track PQC XML-DSig profiles (ML-DSA).\",\n};\nconst RULE_XMLDSIG_ECDSA: RuleMeta = {\n id: \"xmldsig-ecdsa-sign\",\n title: \"XML-DSig ECDSA signature\",\n description: \"XML Digital Signature with an ECDSA-SHA* algorithm\",\n category: \"signature\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"ECDSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"XML signatures use classical ECDSA (ecdsa-sha*); forgeable by a quantum attacker.\",\n remediation:\n \"Track PQC XML-DSig / SAML profiles (ML-DSA); rotate the signing key when supported.\",\n};\nconst RULE_XMLENC_RSA: RuleMeta = {\n id: \"xmlenc-rsa-keytransport\",\n title: \"XML-Enc RSA key transport\",\n description: \"XML Encryption with RSA-OAEP / RSA-1_5 key transport (encrypted SAML assertions)\",\n category: \"kem\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"XML Encryption wraps the content key with classical RSA (rsa-oaep / rsa-1_5); encrypted XML (e.g. SAML assertions) is harvest-now-decrypt-later exposed.\",\n remediation:\n \"Plan migration to a post-quantum KEM (ML-KEM-768) for key transport as XML-Enc / SAML PQC profiles mature.\",\n};\n\n/** Detects classical XML-DSig / XML-Enc algorithms (SAML, WS-Security, signed XML). */\nexport const xmldsigDetector: Detector = {\n id: \"xmldsig-crypto\",\n description: \"Classical XML-DSig / XML-Enc algorithms (SAML, WS-Security, signed XML)\",\n scope: \"config\",\n language: \"any\",\n // Skip prose/docs: a page explaining the SAML algorithm URIs is not live config.\n appliesTo: (f) => !hasExtension(f, DOC_EXTENSIONS),\n rules: [RULE_XMLDSIG_RSA, RULE_XMLDSIG_DSA, RULE_XMLDSIG_ECDSA, RULE_XMLENC_RSA],\n detect({ file, content }): Finding[] {\n // Fast reject: only proceed if an XML-DSig / XML-Enc namespace fragment is present.\n if (!content.includes(\"xmldsig\") && !content.includes(\"xmlenc\")) return [];\n const findings: Finding[] = [];\n const add = (re: RegExp, rule: RuleMeta): void =>\n eachMatch(re, content, (m) =>\n findings.push(\n findingFromRule(rule, { file, content, index: m.index, matchLength: m[0].length }),\n ),\n );\n add(RE_XMLDSIG_RSA, RULE_XMLDSIG_RSA);\n add(RE_XMLDSIG_DSA, RULE_XMLDSIG_DSA);\n add(RE_XMLDSIG_ECDSA, RULE_XMLDSIG_ECDSA);\n add(RE_XMLENC_RSA, RULE_XMLENC_RSA);\n return findings;\n },\n};\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { ScanResult } from "./types.js";
2
+ import type { CryptoPolicy, PolicyMapping } from "./policy.js";
2
3
  /** Stable per-finding record for the evidence body (deterministic per commit). */
3
4
  export interface EvidenceFinding {
4
5
  ruleId: string;
@@ -23,14 +24,27 @@ export interface ReadinessReport {
23
24
  };
24
25
  inventory: ScanResult["inventory"];
25
26
  findings: EvidenceFinding[];
27
+ /** §4 policy verdicts, present only when a crypto policy was supplied. */
28
+ policyMapping?: PolicyMapping;
26
29
  cbom: unknown;
27
30
  attestation: {
28
31
  /** sha256 over the canonicalized deterministic body (excludes scanTimeUtc). */
29
32
  contentHash: string;
30
- /** RFC-3161 / transparency-log token — filled by an external signer. */
31
- timestamp: null;
32
- /** Detached signature over `contentHash` filled by an external signer. */
33
- signature: null;
33
+ /**
34
+ * RFC-3161 / transparency-log token over `contentHash`, produced by an EXTERNAL
35
+ * timestamper (opaque string, e.g. base64). `null` until {@link signReadinessReport}
36
+ * runs one.
37
+ */
38
+ timestamp: string | null;
39
+ /**
40
+ * Detached signature over `contentHash`, produced by an EXTERNAL signer (opaque
41
+ * string, e.g. base64/PEM). `null` until {@link signReadinessReport} runs one.
42
+ */
43
+ signature: string | null;
44
+ /** Non-sensitive provenance label of the signer (e.g. "openssl", "cosign"). */
45
+ signedWith?: string;
46
+ /** Non-sensitive provenance label of the timestamper (e.g. "openssl-ts"). */
47
+ timestampedWith?: string;
34
48
  };
35
49
  }
36
50
  export interface ReadinessReportOptions {
@@ -38,6 +52,8 @@ export interface ReadinessReportOptions {
38
52
  repository?: string;
39
53
  /** Full commit SHA (e.g. from `GITHUB_SHA`); omitted → null. */
40
54
  commit?: string;
55
+ /** Optional org cryptography policy — adds the §4 `policyMapping` verdicts. */
56
+ policy?: CryptoPolicy;
41
57
  }
42
58
  /**
43
59
  * Build the A.8.24 readiness report for a scan result. The attestation's
@@ -45,4 +61,63 @@ export interface ReadinessReportOptions {
45
61
  * block itself, so re-running the same scan on the same commit is verifiable.
46
62
  */
47
63
  export declare function buildReadinessReport(result: ScanResult, opts?: ReadinessReportOptions): ReadinessReport;
64
+ /** The result of {@link verifyReadinessReport}. */
65
+ export interface VerifyReadinessResult {
66
+ /** True iff the recomputed body hash equals the hash claimed in the attestation. */
67
+ valid: boolean;
68
+ /** The hash recomputed over the report's CURRENT body. */
69
+ computedHash: string;
70
+ /** The hash claimed in the report's attestation (`attestation.contentHash`). */
71
+ claimedHash: string;
72
+ /** A short human reason; present only when `valid` is false. */
73
+ reason?: string;
74
+ }
75
+ /**
76
+ * Recompute the deterministic content hash over a readiness report's body and
77
+ * compare it to the hash the attestation claims. Detects tampering with ANY
78
+ * hashed field — a finding, the inventory, a policy verdict, or subject/tool
79
+ * metadata: editing it after the fact changes the recomputed hash, so `valid`
80
+ * becomes false.
81
+ *
82
+ * By construction the scan timestamp, the CBOM envelope, and the attestation
83
+ * block itself are EXCLUDED from the hash (see {@link buildReadinessReport}), so
84
+ * touching those does not fail verification — their integrity follows from their
85
+ * hashed inputs. The body is reconstructed from the report's OWN stored fields
86
+ * (including `tool.version`), so a report built by an older qScan still verifies.
87
+ *
88
+ * This checks the INTEGRITY hash only. It does NOT validate the detached
89
+ * signature or RFC-3161 timestamp: those are opaque tokens from an external
90
+ * signer (ADR-0004) and are verified with that signer's own tooling.
91
+ */
92
+ export declare function verifyReadinessReport(report: ReadinessReport): VerifyReadinessResult;
93
+ /**
94
+ * An EXTERNAL signer/timestamper the tool orchestrates. Per ADR-0004 the tool
95
+ * implements no cryptography: it hands the payload to an operator-provided signer
96
+ * (an `openssl`/`cosign` invocation, an RFC-3161 TSA client, …) and records what
97
+ * comes back. `label` is a short, non-sensitive provenance string (e.g. the signer
98
+ * program name) — NOT the full command, which may contain a key path.
99
+ */
100
+ export interface EvidenceSigner {
101
+ label: string;
102
+ /**
103
+ * Produce a detached signature / timestamp token (opaque string) over `payload`.
104
+ * May be async so a future signer can shell out OR call a KMS / RFC-3161 TSA over
105
+ * the network without foreclosing that once this contract freezes at 1.0.
106
+ */
107
+ sign(payload: string): string | Promise<string>;
108
+ }
109
+ /** Options for {@link signReadinessReport}: a detached-signature and/or a timestamp signer. */
110
+ export interface SignEvidenceOptions {
111
+ signer?: EvidenceSigner;
112
+ timestamper?: EvidenceSigner;
113
+ }
114
+ /**
115
+ * Fill a readiness report's attestation with a detached signature and/or RFC-3161
116
+ * timestamp, produced by EXTERNAL signers over the report's `contentHash`. Pure
117
+ * orchestration: it invokes the injected signers and records their opaque output
118
+ * plus a provenance label — it performs no cryptography itself (ADR-0004). Returns a
119
+ * NEW report; the hashed body is untouched (attestation is excluded from the hash),
120
+ * so signing never changes `contentHash`.
121
+ */
122
+ export declare function signReadinessReport(report: ReadinessReport, opts: SignEvidenceOptions): Promise<ReadinessReport>;
48
123
  //# sourceMappingURL=evidence.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"evidence.d.ts","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7C,kFAAkF;AAClF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,wBAAwB,CAAC;IACrC,WAAW,EAAE,CAAC,CAAC;IACf,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACnC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE;QACX,+EAA+E;QAC/E,WAAW,EAAE,MAAM,CAAC;QACpB,wEAAwE;QACxE,SAAS,EAAE,IAAI,CAAC;QAChB,4EAA4E;QAC5E,SAAS,EAAE,IAAI,CAAC;KACjB,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AAe,EACvB,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,eAAe,CAAC,CAgB1B"}
package/dist/evidence.js CHANGED
@@ -19,6 +19,7 @@
19
19
  import { createHash } from "node:crypto";
20
20
  import { toCbom } from "./cbom.js";
21
21
  import { VERSION } from "./version.js";
22
+ import { buildPolicyMapping } from "./policy.js";
22
23
  /** Canonical JSON: object keys sorted recursively, so the hash is reproducible. */
23
24
  function canonicalize(value) {
24
25
  if (Array.isArray(value))
@@ -50,6 +51,9 @@ export function buildReadinessReport(result, opts = {}) {
50
51
  // its CycloneDX envelope carries a volatile timestamp/serial — so it is
51
52
  // EXCLUDED from the hashed body (its integrity follows from its hashed inputs)
52
53
  // to keep the content hash reproducible across scan runs on the same commit.
54
+ // §4: if the org supplied a crypto policy, attest the per-finding verdicts too.
55
+ // Deterministic (same findings + policy → same mapping), so it is hashed.
56
+ const policyMapping = opts.policy ? buildPolicyMapping(result.findings, opts.policy) : undefined;
53
57
  const hashableBody = {
54
58
  reportType: "quantakrypto-readiness",
55
59
  specVersion: 1,
@@ -61,6 +65,7 @@ export function buildReadinessReport(result, opts = {}) {
61
65
  tool: { name: "qScan", version: VERSION },
62
66
  inventory: result.inventory,
63
67
  findings,
68
+ ...(policyMapping ? { policyMapping } : {}),
64
69
  };
65
70
  const contentHash = "sha256:" +
66
71
  createHash("sha256")
@@ -73,4 +78,75 @@ export function buildReadinessReport(result, opts = {}) {
73
78
  attestation: { contentHash, timestamp: null, signature: null },
74
79
  };
75
80
  }
81
+ /**
82
+ * Recompute the deterministic content hash over a readiness report's body and
83
+ * compare it to the hash the attestation claims. Detects tampering with ANY
84
+ * hashed field — a finding, the inventory, a policy verdict, or subject/tool
85
+ * metadata: editing it after the fact changes the recomputed hash, so `valid`
86
+ * becomes false.
87
+ *
88
+ * By construction the scan timestamp, the CBOM envelope, and the attestation
89
+ * block itself are EXCLUDED from the hash (see {@link buildReadinessReport}), so
90
+ * touching those does not fail verification — their integrity follows from their
91
+ * hashed inputs. The body is reconstructed from the report's OWN stored fields
92
+ * (including `tool.version`), so a report built by an older qScan still verifies.
93
+ *
94
+ * This checks the INTEGRITY hash only. It does NOT validate the detached
95
+ * signature or RFC-3161 timestamp: those are opaque tokens from an external
96
+ * signer (ADR-0004) and are verified with that signer's own tooling.
97
+ */
98
+ export function verifyReadinessReport(report) {
99
+ const hashableBody = {
100
+ reportType: report.reportType,
101
+ specVersion: report.specVersion,
102
+ subject: {
103
+ repository: report.subject.repository,
104
+ commit: report.subject.commit,
105
+ scannedRoot: report.subject.scannedRoot,
106
+ },
107
+ tool: { name: report.tool.name, version: report.tool.version },
108
+ inventory: report.inventory,
109
+ findings: report.findings,
110
+ ...(report.policyMapping ? { policyMapping: report.policyMapping } : {}),
111
+ };
112
+ const computedHash = "sha256:" +
113
+ createHash("sha256")
114
+ .update(JSON.stringify(canonicalize(hashableBody)))
115
+ .digest("hex");
116
+ const claimedHash = report.attestation.contentHash;
117
+ if (computedHash === claimedHash) {
118
+ return { valid: true, computedHash, claimedHash };
119
+ }
120
+ return {
121
+ valid: false,
122
+ computedHash,
123
+ claimedHash,
124
+ reason: "content-hash mismatch: the report body was modified after it was built",
125
+ };
126
+ }
127
+ /**
128
+ * Fill a readiness report's attestation with a detached signature and/or RFC-3161
129
+ * timestamp, produced by EXTERNAL signers over the report's `contentHash`. Pure
130
+ * orchestration: it invokes the injected signers and records their opaque output
131
+ * plus a provenance label — it performs no cryptography itself (ADR-0004). Returns a
132
+ * NEW report; the hashed body is untouched (attestation is excluded from the hash),
133
+ * so signing never changes `contentHash`.
134
+ */
135
+ export async function signReadinessReport(report, opts) {
136
+ const payload = report.attestation.contentHash;
137
+ const signature = opts.signer ? await opts.signer.sign(payload) : report.attestation.signature;
138
+ const timestamp = opts.timestamper
139
+ ? await opts.timestamper.sign(payload)
140
+ : report.attestation.timestamp;
141
+ return {
142
+ ...report,
143
+ attestation: {
144
+ ...report.attestation,
145
+ signature,
146
+ timestamp,
147
+ ...(opts.signer ? { signedWith: opts.signer.label } : {}),
148
+ ...(opts.timestamper ? { timestampedWith: opts.timestamper.label } : {}),
149
+ },
150
+ };
151
+ }
76
152
  //# sourceMappingURL=evidence.js.map