@quantakrypto/core 0.4.2 → 0.4.3
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.
- package/LICENSE +201 -0
- package/README.md +38 -10
- package/dist/agent-types.js.map +1 -1
- package/dist/baseline.js.map +1 -1
- package/dist/cache.js.map +1 -1
- package/dist/cbom.js.map +1 -1
- package/dist/changed.js.map +1 -1
- package/dist/codemods/config-toggle.js.map +1 -1
- package/dist/codemods/registry.js.map +1 -1
- package/dist/comments.d.ts +26 -0
- package/dist/comments.d.ts.map +1 -1
- package/dist/comments.js +141 -1
- package/dist/comments.js.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/cwe.js.map +1 -1
- package/dist/dependencies.d.ts +3 -2
- package/dist/dependencies.d.ts.map +1 -1
- package/dist/dependencies.js +138 -2
- package/dist/dependencies.js.map +1 -1
- package/dist/detect-utils.d.ts +14 -3
- package/dist/detect-utils.d.ts.map +1 -1
- package/dist/detect-utils.js +32 -4
- package/dist/detect-utils.js.map +1 -1
- package/dist/detectors/c.d.ts.map +1 -1
- package/dist/detectors/c.js +190 -2
- package/dist/detectors/c.js.map +1 -1
- package/dist/detectors/csharp.d.ts.map +1 -1
- package/dist/detectors/csharp.js +141 -3
- package/dist/detectors/csharp.js.map +1 -1
- package/dist/detectors/go.d.ts +5 -3
- package/dist/detectors/go.d.ts.map +1 -1
- package/dist/detectors/go.js +187 -3
- package/dist/detectors/go.js.map +1 -1
- package/dist/detectors/java.d.ts.map +1 -1
- package/dist/detectors/java.js +168 -3
- package/dist/detectors/java.js.map +1 -1
- package/dist/detectors/pem.d.ts.map +1 -1
- package/dist/detectors/pem.js +49 -1
- package/dist/detectors/pem.js.map +1 -1
- package/dist/detectors/python.d.ts.map +1 -1
- package/dist/detectors/python.js +74 -3
- package/dist/detectors/python.js.map +1 -1
- package/dist/detectors/ruby.d.ts +9 -5
- package/dist/detectors/ruby.d.ts.map +1 -1
- package/dist/detectors/ruby.js +122 -2
- package/dist/detectors/ruby.js.map +1 -1
- package/dist/detectors/rust.d.ts +8 -3
- package/dist/detectors/rust.d.ts.map +1 -1
- package/dist/detectors/rust.js +185 -3
- package/dist/detectors/rust.js.map +1 -1
- package/dist/detectors/source.d.ts.map +1 -1
- package/dist/detectors/source.js +117 -7
- package/dist/detectors/source.js.map +1 -1
- package/dist/detectors/stateful-hbs.d.ts +22 -0
- package/dist/detectors/stateful-hbs.d.ts.map +1 -0
- package/dist/detectors/stateful-hbs.js +139 -0
- package/dist/detectors/stateful-hbs.js.map +1 -0
- package/dist/errors.js.map +1 -1
- package/dist/evidence.d.ts +48 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +76 -0
- package/dist/evidence.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/inventory.d.ts +2 -0
- package/dist/inventory.d.ts.map +1 -1
- package/dist/inventory.js +27 -1
- package/dist/inventory.js.map +1 -1
- package/dist/parallel.js.map +1 -1
- package/dist/patch-policy.js.map +1 -1
- package/dist/redact.d.ts.map +1 -1
- package/dist/redact.js +39 -0
- package/dist/redact.js.map +1 -1
- package/dist/registry.d.ts +2 -2
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +4 -2
- package/dist/registry.js.map +1 -1
- package/dist/remediate-pipeline.d.ts +3 -0
- package/dist/remediate-pipeline.d.ts.map +1 -1
- package/dist/remediate-pipeline.js +50 -0
- package/dist/remediate-pipeline.js.map +1 -1
- package/dist/remediate-request.js.map +1 -1
- package/dist/remediation.d.ts +9 -3
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +17 -5
- package/dist/remediation.js.map +1 -1
- package/dist/report.d.ts +9 -0
- package/dist/report.d.ts.map +1 -1
- package/dist/report.js +31 -0
- package/dist/report.js.map +1 -1
- package/dist/scan-worker.js.map +1 -1
- package/dist/scan.d.ts.map +1 -1
- package/dist/scan.js +8 -1
- package/dist/scan.js.map +1 -1
- package/dist/severity.js.map +1 -1
- package/dist/triage.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/verify.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/walk.js.map +1 -1
- package/dist/worktree.js.map +1 -1
- package/package.json +1 -1
- package/src/comments.ts +140 -1
- package/src/dependencies.ts +143 -4
- package/src/detect-utils.ts +33 -4
- package/src/detectors/c.ts +202 -2
- package/src/detectors/csharp.ts +154 -3
- package/src/detectors/go.ts +209 -6
- package/src/detectors/java.ts +189 -3
- package/src/detectors/pem.ts +53 -1
- package/src/detectors/python.ts +82 -3
- package/src/detectors/ruby.ts +138 -7
- package/src/detectors/rust.ts +211 -7
- package/src/detectors/source.ts +149 -6
- package/src/detectors/stateful-hbs.ts +177 -0
- package/src/evidence.ts +124 -0
- package/src/index.ts +5 -1
- package/src/inventory.ts +31 -1
- package/src/redact.ts +41 -0
- package/src/registry.ts +4 -2
- package/src/remediate-pipeline.ts +55 -0
- package/src/remediation.ts +23 -8
- package/src/report.ts +41 -2
- package/src/scan.ts +13 -1
- package/src/types.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pem.d.ts","sourceRoot":"","sources":["../../src/detectors/pem.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"pem.d.ts","sourceRoot":"","sources":["../../src/detectors/pem.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AA4M/D,+DAA+D;AAC/D,eAAO,MAAM,WAAW,EAAE,QA2BzB,CAAC"}
|
package/dist/detectors/pem.js
CHANGED
|
@@ -66,7 +66,7 @@ const PEM_RULES = [
|
|
|
66
66
|
cwe: CWE_HARDCODED_KEY,
|
|
67
67
|
sensitive: true,
|
|
68
68
|
message: "Embedded OpenSSH private key (RSA/ECDSA/Ed25519); classical and not quantum-safe.",
|
|
69
|
-
remediation: "Rotate the key; plan migration to PQC-capable SSH (
|
|
69
|
+
remediation: "Rotate the key; plan migration to PQC-capable SSH (prefer the mlkem768x25519-sha256 KEX, OpenSSH 10's default since Apr 2025).",
|
|
70
70
|
},
|
|
71
71
|
},
|
|
72
72
|
{
|
|
@@ -135,6 +135,54 @@ const PEM_RULES = [
|
|
|
135
135
|
remediation: "Plan re-issuance with PQC-capable CAs as ML-DSA certificate profiles mature.",
|
|
136
136
|
},
|
|
137
137
|
},
|
|
138
|
+
{
|
|
139
|
+
re: /-----BEGIN (?:RSA )?PUBLIC KEY-----/g,
|
|
140
|
+
meta: {
|
|
141
|
+
id: "pem-public-key",
|
|
142
|
+
title: "Classical public key (PEM)",
|
|
143
|
+
description: "SubjectPublicKeyInfo / PKCS#1 RSA public key block",
|
|
144
|
+
category: "certificate",
|
|
145
|
+
severity: "low",
|
|
146
|
+
confidence: "high",
|
|
147
|
+
algorithm: "unknown",
|
|
148
|
+
hndl: false,
|
|
149
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
150
|
+
message: "Embedded classical public key (RSA/EC/DSA); its key pair is not quantum-safe — forgeable signatures or classical key exchange.",
|
|
151
|
+
remediation: "Re-issue with PQC keys (ML-DSA / ML-KEM) as the ecosystem adopts them.",
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
re: /-----BEGIN DH PARAMETERS-----/g,
|
|
156
|
+
meta: {
|
|
157
|
+
id: "pem-dh-parameters",
|
|
158
|
+
title: "Diffie-Hellman parameters (PEM)",
|
|
159
|
+
description: "Finite-field DH group parameters block",
|
|
160
|
+
category: "key-exchange",
|
|
161
|
+
severity: "medium",
|
|
162
|
+
confidence: "high",
|
|
163
|
+
algorithm: "DH",
|
|
164
|
+
hndl: true,
|
|
165
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
166
|
+
message: "Embedded finite-field Diffie-Hellman parameters; classical DH key exchange is harvest-now-decrypt-later exposed.",
|
|
167
|
+
remediation: "Migrate key exchange to hybrid X25519MLKEM768 (ML-KEM-768).",
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
re: /-----BEGIN (?:NEW )?CERTIFICATE REQUEST-----/g,
|
|
172
|
+
meta: {
|
|
173
|
+
id: "pem-cert-request",
|
|
174
|
+
title: "Certificate signing request (PEM)",
|
|
175
|
+
description: "PKCS#10 certificate request block",
|
|
176
|
+
category: "certificate",
|
|
177
|
+
severity: "low",
|
|
178
|
+
confidence: "high",
|
|
179
|
+
algorithm: "unknown",
|
|
180
|
+
hndl: false,
|
|
181
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
182
|
+
message: "Embedded PKCS#10 CSR; carries a classical public key and will be signed with classical crypto.",
|
|
183
|
+
remediation: "Re-generate with PQC keys as PQC-capable CAs mature.",
|
|
184
|
+
},
|
|
185
|
+
},
|
|
138
186
|
];
|
|
139
187
|
/** Detects PEM key/certificate material in arbitrary files. */
|
|
140
188
|
export const pemDetector = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pem.js","sourceRoot":"","sources":["../../src/detectors/pem.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AASjE,MAAM,SAAS,GAAc;IAC3B;QACE,EAAE,EAAE,kCAAkC;QACtC,IAAI,EAAE;YACJ,EAAE,EAAE,qBAAqB;YACzB,KAAK,EAAE,uBAAuB;YAC9B,WAAW,EAAE,8BAA8B;YAC3C,QAAQ,EAAE,aAAa;YACvB,QAAQ,EAAE,UAAU;YACpB,UAAU,EAAE,MAAM;Y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finds PEM-encoded cryptographic material in\n * any text file (source, config, .pem, .key, .crt, .env, …). This catches\n * embedded private keys and X.509 certificates regardless of language.\n *\n * Every rule's metadata lives in the {@link RuleMeta} declaration below (the\n * catalog entry); `detect()` builds findings straight from it via\n * `findingFromRule`. All PEM findings are high-confidence exact-marker matches.\n */\nimport type { Detector, Finding, RuleMeta } from \"../types.js\";\nimport { eachMatch, findingFromRule } from \"../detect-utils.js\";\nimport { CWE_BROKEN_CRYPTO, CWE_HARDCODED_KEY } from \"../cwe.js\";\n\n/** A PEM rule: its catalog metadata plus the begin-marker regex that triggers it. */\ninterface PemRule {\n /** Regex matching the PEM begin marker. */\n re: RegExp;\n meta: RuleMeta;\n}\n\nconst PEM_RULES: PemRule[] = [\n {\n re: /-----BEGIN RSA PRIVATE KEY-----/g,\n meta: {\n id: \"pem-rsa-private-key\",\n title: \"RSA private key (PEM)\",\n description: \"PKCS#1 RSA private key block\",\n category: \"certificate\",\n severity: \"critical\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: true,\n cwe: CWE_HARDCODED_KEY,\n sensitive: true,\n message: \"Embedded RSA private key (PKCS#1 PEM); classical and not quantum-safe.\",\n remediation: \"Migrate to ML-DSA / ML-KEM keys and remove embedded private keys from source.\",\n },\n },\n {\n re: /-----BEGIN EC PRIVATE KEY-----/g,\n meta: {\n id: \"pem-ec-private-key\",\n title: \"EC private key (PEM)\",\n description: \"SEC1 EC private key block\",\n category: \"certificate\",\n severity: \"critical\",\n confidence: \"high\",\n algorithm: \"ECDSA\",\n hndl: true,\n cwe: CWE_HARDCODED_KEY,\n sensitive: true,\n message: \"Embedded EC private key (SEC1 PEM); classical ECDSA/ECDH key, not quantum-safe.\",\n remediation:\n \"Migrate to ML-DSA (FIPS 204) keys and remove embedded private keys from source.\",\n },\n },\n {\n re: /-----BEGIN DSA PRIVATE KEY-----/g,\n meta: {\n id: \"pem-dsa-private-key\",\n title: \"DSA private key (PEM)\",\n description: \"DSA private key block\",\n category: \"certificate\",\n severity: \"critical\",\n confidence: \"high\",\n algorithm: \"DSA\",\n hndl: false,\n cwe: CWE_HARDCODED_KEY,\n sensitive: true,\n message:\n \"Embedded DSA private key (PEM); classical, already deprecated, and not quantum-safe.\",\n remediation: \"Rotate immediately (DSA is deprecated) and migrate to ML-DSA-65 (FIPS 204).\",\n },\n },\n {\n re: /-----BEGIN OPENSSH PRIVATE KEY-----/g,\n meta: {\n id: \"pem-openssh-private-key\",\n title: \"OpenSSH private key\",\n description: \"OpenSSH private key block\",\n category: \"certificate\",\n severity: \"critical\",\n confidence: \"high\",\n algorithm: \"unknown\",\n hndl: true,\n cwe: CWE_HARDCODED_KEY,\n sensitive: true,\n message: \"Embedded OpenSSH private key (RSA/ECDSA/Ed25519); classical and not quantum-safe.\",\n remediation:\n \"Rotate the key; plan migration to PQC-capable SSH (prefer the mlkem768x25519-sha256 KEX, OpenSSH 10's default since Apr 2025).\",\n },\n },\n {\n re: /-----BEGIN PGP PRIVATE KEY BLOCK-----/g,\n meta: {\n id: \"pem-pgp-private-key\",\n title: \"PGP/GPG private key block\",\n description: \"OpenPGP private key block\",\n category: \"certificate\",\n severity: \"critical\",\n confidence: \"high\",\n algorithm: \"unknown\",\n hndl: true,\n cwe: CWE_HARDCODED_KEY,\n sensitive: true,\n message:\n \"Embedded PGP/GPG private key block (RSA/ECDSA/EdDSA/ElGamal); classical and not quantum-safe.\",\n remediation: \"Rotate the key; track OpenPGP PQC drafts for migration.\",\n },\n },\n {\n re: /-----BEGIN PGP MESSAGE-----/g,\n meta: {\n id: \"pem-pgp-message\",\n title: \"PGP/GPG encrypted message\",\n description: \"OpenPGP encrypted message block\",\n category: \"certificate\",\n severity: \"low\",\n confidence: \"high\",\n algorithm: \"unknown\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Embedded PGP/GPG message; likely encrypted with classical RSA/ElGamal (harvest-now-decrypt-later).\",\n remediation: \"Re-encrypt with PQC-capable tooling as OpenPGP PQC profiles mature.\",\n },\n },\n {\n re: /-----BEGIN (?:ENCRYPTED )?PRIVATE KEY-----/g,\n meta: {\n id: \"pem-pkcs8-private-key\",\n title: \"Private key (PKCS#8 PEM)\",\n description: \"PKCS#8 private key block\",\n category: \"certificate\",\n severity: \"critical\",\n confidence: \"high\",\n algorithm: \"unknown\",\n hndl: true,\n cwe: CWE_HARDCODED_KEY,\n sensitive: true,\n message: \"Embedded PKCS#8 private key; likely classical RSA/EC, not quantum-safe.\",\n remediation: \"Migrate to PQC keys and remove embedded private keys from source.\",\n },\n },\n {\n re: /-----BEGIN CERTIFICATE-----/g,\n meta: {\n id: \"pem-certificate\",\n title: \"X.509 certificate (PEM)\",\n description: \"X.509 certificate block\",\n category: \"certificate\",\n severity: \"low\",\n confidence: \"high\",\n algorithm: \"unknown\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"Embedded X.509 certificate; almost certainly signed with classical RSA/ECDSA.\",\n remediation: \"Plan re-issuance with PQC-capable CAs as ML-DSA certificate profiles mature.\",\n },\n },\n {\n re: /-----BEGIN (?:RSA )?PUBLIC KEY-----/g,\n meta: {\n id: \"pem-public-key\",\n title: \"Classical public key (PEM)\",\n description: \"SubjectPublicKeyInfo / PKCS#1 RSA public key block\",\n category: \"certificate\",\n severity: \"low\",\n confidence: \"high\",\n algorithm: \"unknown\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Embedded classical public key (RSA/EC/DSA); its key pair is not quantum-safe — forgeable signatures or classical key exchange.\",\n remediation: \"Re-issue with PQC keys (ML-DSA / ML-KEM) as the ecosystem adopts them.\",\n },\n },\n {\n re: /-----BEGIN DH PARAMETERS-----/g,\n meta: {\n id: \"pem-dh-parameters\",\n title: \"Diffie-Hellman parameters (PEM)\",\n description: \"Finite-field DH group parameters block\",\n category: \"key-exchange\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"DH\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Embedded finite-field Diffie-Hellman parameters; classical DH key exchange is harvest-now-decrypt-later exposed.\",\n remediation: \"Migrate key exchange to hybrid X25519MLKEM768 (ML-KEM-768).\",\n },\n },\n {\n re: /-----BEGIN (?:NEW )?CERTIFICATE REQUEST-----/g,\n meta: {\n id: \"pem-cert-request\",\n title: \"Certificate signing request (PEM)\",\n description: \"PKCS#10 certificate request block\",\n category: \"certificate\",\n severity: \"low\",\n confidence: \"high\",\n algorithm: \"unknown\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Embedded PKCS#10 CSR; carries a classical public key and will be signed with classical crypto.\",\n remediation: \"Re-generate with PQC keys as PQC-capable CAs mature.\",\n },\n },\n];\n\n/** Detects PEM key/certificate material in arbitrary files. */\nexport const pemDetector: Detector = {\n id: \"pem-material\",\n description: \"PEM-encoded private keys and X.509 certificates in any file\",\n scope: \"config\",\n language: \"any\",\n rules: PEM_RULES.map((r) => r.meta),\n // Applies to every text file; the walker already filters out binaries.\n appliesTo: () => true,\n detect({ file, content }): Finding[] {\n // Fast reject: only proceed if a PEM header is present at all.\n if (!content.includes(\"-----BEGIN \")) return [];\n\n const findings: Finding[] = [];\n for (const rule of PEM_RULES) {\n eachMatch(rule.re, content, (m) => {\n findings.push(\n findingFromRule(rule.meta, {\n file,\n content,\n index: m.index,\n matchLength: m[0].length,\n }),\n );\n });\n }\n return findings;\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/detectors/python.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/detectors/python.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AA6N/D,4DAA4D;AAC5D,eAAO,MAAM,cAAc,EAAE,QA8C5B,CAAC"}
|
package/dist/detectors/python.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PYTHON_EXTENSIONS, eachMatch, findingFromRule, hasExtension } from "../detect-utils.js";
|
|
2
|
-
import { CWE_BROKEN_CRYPTO } from "../cwe.js";
|
|
2
|
+
import { CWE_BROKEN_CRYPTO, CWE_CERT_VALIDATION, CWE_WEAK_STRENGTH } from "../cwe.js";
|
|
3
3
|
/* -------------------------------------------------------------------------- */
|
|
4
4
|
/* Precompiled regexes (module scope) */
|
|
5
5
|
/* -------------------------------------------------------------------------- */
|
|
@@ -12,8 +12,15 @@ const RE_PY_RSA_ENCRYPT = /\bpadding\.OAEP\s*\(|\bPKCS1_OAEP\.new\s*\(/g;
|
|
|
12
12
|
const RE_PY_EC_KEYGEN = /\bec\.generate_private_key\s*\(|\bECC\.generate\s*\(/g;
|
|
13
13
|
// ECDSA signatures: cryptography `ec.ECDSA(`, paramiko ECDSAKey.
|
|
14
14
|
const RE_PY_ECDSA = /\bec\.ECDSA\s*\(|\bparamiko\.ECDSAKey\b|\bECDSAKey\.generate\s*\(/g;
|
|
15
|
+
// ECDH key agreement: cryptography `ec.ECDH(` — the actual harvest-now event in
|
|
16
|
+
// `private_key.exchange(ec.ECDH(), peer)`; previously missed entirely (audit F3).
|
|
17
|
+
const RE_PY_ECDH = /\bec\.ECDH\s*\(/g;
|
|
15
18
|
// DSA: PyCryptodome `DSA.generate(`, paramiko DSSKey.
|
|
16
19
|
const RE_PY_DSA = /\bDSA\.generate\s*\(|\bparamiko\.DSSKey\b|\bDSSKey\.generate\s*\(/g;
|
|
20
|
+
// hazmat DSA: cryptography `dsa.generate_private_key(` — the `cryptography` DSA
|
|
21
|
+
// keygen path (lowercase module) that RE_PY_DSA's uppercase `DSA.generate` misses
|
|
22
|
+
// (audit F9-python).
|
|
23
|
+
const RE_PY_HAZMAT_DSA = /\bdsa\.generate_private_key\s*\(/g;
|
|
17
24
|
// Finite-field Diffie-Hellman (cryptography `dh`).
|
|
18
25
|
const RE_PY_DH = /\bdh\.generate_parameters\s*\(|\bdh\.DHParameterNumbers\s*\(/g;
|
|
19
26
|
// Modern-but-classical curve primitives (cryptography). `.generate(` anchors so
|
|
@@ -21,6 +28,13 @@ const RE_PY_DH = /\bdh\.generate_parameters\s*\(|\bdh\.DHParameterNumbers\s*\(/g
|
|
|
21
28
|
const RE_PY_X25519 = /\bX25519PrivateKey\.generate\s*\(/g;
|
|
22
29
|
const RE_PY_X448 = /\bX448PrivateKey\.generate\s*\(/g;
|
|
23
30
|
const RE_PY_EDDSA = /\b(?:Ed25519|Ed448)PrivateKey\.generate\s*\(|\bparamiko\.Ed25519Key\b/g;
|
|
31
|
+
// Python TLS misconfiguration. Mirrors the JS `tlsDetector` split of source.ts:
|
|
32
|
+
// certificate-verification bypass (requests `verify=False`, `ssl.CERT_NONE`,
|
|
33
|
+
// `check_hostname=False`, `ssl._create_unverified_context(`) is the high-severity
|
|
34
|
+
// MITM surface (CWE-295); a pinned legacy protocol (`ssl.PROTOCOL_TLSv1`) is the
|
|
35
|
+
// medium-severity weak-strength surface (CWE-326).
|
|
36
|
+
const RE_PY_TLS_REJECT = /\bverify\s*=\s*False\b|\bssl\.CERT_NONE\b|\bcheck_hostname\s*=\s*False\b|\bssl\._create_unverified_context\s*\(/g;
|
|
37
|
+
const RE_PY_TLS_LEGACY = /\bPROTOCOL_TLSv1\b/g;
|
|
24
38
|
/* -------------------------------------------------------------------------- */
|
|
25
39
|
/* Rule catalog */
|
|
26
40
|
/* -------------------------------------------------------------------------- */
|
|
@@ -74,6 +88,18 @@ const RULE_PY_ECDSA = {
|
|
|
74
88
|
message: "Classical ECDSA signing (Python) is forgeable by a quantum attacker.",
|
|
75
89
|
remediation: "ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)",
|
|
76
90
|
};
|
|
91
|
+
const RULE_PY_ECDH = {
|
|
92
|
+
id: "python-ecdh",
|
|
93
|
+
title: "Python ECDH key agreement",
|
|
94
|
+
description: "cryptography ec.ECDH() exchange",
|
|
95
|
+
category: "key-exchange",
|
|
96
|
+
severity: "high",
|
|
97
|
+
confidence: "high",
|
|
98
|
+
algorithm: "ECDH",
|
|
99
|
+
hndl: true,
|
|
100
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
101
|
+
message: "Elliptic-curve Diffie-Hellman key agreement (Python) is broken by Shor's algorithm (harvest-now-decrypt-later).",
|
|
102
|
+
};
|
|
77
103
|
const RULE_PY_DSA = {
|
|
78
104
|
id: "python-dsa",
|
|
79
105
|
title: "Python DSA key/usage",
|
|
@@ -87,6 +113,19 @@ const RULE_PY_DSA = {
|
|
|
87
113
|
message: "Classical DSA (Python) is deprecated and forgeable by a quantum attacker.",
|
|
88
114
|
remediation: "Rotate off DSA and migrate to ML-DSA-65 (FIPS 204).",
|
|
89
115
|
};
|
|
116
|
+
const RULE_PY_HAZMAT_DSA = {
|
|
117
|
+
id: "python-hazmat-dsa",
|
|
118
|
+
title: "Python DSA key generation (cryptography)",
|
|
119
|
+
description: "cryptography dsa.generate_private_key",
|
|
120
|
+
category: "signature",
|
|
121
|
+
severity: "high",
|
|
122
|
+
confidence: "high",
|
|
123
|
+
algorithm: "DSA",
|
|
124
|
+
hndl: false,
|
|
125
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
126
|
+
message: "cryptography dsa.generate_private_key (Python) creates a classical DSA key; DSA is deprecated and forgeable by a quantum attacker.",
|
|
127
|
+
remediation: "Rotate off DSA and migrate to ML-DSA-65 (FIPS 204).",
|
|
128
|
+
};
|
|
90
129
|
const RULE_PY_DH = {
|
|
91
130
|
id: "python-dh",
|
|
92
131
|
title: "Python Diffie-Hellman key exchange",
|
|
@@ -104,7 +143,7 @@ const RULE_PY_X25519 = {
|
|
|
104
143
|
title: "Python X25519 key exchange",
|
|
105
144
|
description: "cryptography X25519PrivateKey.generate",
|
|
106
145
|
category: "key-exchange",
|
|
107
|
-
severity: "
|
|
146
|
+
severity: "medium",
|
|
108
147
|
confidence: "high",
|
|
109
148
|
algorithm: "X25519",
|
|
110
149
|
hndl: true,
|
|
@@ -116,7 +155,7 @@ const RULE_PY_X448 = {
|
|
|
116
155
|
title: "Python X448 key exchange",
|
|
117
156
|
description: "cryptography X448PrivateKey.generate",
|
|
118
157
|
category: "key-exchange",
|
|
119
|
-
severity: "
|
|
158
|
+
severity: "medium",
|
|
120
159
|
confidence: "high",
|
|
121
160
|
algorithm: "X448",
|
|
122
161
|
hndl: true,
|
|
@@ -135,6 +174,30 @@ const RULE_PY_EDDSA = {
|
|
|
135
174
|
cwe: CWE_BROKEN_CRYPTO,
|
|
136
175
|
message: "Ed25519/Ed448 (Python) is a modern but still classical signature scheme.",
|
|
137
176
|
};
|
|
177
|
+
const RULE_PY_TLS_REJECT = {
|
|
178
|
+
id: "python-tls-reject",
|
|
179
|
+
title: "Python TLS certificate verification disabled",
|
|
180
|
+
description: "requests verify=False / ssl.CERT_NONE / check_hostname=False / _create_unverified_context",
|
|
181
|
+
category: "tls",
|
|
182
|
+
severity: "high",
|
|
183
|
+
confidence: "high",
|
|
184
|
+
hndl: false,
|
|
185
|
+
cwe: CWE_CERT_VALIDATION,
|
|
186
|
+
message: "TLS certificate verification is disabled (verify=False / CERT_NONE / check_hostname=False / _create_unverified_context), which allows man-in-the-middle attacks.",
|
|
187
|
+
remediation: "Enable certificate verification (verify=True, ssl.CERT_REQUIRED, check_hostname=True) and verify certificates properly.",
|
|
188
|
+
};
|
|
189
|
+
const RULE_PY_TLS_LEGACY = {
|
|
190
|
+
id: "python-tls-legacy-version",
|
|
191
|
+
title: "Python legacy TLS version pinned",
|
|
192
|
+
description: "ssl.PROTOCOL_TLSv1 (TLS 1.0)",
|
|
193
|
+
category: "tls",
|
|
194
|
+
severity: "medium",
|
|
195
|
+
confidence: "high",
|
|
196
|
+
hndl: false,
|
|
197
|
+
cwe: CWE_WEAK_STRENGTH,
|
|
198
|
+
message: "TLS 1.0 (ssl.PROTOCOL_TLSv1) is deprecated and insecure; require TLS 1.3.",
|
|
199
|
+
remediation: "Use ssl.PROTOCOL_TLS_CLIENT with minimum_version = ssl.TLSVersion.TLSv1_3 and prefer PQC-hybrid key exchange.",
|
|
200
|
+
};
|
|
138
201
|
/** Detects classical asymmetric crypto in Python source. */
|
|
139
202
|
export const pythonDetector = {
|
|
140
203
|
id: "python-crypto",
|
|
@@ -146,11 +209,15 @@ export const pythonDetector = {
|
|
|
146
209
|
RULE_PY_RSA_ENCRYPT,
|
|
147
210
|
RULE_PY_EC_KEYGEN,
|
|
148
211
|
RULE_PY_ECDSA,
|
|
212
|
+
RULE_PY_ECDH,
|
|
149
213
|
RULE_PY_DSA,
|
|
214
|
+
RULE_PY_HAZMAT_DSA,
|
|
150
215
|
RULE_PY_DH,
|
|
151
216
|
RULE_PY_X25519,
|
|
152
217
|
RULE_PY_X448,
|
|
153
218
|
RULE_PY_EDDSA,
|
|
219
|
+
RULE_PY_TLS_REJECT,
|
|
220
|
+
RULE_PY_TLS_LEGACY,
|
|
154
221
|
],
|
|
155
222
|
appliesTo: (f) => hasExtension(f, PYTHON_EXTENSIONS),
|
|
156
223
|
detect({ file, content }) {
|
|
@@ -160,11 +227,15 @@ export const pythonDetector = {
|
|
|
160
227
|
add(RE_PY_RSA_ENCRYPT, RULE_PY_RSA_ENCRYPT);
|
|
161
228
|
add(RE_PY_EC_KEYGEN, RULE_PY_EC_KEYGEN);
|
|
162
229
|
add(RE_PY_ECDSA, RULE_PY_ECDSA);
|
|
230
|
+
add(RE_PY_ECDH, RULE_PY_ECDH);
|
|
163
231
|
add(RE_PY_DSA, RULE_PY_DSA);
|
|
232
|
+
add(RE_PY_HAZMAT_DSA, RULE_PY_HAZMAT_DSA);
|
|
164
233
|
add(RE_PY_DH, RULE_PY_DH);
|
|
165
234
|
add(RE_PY_X25519, RULE_PY_X25519);
|
|
166
235
|
add(RE_PY_X448, RULE_PY_X448);
|
|
167
236
|
add(RE_PY_EDDSA, RULE_PY_EDDSA);
|
|
237
|
+
add(RE_PY_TLS_REJECT, RULE_PY_TLS_REJECT);
|
|
238
|
+
add(RE_PY_TLS_LEGACY, RULE_PY_TLS_LEGACY);
|
|
168
239
|
return findings;
|
|
169
240
|
},
|
|
170
241
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../src/detectors/python.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,6EAA6E;AAC7E,oEAAoE;AACpE,MAAM,gBAAgB,GACpB,qGAAqG,CAAC;AACxG,wEAAwE;AACxE,MAAM,iBAAiB,GAAG,8CAA8C,CAAC;AACzE,yEAAyE;AACzE,MAAM,eAAe,GAAG,uDAAuD,CAAC;AAChF,iEAAiE;AACjE,MAAM,WAAW,GAAG,oEAAoE,CAAC;AACzF,sDAAsD;AACtD,MAAM,SAAS,GAAG,oEAAoE,CAAC;AACvF,mDAAmD;AACnD,MAAM,QAAQ,GAAG,+DAA+D,CAAC;AACjF,gFAAgF;AAChF,iDAAiD;AACjD,MAAM,YAAY,GAAG,oCAAoC,CAAC;AAC1D,MAAM,UAAU,GAAG,kCAAkC,CAAC;AACtD,MAAM,WAAW,GAAG,wEAAwE,CAAC;AAE7F,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,kBAAkB,GAAa;IACnC,EAAE,EAAE,mBAAmB;IACvB,KAAK,EAAE,2BAA2B;IAClC,WAAW,EACT,qFAAqF;IACvF,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,KAAK;IAChB,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,iBAAiB;I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AAC;QAC5B,GAAG,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;QAC1C,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC1B,GAAG,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QAClC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAC9B,GAAG,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAChC,GAAG,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;QAC1C,GAAG,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;QAE1C,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC","sourcesContent":["/**\n * Source-code detector for classical, non-quantum-safe asymmetric cryptography\n * in Python. Same lexical (regex-over-source) strategy as the JS/TS detectors:\n * robust to formatting, dependency-free, and confidence-tagged per pattern.\n *\n * Covers the three libraries that carry ~all real-world Python asymmetric\n * crypto:\n * - `cryptography` (hazmat): rsa/ec/dh/x25519/x448/ed25519/ed448 + OAEP padding\n * - PyCryptodome (`Crypto.PublicKey`): RSA/ECC/DSA generate + PKCS1_OAEP\n * - paramiko (SSH): RSAKey / ECDSAKey / Ed25519Key / DSSKey\n *\n * JWT/JOSE algorithm strings (`algorithm=\"RS256\"`) are NOT handled here — the\n * language-agnostic `jwt-jose` detector now applies to Python too (a quoted\n * `\"RS256\"` is the same evidence in any language).\n *\n * HNDL policy mirrors the JS detectors: key agreement / KEM (RSA-OAEP, ECDH, DH,\n * X25519/X448) is harvest-now-decrypt-later exposed (hndl:true); signatures\n * (ECDSA, DSA, Ed25519/Ed448) are hndl:false but still high/low severity because\n * a quantum attacker can forge them. EC key generation is ambiguous (an EC key\n * feeds both ECDSA and ECDH), so it is classified conservatively as\n * key-exchange-capable (hndl:true), exactly as the Node `ec` keygen rule is.\n */\nimport type { Detector, Finding, RuleMeta } from \"../types.js\";\nimport { PYTHON_EXTENSIONS, eachMatch, findingFromRule, hasExtension } from \"../detect-utils.js\";\nimport { CWE_BROKEN_CRYPTO, CWE_CERT_VALIDATION, CWE_WEAK_STRENGTH } from \"../cwe.js\";\n\n/* -------------------------------------------------------------------------- */\n/* Precompiled regexes (module scope) */\n/* -------------------------------------------------------------------------- */\n\n// RSA key generation: cryptography `rsa.generate_private_key(`, PyCryptodome\n// `RSA.generate(`, paramiko `paramiko.RSAKey` / `RSAKey.generate(`.\nconst RE_PY_RSA_KEYGEN =\n /\\brsa\\.generate_private_key\\s*\\(|\\bRSA\\.generate\\s*\\(|\\bparamiko\\.RSAKey\\b|\\bRSAKey\\.generate\\s*\\(/g;\n// RSA public-key encryption padding (RSA-OAEP): confidentiality → HNDL.\nconst RE_PY_RSA_ENCRYPT = /\\bpadding\\.OAEP\\s*\\(|\\bPKCS1_OAEP\\.new\\s*\\(/g;\n// EC key generation (ambiguous ECDSA/ECDH): cryptography + PyCryptodome.\nconst RE_PY_EC_KEYGEN = /\\bec\\.generate_private_key\\s*\\(|\\bECC\\.generate\\s*\\(/g;\n// ECDSA signatures: cryptography `ec.ECDSA(`, paramiko ECDSAKey.\nconst RE_PY_ECDSA = /\\bec\\.ECDSA\\s*\\(|\\bparamiko\\.ECDSAKey\\b|\\bECDSAKey\\.generate\\s*\\(/g;\n// ECDH key agreement: cryptography `ec.ECDH(` — the actual harvest-now event in\n// `private_key.exchange(ec.ECDH(), peer)`; previously missed entirely (audit F3).\nconst RE_PY_ECDH = /\\bec\\.ECDH\\s*\\(/g;\n// DSA: PyCryptodome `DSA.generate(`, paramiko DSSKey.\nconst RE_PY_DSA = /\\bDSA\\.generate\\s*\\(|\\bparamiko\\.DSSKey\\b|\\bDSSKey\\.generate\\s*\\(/g;\n// hazmat DSA: cryptography `dsa.generate_private_key(` — the `cryptography` DSA\n// keygen path (lowercase module) that RE_PY_DSA's uppercase `DSA.generate` misses\n// (audit F9-python).\nconst RE_PY_HAZMAT_DSA = /\\bdsa\\.generate_private_key\\s*\\(/g;\n// Finite-field Diffie-Hellman (cryptography `dh`).\nconst RE_PY_DH = /\\bdh\\.generate_parameters\\s*\\(|\\bdh\\.DHParameterNumbers\\s*\\(/g;\n// Modern-but-classical curve primitives (cryptography). `.generate(` anchors so\n// a bare import of the class name does not fire.\nconst RE_PY_X25519 = /\\bX25519PrivateKey\\.generate\\s*\\(/g;\nconst RE_PY_X448 = /\\bX448PrivateKey\\.generate\\s*\\(/g;\nconst RE_PY_EDDSA = /\\b(?:Ed25519|Ed448)PrivateKey\\.generate\\s*\\(|\\bparamiko\\.Ed25519Key\\b/g;\n\n// Python TLS misconfiguration. Mirrors the JS `tlsDetector` split of source.ts:\n// certificate-verification bypass (requests `verify=False`, `ssl.CERT_NONE`,\n// `check_hostname=False`, `ssl._create_unverified_context(`) is the high-severity\n// MITM surface (CWE-295); a pinned legacy protocol (`ssl.PROTOCOL_TLSv1`) is the\n// medium-severity weak-strength surface (CWE-326).\nconst RE_PY_TLS_REJECT =\n /\\bverify\\s*=\\s*False\\b|\\bssl\\.CERT_NONE\\b|\\bcheck_hostname\\s*=\\s*False\\b|\\bssl\\._create_unverified_context\\s*\\(/g;\nconst RE_PY_TLS_LEGACY = /\\bPROTOCOL_TLSv1\\b/g;\n\n/* -------------------------------------------------------------------------- */\n/* Rule catalog */\n/* -------------------------------------------------------------------------- */\n\nconst RULE_PY_RSA_KEYGEN: RuleMeta = {\n id: \"python-rsa-keygen\",\n title: \"Python RSA key generation\",\n description:\n \"cryptography rsa.generate_private_key / PyCryptodome RSA.generate / paramiko RSAKey\",\n category: \"kem\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"Generates a classical RSA key pair (Python), which is not quantum-safe.\",\n};\nconst RULE_PY_RSA_ENCRYPT: RuleMeta = {\n id: \"python-rsa-encrypt\",\n title: \"Python RSA public-key encryption\",\n description: \"RSA-OAEP / PKCS1_OAEP encryption padding\",\n category: \"kem\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"RSA public-key encryption (OAEP) is broken by Shor's algorithm and exposed to harvest-now-decrypt-later.\",\n};\nconst RULE_PY_EC_KEYGEN: RuleMeta = {\n id: \"python-ec-keygen\",\n title: \"Python EC key generation\",\n description: \"cryptography ec.generate_private_key / PyCryptodome ECC.generate\",\n category: \"key-exchange\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"ECDH\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Generates a classical EC key pair (Python). EC keys feed BOTH ECDSA signatures and ECDH key agreement; the ECDH path is harvest-now-decrypt-later exposed.\",\n remediation:\n \"For key agreement: hybrid X25519MLKEM768 (ML-KEM-768). For signatures: ML-DSA-65 (FIPS 204).\",\n};\nconst RULE_PY_ECDSA: RuleMeta = {\n id: \"python-ecdsa\",\n title: \"Python ECDSA signature\",\n description: \"cryptography ec.ECDSA / paramiko ECDSAKey\",\n category: \"signature\",\n severity: \"high\",\n confidence: \"medium\",\n algorithm: \"ECDSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"Classical ECDSA signing (Python) is forgeable by a quantum attacker.\",\n remediation: \"ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)\",\n};\nconst RULE_PY_ECDH: RuleMeta = {\n id: \"python-ecdh\",\n title: \"Python ECDH key agreement\",\n description: \"cryptography ec.ECDH() exchange\",\n category: \"key-exchange\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"ECDH\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Elliptic-curve Diffie-Hellman key agreement (Python) is broken by Shor's algorithm (harvest-now-decrypt-later).\",\n};\nconst RULE_PY_DSA: RuleMeta = {\n id: \"python-dsa\",\n title: \"Python DSA key/usage\",\n description: \"PyCryptodome DSA.generate / paramiko DSSKey\",\n category: \"signature\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"DSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"Classical DSA (Python) is deprecated and forgeable by a quantum attacker.\",\n remediation: \"Rotate off DSA and migrate to ML-DSA-65 (FIPS 204).\",\n};\nconst RULE_PY_HAZMAT_DSA: RuleMeta = {\n id: \"python-hazmat-dsa\",\n title: \"Python DSA key generation (cryptography)\",\n description: \"cryptography dsa.generate_private_key\",\n category: \"signature\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"DSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"cryptography dsa.generate_private_key (Python) creates a classical DSA key; DSA is deprecated and forgeable by a quantum attacker.\",\n remediation: \"Rotate off DSA and migrate to ML-DSA-65 (FIPS 204).\",\n};\nconst RULE_PY_DH: RuleMeta = {\n id: \"python-dh\",\n title: \"Python Diffie-Hellman key exchange\",\n description: \"cryptography dh.generate_parameters / DHParameterNumbers\",\n category: \"key-exchange\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"DH\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Finite-field Diffie-Hellman (Python) is broken by Shor's algorithm (harvest-now-decrypt-later).\",\n};\nconst RULE_PY_X25519: RuleMeta = {\n id: \"python-x25519\",\n title: \"Python X25519 key exchange\",\n description: \"cryptography X25519PrivateKey.generate\",\n category: \"key-exchange\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"X25519\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"X25519 (Python) is modern but still classical key agreement — harvest-now-decrypt-later.\",\n};\nconst RULE_PY_X448: RuleMeta = {\n id: \"python-x448\",\n title: \"Python X448 key exchange\",\n description: \"cryptography X448PrivateKey.generate\",\n category: \"key-exchange\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"X448\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"X448 (Python) is modern but still classical key agreement — harvest-now-decrypt-later.\",\n};\nconst RULE_PY_EDDSA: RuleMeta = {\n id: \"python-eddsa\",\n title: \"Python Ed25519/Ed448 signature\",\n description: \"cryptography Ed25519/Ed448 PrivateKey.generate / paramiko Ed25519Key\",\n category: \"signature\",\n severity: \"low\",\n confidence: \"high\",\n algorithm: \"EdDSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"Ed25519/Ed448 (Python) is a modern but still classical signature scheme.\",\n};\nconst RULE_PY_TLS_REJECT: RuleMeta = {\n id: \"python-tls-reject\",\n title: \"Python TLS certificate verification disabled\",\n description:\n \"requests verify=False / ssl.CERT_NONE / check_hostname=False / _create_unverified_context\",\n category: \"tls\",\n severity: \"high\",\n confidence: \"high\",\n hndl: false,\n cwe: CWE_CERT_VALIDATION,\n message:\n \"TLS certificate verification is disabled (verify=False / CERT_NONE / check_hostname=False / _create_unverified_context), which allows man-in-the-middle attacks.\",\n remediation:\n \"Enable certificate verification (verify=True, ssl.CERT_REQUIRED, check_hostname=True) and verify certificates properly.\",\n};\nconst RULE_PY_TLS_LEGACY: RuleMeta = {\n id: \"python-tls-legacy-version\",\n title: \"Python legacy TLS version pinned\",\n description: \"ssl.PROTOCOL_TLSv1 (TLS 1.0)\",\n category: \"tls\",\n severity: \"medium\",\n confidence: \"high\",\n hndl: false,\n cwe: CWE_WEAK_STRENGTH,\n message: \"TLS 1.0 (ssl.PROTOCOL_TLSv1) is deprecated and insecure; require TLS 1.3.\",\n remediation:\n \"Use ssl.PROTOCOL_TLS_CLIENT with minimum_version = ssl.TLSVersion.TLSv1_3 and prefer PQC-hybrid key exchange.\",\n};\n\n/** Detects classical asymmetric crypto in Python source. */\nexport const pythonDetector: Detector = {\n id: \"python-crypto\",\n description: \"Classical asymmetric crypto in Python (cryptography, PyCryptodome, paramiko)\",\n scope: \"source\",\n language: \"python\",\n rules: [\n RULE_PY_RSA_KEYGEN,\n RULE_PY_RSA_ENCRYPT,\n RULE_PY_EC_KEYGEN,\n RULE_PY_ECDSA,\n RULE_PY_ECDH,\n RULE_PY_DSA,\n RULE_PY_HAZMAT_DSA,\n RULE_PY_DH,\n RULE_PY_X25519,\n RULE_PY_X448,\n RULE_PY_EDDSA,\n RULE_PY_TLS_REJECT,\n RULE_PY_TLS_LEGACY,\n ],\n appliesTo: (f) => hasExtension(f, PYTHON_EXTENSIONS),\n detect({ file, content }): Finding[] {\n const findings: Finding[] = [];\n const add = (re: RegExp, rule: RuleMeta) =>\n eachMatch(re, content, (m) =>\n findings.push(\n findingFromRule(rule, { file, content, index: m.index, matchLength: m[0].length }),\n ),\n );\n\n add(RE_PY_RSA_KEYGEN, RULE_PY_RSA_KEYGEN);\n add(RE_PY_RSA_ENCRYPT, RULE_PY_RSA_ENCRYPT);\n add(RE_PY_EC_KEYGEN, RULE_PY_EC_KEYGEN);\n add(RE_PY_ECDSA, RULE_PY_ECDSA);\n add(RE_PY_ECDH, RULE_PY_ECDH);\n add(RE_PY_DSA, RULE_PY_DSA);\n add(RE_PY_HAZMAT_DSA, RULE_PY_HAZMAT_DSA);\n add(RE_PY_DH, RULE_PY_DH);\n add(RE_PY_X25519, RULE_PY_X25519);\n add(RE_PY_X448, RULE_PY_X448);\n add(RE_PY_EDDSA, RULE_PY_EDDSA);\n add(RE_PY_TLS_REJECT, RULE_PY_TLS_REJECT);\n add(RE_PY_TLS_LEGACY, RULE_PY_TLS_LEGACY);\n\n return findings;\n },\n};\n"]}
|
package/dist/detectors/ruby.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Source-code detector for classical asymmetric cryptography in Ruby. Ruby's
|
|
3
3
|
* asymmetric crypto is almost entirely `OpenSSL::PKey::{RSA,EC,DSA,DH}`, which
|
|
4
|
-
* makes the signals precise. Lexical, same strategy as the other packs.
|
|
4
|
+
* makes the signals precise. Lexical, same strategy as the other packs. Beyond
|
|
5
|
+
* keygen it also covers RSA public-key encryption on a loaded key, DH key
|
|
6
|
+
* agreement, the type-agnostic `OpenSSL::PKey.read` loader, Ed25519 key
|
|
7
|
+
* generation, and disabled TLS peer verification (`VERIFY_NONE`).
|
|
5
8
|
*
|
|
6
9
|
* HNDL: RSA (keygen/encryption) and (EC)DH key agreement are harvest-now-
|
|
7
|
-
* decrypt-later exposed (hndl:true); DSA signatures are hndl:false but
|
|
8
|
-
* `OpenSSL::PKey::EC` is ambiguous (feeds ECDSA + ECDH), so it is
|
|
9
|
-
* conservatively as key-exchange-capable (hndl:true), like the other
|
|
10
|
-
* rules.
|
|
10
|
+
* decrypt-later exposed (hndl:true); DSA / Ed25519 signatures are hndl:false but
|
|
11
|
+
* forgeable. `OpenSSL::PKey::EC` is ambiguous (feeds ECDSA + ECDH), so it is
|
|
12
|
+
* classified conservatively as key-exchange-capable (hndl:true), like the other
|
|
13
|
+
* EC keygen rules; `OpenSSL::PKey.read` loads a key of unknown type and is
|
|
14
|
+
* likewise treated conservatively.
|
|
11
15
|
*/
|
|
12
16
|
import type { Detector } from "../types.js";
|
|
13
17
|
/** Detects classical asymmetric crypto in Ruby (OpenSSL::PKey). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruby.d.ts","sourceRoot":"","sources":["../../src/detectors/ruby.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ruby.d.ts","sourceRoot":"","sources":["../../src/detectors/ruby.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AA2K/D,mEAAmE;AACnE,eAAO,MAAM,YAAY,EAAE,QAwC1B,CAAC"}
|
package/dist/detectors/ruby.js
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { RUBY_EXTENSIONS, eachMatch, findingFromRule, hasExtension } from "../detect-utils.js";
|
|
2
|
-
import { CWE_BROKEN_CRYPTO } from "../cwe.js";
|
|
2
|
+
import { CWE_BROKEN_CRYPTO, CWE_CERT_VALIDATION } from "../cwe.js";
|
|
3
3
|
const RE_RB_RSA = /\bOpenSSL::PKey::RSA\.(?:new|generate)\s*\(/g;
|
|
4
4
|
const RE_RB_EC = /\bOpenSSL::PKey::EC\.(?:new|generate)\s*\(/g;
|
|
5
5
|
const RE_RB_DSA = /\bOpenSSL::PKey::DSA\.(?:new|generate)\s*\(/g;
|
|
6
6
|
const RE_RB_DH = /\bOpenSSL::PKey::DH\.new\s*\(/g;
|
|
7
|
+
// RSA public-key encryption on an already-loaded key (audit F4-ruby / F9).
|
|
8
|
+
const RE_RB_RSA_CRYPT = /\.public_encrypt\b|\.private_decrypt\b/g;
|
|
9
|
+
// Finite-field DH shared-secret agreement.
|
|
10
|
+
const RE_RB_DH_AGREE = /\bdh_compute_key\s*\(/g;
|
|
11
|
+
// Type-agnostic key loader — could be RSA/EC/DSA/DH (conservative).
|
|
12
|
+
const RE_RB_PKEY_READ = /\bOpenSSL::PKey\.read\s*\(/g;
|
|
13
|
+
// Ed25519 signing key via the generic generate_key factory.
|
|
14
|
+
const RE_RB_ED25519 = /\bOpenSSL::PKey\.generate_key\s*\(\s*["']ED25519["']/g;
|
|
15
|
+
// `ed25519` gem — Ed25519::SigningKey / VerifyKey (signature keys).
|
|
16
|
+
const RE_RB_ED25519_GEM = /\bEd25519::(?:SigningKey|VerifyKey)\b/g;
|
|
17
|
+
// `rbnacl` (libsodium) — Curve25519/X25519 key agreement: PrivateKey, Box, GroupElement.
|
|
18
|
+
const RE_RB_RBNACL = /\bRbNaCl::(?:PrivateKey|Box|GroupElement)\b/g;
|
|
19
|
+
// TLS peer verification disabled (mirrors the JS tlsDetector rejectUnauthorized rule).
|
|
20
|
+
const RE_RB_TLS_VERIFY_NONE = /\bOpenSSL::SSL::VERIFY_NONE\b/g;
|
|
7
21
|
const RULE_RB_RSA = {
|
|
8
22
|
id: "ruby-rsa",
|
|
9
23
|
title: "Ruby RSA key/usage",
|
|
@@ -54,13 +68,112 @@ const RULE_RB_DH = {
|
|
|
54
68
|
cwe: CWE_BROKEN_CRYPTO,
|
|
55
69
|
message: "Finite-field Diffie-Hellman (Ruby/OpenSSL) is broken by Shor's algorithm (harvest-now-decrypt-later).",
|
|
56
70
|
};
|
|
71
|
+
const RULE_RB_RSA_CRYPT = {
|
|
72
|
+
id: "ruby-rsa-crypt",
|
|
73
|
+
title: "Ruby RSA public-key encryption",
|
|
74
|
+
description: "OpenSSL::PKey::RSA#public_encrypt / #private_decrypt",
|
|
75
|
+
category: "kem",
|
|
76
|
+
severity: "high",
|
|
77
|
+
confidence: "high",
|
|
78
|
+
algorithm: "RSA",
|
|
79
|
+
hndl: true,
|
|
80
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
81
|
+
message: "RSA public-key encryption/decryption (Ruby/OpenSSL) is harvest-now-decrypt-later exposed.",
|
|
82
|
+
};
|
|
83
|
+
const RULE_RB_DH_AGREE = {
|
|
84
|
+
id: "ruby-dh-agree",
|
|
85
|
+
title: "Ruby Diffie-Hellman key agreement",
|
|
86
|
+
description: "OpenSSL DH compute_key shared-secret agreement",
|
|
87
|
+
category: "key-exchange",
|
|
88
|
+
severity: "high",
|
|
89
|
+
confidence: "high",
|
|
90
|
+
algorithm: "DH",
|
|
91
|
+
hndl: true,
|
|
92
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
93
|
+
message: "Finite-field Diffie-Hellman key agreement (Ruby/OpenSSL) is broken by Shor's algorithm (harvest-now-decrypt-later).",
|
|
94
|
+
};
|
|
95
|
+
const RULE_RB_PKEY_READ = {
|
|
96
|
+
id: "ruby-pkey-read",
|
|
97
|
+
title: "Ruby PKey loaded from serialized key",
|
|
98
|
+
description: "OpenSSL::PKey.read (type-agnostic key loader)",
|
|
99
|
+
category: "key-exchange",
|
|
100
|
+
severity: "high",
|
|
101
|
+
confidence: "medium",
|
|
102
|
+
algorithm: "unknown",
|
|
103
|
+
hndl: true,
|
|
104
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
105
|
+
message: "Loads a classical asymmetric key of unknown type (RSA/EC/DSA/DH) via OpenSSL::PKey.read. Treated conservatively as key-exchange-capable (harvest-now-decrypt-later).",
|
|
106
|
+
remediation: "For key agreement: hybrid X25519MLKEM768 (ML-KEM-768). For signatures: ML-DSA-65 (FIPS 204).",
|
|
107
|
+
};
|
|
108
|
+
const RULE_RB_ED25519 = {
|
|
109
|
+
id: "ruby-ed25519",
|
|
110
|
+
title: "Ruby Ed25519 key generation",
|
|
111
|
+
description: 'OpenSSL::PKey.generate_key("ED25519")',
|
|
112
|
+
category: "signature",
|
|
113
|
+
severity: "low",
|
|
114
|
+
confidence: "high",
|
|
115
|
+
algorithm: "EdDSA",
|
|
116
|
+
hndl: false,
|
|
117
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
118
|
+
message: "Generates an Ed25519 signing key (Ruby/OpenSSL) — modern but classical, and forgeable by a quantum attacker.",
|
|
119
|
+
remediation: "ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)",
|
|
120
|
+
};
|
|
121
|
+
const RULE_RB_ED25519_GEM = {
|
|
122
|
+
id: "ruby-ed25519-gem",
|
|
123
|
+
title: "Ruby Ed25519 signature (ed25519 gem)",
|
|
124
|
+
description: "ed25519 gem Ed25519::SigningKey / Ed25519::VerifyKey",
|
|
125
|
+
category: "signature",
|
|
126
|
+
severity: "low",
|
|
127
|
+
confidence: "high",
|
|
128
|
+
algorithm: "EdDSA",
|
|
129
|
+
hndl: false,
|
|
130
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
131
|
+
message: "Ed25519 signing/verification via the `ed25519` gem — modern but classical, and forgeable by a quantum attacker.",
|
|
132
|
+
remediation: "ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)",
|
|
133
|
+
};
|
|
134
|
+
const RULE_RB_RBNACL = {
|
|
135
|
+
id: "ruby-rbnacl",
|
|
136
|
+
title: "Ruby X25519 key agreement (rbnacl)",
|
|
137
|
+
description: "rbnacl (libsodium) RbNaCl::PrivateKey / Box / GroupElement",
|
|
138
|
+
category: "key-exchange",
|
|
139
|
+
severity: "medium",
|
|
140
|
+
confidence: "high",
|
|
141
|
+
algorithm: "X25519",
|
|
142
|
+
hndl: true,
|
|
143
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
144
|
+
message: "Curve25519/X25519 key agreement via the `rbnacl` gem (libsodium) — modern but classical key agreement, harvest-now-decrypt-later exposed.",
|
|
145
|
+
};
|
|
146
|
+
const RULE_RB_TLS_VERIFY_NONE = {
|
|
147
|
+
id: "ruby-tls-verify-none",
|
|
148
|
+
title: "Ruby TLS certificate verification disabled",
|
|
149
|
+
description: "OpenSSL::SSL::VERIFY_NONE",
|
|
150
|
+
category: "tls",
|
|
151
|
+
severity: "high",
|
|
152
|
+
confidence: "high",
|
|
153
|
+
hndl: false,
|
|
154
|
+
cwe: CWE_CERT_VALIDATION,
|
|
155
|
+
message: "OpenSSL::SSL::VERIFY_NONE disables TLS peer certificate verification (MITM risk).",
|
|
156
|
+
remediation: "Use OpenSSL::SSL::VERIFY_PEER and verify the certificate chain.",
|
|
157
|
+
};
|
|
57
158
|
/** Detects classical asymmetric crypto in Ruby (OpenSSL::PKey). */
|
|
58
159
|
export const rubyDetector = {
|
|
59
160
|
id: "ruby-crypto",
|
|
60
161
|
description: "Classical asymmetric crypto in Ruby (OpenSSL::PKey::{RSA,EC,DSA,DH})",
|
|
61
162
|
scope: "source",
|
|
62
163
|
language: "ruby",
|
|
63
|
-
rules: [
|
|
164
|
+
rules: [
|
|
165
|
+
RULE_RB_RSA,
|
|
166
|
+
RULE_RB_EC,
|
|
167
|
+
RULE_RB_DSA,
|
|
168
|
+
RULE_RB_DH,
|
|
169
|
+
RULE_RB_RSA_CRYPT,
|
|
170
|
+
RULE_RB_DH_AGREE,
|
|
171
|
+
RULE_RB_PKEY_READ,
|
|
172
|
+
RULE_RB_ED25519,
|
|
173
|
+
RULE_RB_ED25519_GEM,
|
|
174
|
+
RULE_RB_RBNACL,
|
|
175
|
+
RULE_RB_TLS_VERIFY_NONE,
|
|
176
|
+
],
|
|
64
177
|
appliesTo: (f) => hasExtension(f, RUBY_EXTENSIONS),
|
|
65
178
|
detect({ file, content }) {
|
|
66
179
|
const findings = [];
|
|
@@ -69,6 +182,13 @@ export const rubyDetector = {
|
|
|
69
182
|
add(RE_RB_EC, RULE_RB_EC);
|
|
70
183
|
add(RE_RB_DSA, RULE_RB_DSA);
|
|
71
184
|
add(RE_RB_DH, RULE_RB_DH);
|
|
185
|
+
add(RE_RB_RSA_CRYPT, RULE_RB_RSA_CRYPT);
|
|
186
|
+
add(RE_RB_DH_AGREE, RULE_RB_DH_AGREE);
|
|
187
|
+
add(RE_RB_PKEY_READ, RULE_RB_PKEY_READ);
|
|
188
|
+
add(RE_RB_ED25519, RULE_RB_ED25519);
|
|
189
|
+
add(RE_RB_ED25519_GEM, RULE_RB_ED25519_GEM);
|
|
190
|
+
add(RE_RB_RBNACL, RULE_RB_RBNACL);
|
|
191
|
+
add(RE_RB_TLS_VERIFY_NONE, RULE_RB_TLS_VERIFY_NONE);
|
|
72
192
|
return findings;
|
|
73
193
|
},
|
|
74
194
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruby.js","sourceRoot":"","sources":["../../src/detectors/ruby.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,SAAS,GAAG,8CAA8C,CAAC;AACjE,MAAM,QAAQ,GAAG,6CAA6C,CAAC;AAC/D,MAAM,SAAS,GAAG,8CAA8C,CAAC;AACjE,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AAElD,MAAM,WAAW,GAAa;IAC5B,EAAE,EAAE,UAAU;IACd,KAAK,EAAE,oBAAoB;IAC3B,WAAW,EAAE,oCAAoC;IACjD,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,KAAK;IAChB,IAAI,EAAE,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AAC;QACpD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC","sourcesContent":["/**\n * Source-code detector for classical asymmetric cryptography in Ruby. Ruby's\n * asymmetric crypto is almost entirely `OpenSSL::PKey::{RSA,EC,DSA,DH}`, which\n * makes the signals precise. Lexical, same strategy as the other packs. Beyond\n * keygen it also covers RSA public-key encryption on a loaded key, DH key\n * agreement, the type-agnostic `OpenSSL::PKey.read` loader, Ed25519 key\n * generation, and disabled TLS peer verification (`VERIFY_NONE`).\n *\n * HNDL: RSA (keygen/encryption) and (EC)DH key agreement are harvest-now-\n * decrypt-later exposed (hndl:true); DSA / Ed25519 signatures are hndl:false but\n * forgeable. `OpenSSL::PKey::EC` is ambiguous (feeds ECDSA + ECDH), so it is\n * classified conservatively as key-exchange-capable (hndl:true), like the other\n * EC keygen rules; `OpenSSL::PKey.read` loads a key of unknown type and is\n * likewise treated conservatively.\n */\nimport type { Detector, Finding, RuleMeta } from \"../types.js\";\nimport { RUBY_EXTENSIONS, eachMatch, findingFromRule, hasExtension } from \"../detect-utils.js\";\nimport { CWE_BROKEN_CRYPTO, CWE_CERT_VALIDATION } from \"../cwe.js\";\n\nconst RE_RB_RSA = /\\bOpenSSL::PKey::RSA\\.(?:new|generate)\\s*\\(/g;\nconst RE_RB_EC = /\\bOpenSSL::PKey::EC\\.(?:new|generate)\\s*\\(/g;\nconst RE_RB_DSA = /\\bOpenSSL::PKey::DSA\\.(?:new|generate)\\s*\\(/g;\nconst RE_RB_DH = /\\bOpenSSL::PKey::DH\\.new\\s*\\(/g;\n// RSA public-key encryption on an already-loaded key (audit F4-ruby / F9).\nconst RE_RB_RSA_CRYPT = /\\.public_encrypt\\b|\\.private_decrypt\\b/g;\n// Finite-field DH shared-secret agreement.\nconst RE_RB_DH_AGREE = /\\bdh_compute_key\\s*\\(/g;\n// Type-agnostic key loader — could be RSA/EC/DSA/DH (conservative).\nconst RE_RB_PKEY_READ = /\\bOpenSSL::PKey\\.read\\s*\\(/g;\n// Ed25519 signing key via the generic generate_key factory.\nconst RE_RB_ED25519 = /\\bOpenSSL::PKey\\.generate_key\\s*\\(\\s*[\"']ED25519[\"']/g;\n// `ed25519` gem — Ed25519::SigningKey / VerifyKey (signature keys).\nconst RE_RB_ED25519_GEM = /\\bEd25519::(?:SigningKey|VerifyKey)\\b/g;\n// `rbnacl` (libsodium) — Curve25519/X25519 key agreement: PrivateKey, Box, GroupElement.\nconst RE_RB_RBNACL = /\\bRbNaCl::(?:PrivateKey|Box|GroupElement)\\b/g;\n// TLS peer verification disabled (mirrors the JS tlsDetector rejectUnauthorized rule).\nconst RE_RB_TLS_VERIFY_NONE = /\\bOpenSSL::SSL::VERIFY_NONE\\b/g;\n\nconst RULE_RB_RSA: RuleMeta = {\n id: \"ruby-rsa\",\n title: \"Ruby RSA key/usage\",\n description: \"OpenSSL::PKey::RSA.new / .generate\",\n category: \"kem\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"Classical RSA (Ruby/OpenSSL) is not quantum-safe and RSA encryption is HNDL-exposed.\",\n};\nconst RULE_RB_EC: RuleMeta = {\n id: \"ruby-ec\",\n title: \"Ruby EC key generation\",\n description: \"OpenSSL::PKey::EC.new / .generate\",\n category: \"key-exchange\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"ECDH\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Generates a classical EC key pair (Ruby/OpenSSL). EC keys feed BOTH ECDSA signatures and ECDH key agreement; the ECDH path is harvest-now-decrypt-later exposed.\",\n remediation:\n \"For key agreement: hybrid X25519MLKEM768 (ML-KEM-768). For signatures: ML-DSA-65 (FIPS 204).\",\n};\nconst RULE_RB_DSA: RuleMeta = {\n id: \"ruby-dsa\",\n title: \"Ruby DSA key/signature\",\n description: \"OpenSSL::PKey::DSA.new / .generate\",\n category: \"signature\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"DSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"Classical DSA (Ruby/OpenSSL) is deprecated and forgeable by a quantum attacker.\",\n remediation: \"Rotate off DSA and migrate to ML-DSA-65 (FIPS 204).\",\n};\nconst RULE_RB_DH: RuleMeta = {\n id: \"ruby-dh\",\n title: \"Ruby Diffie-Hellman key exchange\",\n description: \"OpenSSL::PKey::DH.new\",\n category: \"key-exchange\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"DH\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Finite-field Diffie-Hellman (Ruby/OpenSSL) is broken by Shor's algorithm (harvest-now-decrypt-later).\",\n};\nconst RULE_RB_RSA_CRYPT: RuleMeta = {\n id: \"ruby-rsa-crypt\",\n title: \"Ruby RSA public-key encryption\",\n description: \"OpenSSL::PKey::RSA#public_encrypt / #private_decrypt\",\n category: \"kem\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"RSA public-key encryption/decryption (Ruby/OpenSSL) is harvest-now-decrypt-later exposed.\",\n};\nconst RULE_RB_DH_AGREE: RuleMeta = {\n id: \"ruby-dh-agree\",\n title: \"Ruby Diffie-Hellman key agreement\",\n description: \"OpenSSL DH compute_key shared-secret agreement\",\n category: \"key-exchange\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"DH\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Finite-field Diffie-Hellman key agreement (Ruby/OpenSSL) is broken by Shor's algorithm (harvest-now-decrypt-later).\",\n};\nconst RULE_RB_PKEY_READ: RuleMeta = {\n id: \"ruby-pkey-read\",\n title: \"Ruby PKey loaded from serialized key\",\n description: \"OpenSSL::PKey.read (type-agnostic key loader)\",\n category: \"key-exchange\",\n severity: \"high\",\n confidence: \"medium\",\n algorithm: \"unknown\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Loads a classical asymmetric key of unknown type (RSA/EC/DSA/DH) via OpenSSL::PKey.read. Treated conservatively as key-exchange-capable (harvest-now-decrypt-later).\",\n remediation:\n \"For key agreement: hybrid X25519MLKEM768 (ML-KEM-768). For signatures: ML-DSA-65 (FIPS 204).\",\n};\nconst RULE_RB_ED25519: RuleMeta = {\n id: \"ruby-ed25519\",\n title: \"Ruby Ed25519 key generation\",\n description: 'OpenSSL::PKey.generate_key(\"ED25519\")',\n category: \"signature\",\n severity: \"low\",\n confidence: \"high\",\n algorithm: \"EdDSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Generates an Ed25519 signing key (Ruby/OpenSSL) — modern but classical, and forgeable by a quantum attacker.\",\n remediation: \"ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)\",\n};\nconst RULE_RB_ED25519_GEM: RuleMeta = {\n id: \"ruby-ed25519-gem\",\n title: \"Ruby Ed25519 signature (ed25519 gem)\",\n description: \"ed25519 gem Ed25519::SigningKey / Ed25519::VerifyKey\",\n category: \"signature\",\n severity: \"low\",\n confidence: \"high\",\n algorithm: \"EdDSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Ed25519 signing/verification via the `ed25519` gem — modern but classical, and forgeable by a quantum attacker.\",\n remediation: \"ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)\",\n};\nconst RULE_RB_RBNACL: RuleMeta = {\n id: \"ruby-rbnacl\",\n title: \"Ruby X25519 key agreement (rbnacl)\",\n description: \"rbnacl (libsodium) RbNaCl::PrivateKey / Box / GroupElement\",\n category: \"key-exchange\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"X25519\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Curve25519/X25519 key agreement via the `rbnacl` gem (libsodium) — modern but classical key agreement, harvest-now-decrypt-later exposed.\",\n};\nconst RULE_RB_TLS_VERIFY_NONE: RuleMeta = {\n id: \"ruby-tls-verify-none\",\n title: \"Ruby TLS certificate verification disabled\",\n description: \"OpenSSL::SSL::VERIFY_NONE\",\n category: \"tls\",\n severity: \"high\",\n confidence: \"high\",\n hndl: false,\n cwe: CWE_CERT_VALIDATION,\n message: \"OpenSSL::SSL::VERIFY_NONE disables TLS peer certificate verification (MITM risk).\",\n remediation: \"Use OpenSSL::SSL::VERIFY_PEER and verify the certificate chain.\",\n};\n\n/** Detects classical asymmetric crypto in Ruby (OpenSSL::PKey). */\nexport const rubyDetector: Detector = {\n id: \"ruby-crypto\",\n description: \"Classical asymmetric crypto in Ruby (OpenSSL::PKey::{RSA,EC,DSA,DH})\",\n scope: \"source\",\n language: \"ruby\",\n rules: [\n RULE_RB_RSA,\n RULE_RB_EC,\n RULE_RB_DSA,\n RULE_RB_DH,\n RULE_RB_RSA_CRYPT,\n RULE_RB_DH_AGREE,\n RULE_RB_PKEY_READ,\n RULE_RB_ED25519,\n RULE_RB_ED25519_GEM,\n RULE_RB_RBNACL,\n RULE_RB_TLS_VERIFY_NONE,\n ],\n appliesTo: (f) => hasExtension(f, RUBY_EXTENSIONS),\n detect({ file, content }): Finding[] {\n const findings: Finding[] = [];\n const add = (re: RegExp, rule: RuleMeta) =>\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_RB_RSA, RULE_RB_RSA);\n add(RE_RB_EC, RULE_RB_EC);\n add(RE_RB_DSA, RULE_RB_DSA);\n add(RE_RB_DH, RULE_RB_DH);\n add(RE_RB_RSA_CRYPT, RULE_RB_RSA_CRYPT);\n add(RE_RB_DH_AGREE, RULE_RB_DH_AGREE);\n add(RE_RB_PKEY_READ, RULE_RB_PKEY_READ);\n add(RE_RB_ED25519, RULE_RB_ED25519);\n add(RE_RB_ED25519_GEM, RULE_RB_ED25519_GEM);\n add(RE_RB_RBNACL, RULE_RB_RBNACL);\n add(RE_RB_TLS_VERIFY_NONE, RULE_RB_TLS_VERIFY_NONE);\n return findings;\n },\n};\n"]}
|
package/dist/detectors/rust.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Source-code detector for classical asymmetric cryptography in Rust. Covers the
|
|
3
3
|
* common crypto crates: `rsa`, `ring`, the `*-dalek` family (ed25519/x25519),
|
|
4
|
-
*
|
|
5
|
-
* strategy as the other packs; the `::` path
|
|
4
|
+
* the RustCrypto elliptic-curve crates (`p256`/`p384`/`k256`), and the `openssl`
|
|
5
|
+
* crate bindings. Lexical, same strategy as the other packs; the `::` path
|
|
6
|
+
* syntax makes the signals precise.
|
|
6
7
|
*
|
|
7
8
|
* HNDL: RSA encryption and (EC/X)DH key agreement are harvest-now-decrypt-later
|
|
8
|
-
* exposed (hndl:true); ECDSA / Ed25519 signatures are hndl:false but
|
|
9
|
+
* exposed (hndl:true); ECDSA / DSA / Ed25519 signatures are hndl:false but
|
|
10
|
+
* forgeable. `openssl::EcKey` keygen is ambiguous (feeds ECDSA + ECDH),
|
|
11
|
+
* classified conservatively as key-exchange-capable (hndl:true). Also flags
|
|
12
|
+
* Rust TLS certificate-validation bypasses (reqwest / rustls) — not quantum but
|
|
13
|
+
* mirrors the JS tlsDetector's cert-validation category.
|
|
9
14
|
*/
|
|
10
15
|
import type { Detector } from "../types.js";
|
|
11
16
|
/** Detects classical asymmetric crypto in Rust (rsa, ring, dalek, p256/k256). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rust.d.ts","sourceRoot":"","sources":["../../src/detectors/rust.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rust.d.ts","sourceRoot":"","sources":["../../src/detectors/rust.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAmB,QAAQ,EAAqB,MAAM,aAAa,CAAC;AA+OhF,iFAAiF;AACjF,eAAO,MAAM,YAAY,EAAE,QA6D1B,CAAC"}
|