@quantakrypto/core 0.4.2 → 0.4.4
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-merge.d.ts +9 -0
- package/dist/cbom-merge.d.ts.map +1 -0
- package/dist/cbom-merge.js +99 -0
- package/dist/cbom-merge.js.map +1 -0
- 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 +29 -2
- package/dist/comments.d.ts.map +1 -1
- package/dist/comments.js +178 -18
- 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 +19 -4
- package/dist/detect-utils.d.ts.map +1 -1
- package/dist/detect-utils.js +43 -6
- package/dist/detect-utils.js.map +1 -1
- package/dist/detectors/c.d.ts +4 -2
- package/dist/detectors/c.d.ts.map +1 -1
- package/dist/detectors/c.js +382 -3
- package/dist/detectors/c.js.map +1 -1
- package/dist/detectors/cicd.d.ts +27 -0
- package/dist/detectors/cicd.d.ts.map +1 -0
- package/dist/detectors/cicd.js +116 -0
- package/dist/detectors/cicd.js.map +1 -0
- package/dist/detectors/cloud-kms.d.ts +21 -0
- package/dist/detectors/cloud-kms.d.ts.map +1 -0
- package/dist/detectors/cloud-kms.js +57 -0
- package/dist/detectors/cloud-kms.js.map +1 -0
- package/dist/detectors/cloudformation.d.ts +30 -0
- package/dist/detectors/cloudformation.d.ts.map +1 -0
- package/dist/detectors/cloudformation.js +170 -0
- package/dist/detectors/cloudformation.js.map +1 -0
- 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/database.d.ts +17 -0
- package/dist/detectors/database.d.ts.map +1 -0
- package/dist/detectors/database.js +60 -0
- package/dist/detectors/database.js.map +1 -0
- package/dist/detectors/dnssec.d.ts +55 -0
- package/dist/detectors/dnssec.d.ts.map +1 -0
- package/dist/detectors/dnssec.js +107 -0
- package/dist/detectors/dnssec.js.map +1 -0
- package/dist/detectors/elixir.d.ts +20 -0
- package/dist/detectors/elixir.d.ts.map +1 -0
- package/dist/detectors/elixir.js +195 -0
- package/dist/detectors/elixir.js.map +1 -0
- 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 +169 -4
- package/dist/detectors/java.js.map +1 -1
- package/dist/detectors/jose.d.ts +20 -0
- package/dist/detectors/jose.d.ts.map +1 -0
- package/dist/detectors/jose.js +62 -0
- package/dist/detectors/jose.js.map +1 -0
- package/dist/detectors/jwk.d.ts +25 -0
- package/dist/detectors/jwk.d.ts.map +1 -0
- package/dist/detectors/jwk.js +95 -0
- package/dist/detectors/jwk.js.map +1 -0
- package/dist/detectors/k8s.d.ts +17 -0
- package/dist/detectors/k8s.d.ts.map +1 -0
- package/dist/detectors/k8s.js +85 -0
- package/dist/detectors/k8s.js.map +1 -0
- package/dist/detectors/mesh.d.ts +35 -0
- package/dist/detectors/mesh.d.ts.map +1 -0
- package/dist/detectors/mesh.js +109 -0
- package/dist/detectors/mesh.js.map +1 -0
- package/dist/detectors/messaging.d.ts +16 -0
- package/dist/detectors/messaging.d.ts.map +1 -0
- package/dist/detectors/messaging.js +72 -0
- package/dist/detectors/messaging.js.map +1 -0
- package/dist/detectors/pem.d.ts.map +1 -1
- package/dist/detectors/pem.js +50 -2
- package/dist/detectors/pem.js.map +1 -1
- package/dist/detectors/php.d.ts +24 -0
- package/dist/detectors/php.d.ts.map +1 -0
- package/dist/detectors/php.js +167 -0
- package/dist/detectors/php.js.map +1 -0
- package/dist/detectors/python.d.ts.map +1 -1
- package/dist/detectors/python.js +144 -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 +253 -3
- package/dist/detectors/rust.js.map +1 -1
- package/dist/detectors/secrets.d.ts +21 -0
- package/dist/detectors/secrets.d.ts.map +1 -0
- package/dist/detectors/secrets.js +79 -0
- package/dist/detectors/secrets.js.map +1 -0
- package/dist/detectors/source.d.ts.map +1 -1
- package/dist/detectors/source.js +305 -52
- 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 +142 -0
- package/dist/detectors/stateful-hbs.js.map +1 -0
- package/dist/detectors/terraform.d.ts +21 -0
- package/dist/detectors/terraform.d.ts.map +1 -0
- package/dist/detectors/terraform.js +123 -0
- package/dist/detectors/terraform.js.map +1 -0
- package/dist/detectors/vpn.d.ts +22 -0
- package/dist/detectors/vpn.d.ts.map +1 -0
- package/dist/detectors/vpn.js +99 -0
- package/dist/detectors/vpn.js.map +1 -0
- package/dist/errors.js.map +1 -1
- package/dist/evidence.d.ts +53 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +81 -0
- package/dist/evidence.js.map +1 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -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/policy.d.ts +67 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +115 -0
- package/dist/policy.js.map +1 -0
- 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 +34 -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 +71 -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 +38 -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/standards.d.ts +96 -0
- package/dist/standards.d.ts.map +1 -0
- package/dist/standards.js +107 -0
- package/dist/standards.js.map +1 -0
- package/dist/triage.js.map +1 -1
- package/dist/types.d.ts +2 -2
- 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/cbom-merge.ts +116 -0
- package/src/comments.ts +183 -18
- package/src/dependencies.ts +144 -4
- package/src/detect-utils.ts +47 -6
- package/src/detectors/c.ts +411 -5
- package/src/detectors/cicd.ts +158 -0
- package/src/detectors/cloud-kms.ts +87 -0
- package/src/detectors/cloudformation.ts +215 -0
- package/src/detectors/csharp.ts +154 -3
- package/src/detectors/database.ts +88 -0
- package/src/detectors/dnssec.ts +186 -0
- package/src/detectors/elixir.ts +237 -0
- package/src/detectors/go.ts +209 -6
- package/src/detectors/java.ts +191 -4
- package/src/detectors/jose.ts +94 -0
- package/src/detectors/jwk.ts +128 -0
- package/src/detectors/k8s.ts +112 -0
- package/src/detectors/mesh.ts +154 -0
- package/src/detectors/messaging.ts +98 -0
- package/src/detectors/pem.ts +54 -2
- package/src/detectors/php.ts +225 -0
- package/src/detectors/python.ts +153 -3
- package/src/detectors/ruby.ts +138 -7
- package/src/detectors/rust.ts +282 -7
- package/src/detectors/secrets.ts +114 -0
- package/src/detectors/source.ts +382 -72
- package/src/detectors/stateful-hbs.ts +180 -0
- package/src/detectors/terraform.ts +154 -0
- package/src/detectors/vpn.ts +131 -0
- package/src/evidence.ts +135 -0
- package/src/index.ts +15 -1
- package/src/inventory.ts +31 -1
- package/src/policy.ts +180 -0
- package/src/redact.ts +41 -0
- package/src/registry.ts +34 -2
- package/src/remediate-pipeline.ts +78 -0
- package/src/remediation.ts +23 -8
- package/src/report.ts +48 -2
- package/src/scan.ts +13 -1
- package/src/standards.ts +186 -0
- package/src/types.ts +3 -1
- package/src/version.ts +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cicd.js","sourceRoot":"","sources":["../../src/detectors/cicd.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,2EAA2E;AAC3E,SAAS,gBAAgB,CAAC,QAAgB;IACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,KAAK,CAAC;IAC7C,OAAO,CACL,CAAC,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EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAClC,SAAS,EAAE,gBAAgB;IAC3B,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;QACtB,MAAM,QAAQ,GAAc,EAAE,CAAC;QAC/B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC5B,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;gBAChC,QAAQ,CAAC,IAAI,CACX,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CACxF,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC","sourcesContent":["/**\n * Config detector: classical signing of build artifacts and code in CI/CD\n * pipelines (GitHub Actions, GitLab CI, Jenkins, Azure Pipelines, CircleCI).\n *\n * Artifact and code signatures are the signature-side analogue of \"harvest now,\n * decrypt later\": a release signed today with a classical key is *forgeable* once\n * a CRQC exists, and long-lived artifacts (container images, released binaries,\n * SBOM attestations) keep verifying against that classical public key for years.\n * So these are flagged `hndl:false` (a signature is not confidentiality — nothing\n * to harvest) but remain real quantum-migration debt.\n *\n * Covered command invocations (distinctive enough inside a CI file that the\n * false-positive risk is low):\n * - `cosign sign|attest|generate-key-pair` → sigstore/cosign uses ECDSA P-256\n * (both key-based and keyless/Fulcio).\n * - `gpg --detach-sign|--clearsign|--sign` → GnuPG, classically RSA.\n * - `jarsigner` → Java JAR signing (RSA/DSA/EC).\n * - `codesign --sign|-s` → Apple code signing (RSA).\n * - `minisign` → Ed25519 signatures.\n *\n * Gated to CI/CD pipeline files so `gpg`/`cosign` mentioned in a shell script or\n * doc does not fire; the surface here is specifically the release pipeline.\n */\nimport type { Detector, Finding, RuleMeta } from \"../types.js\";\nimport { eachMatch, findingFromRule } from \"../detect-utils.js\";\nimport { CWE_BROKEN_CRYPTO } from \"../cwe.js\";\n\n/** True for the CI/CD pipeline definition files this detector inspects. */\nfunction isCiPipelineFile(filePath: string): boolean {\n const lower = filePath.toLowerCase();\n const base = lower.split(\"/\").pop() ?? lower;\n return (\n (lower.includes(\".github/workflows/\") && (lower.endsWith(\".yml\") || lower.endsWith(\".yaml\"))) ||\n base === \".gitlab-ci.yml\" ||\n lower.endsWith(\".gitlab-ci.yml\") ||\n base === \"jenkinsfile\" ||\n lower.endsWith(\".jenkinsfile\") ||\n base === \"azure-pipelines.yml\" ||\n base === \"azure-pipelines.yaml\" ||\n (lower.includes(\".circleci/\") && (lower.endsWith(\".yml\") || lower.endsWith(\".yaml\")))\n );\n}\n\ninterface CiRule {\n re: RegExp;\n meta: RuleMeta;\n}\n\nconst CI_RULES: CiRule[] = [\n {\n re: /\\bcosign\\s+(?:sign|attest|sign-blob|generate-key-pair)\\b/g,\n meta: {\n id: \"ci-cosign-ecdsa\",\n title: \"cosign artifact signing (ECDSA)\",\n description: \"sigstore/cosign signing in a CI pipeline\",\n category: \"signature\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"ECDSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"CI pipeline signs artifacts with cosign (ECDSA P-256, key-based or keyless/Fulcio); classical signatures are forgeable once a CRQC exists.\",\n remediation:\n \"Track sigstore's post-quantum signing roadmap (ML-DSA); plan hybrid signing for long-lived release artifacts.\",\n },\n },\n {\n re: /\\bgpg\\b[^\\n]*?\\s--(?:detach-sign|clearsign|sign)\\b/g,\n meta: {\n id: \"ci-gpg-sign\",\n title: \"GPG signing (RSA)\",\n description: \"GnuPG detached/clear signing in a CI pipeline\",\n category: \"signature\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"CI pipeline signs with GPG, classically an RSA signing key; forgeable once a CRQC exists.\",\n remediation: \"Plan migration to ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205) signatures.\",\n },\n },\n {\n re: /\\bjarsigner\\b/g,\n meta: {\n id: \"ci-jarsigner\",\n title: \"Java jarsigner (classical)\",\n description: \"JDK jarsigner code signing in a CI pipeline\",\n category: \"signature\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"CI pipeline signs JARs with jarsigner (classical RSA/DSA/EC signing key); forgeable once a CRQC exists.\",\n remediation:\n \"Plan migration to a PQC signature scheme (ML-DSA-65 / SLH-DSA) as the JDK adds support.\",\n },\n },\n {\n re: /\\bcodesign\\s+(?:-s\\b|--sign\\b)/g,\n meta: {\n id: \"ci-codesign\",\n title: \"Apple codesign (RSA)\",\n description: \"Apple codesign in a CI pipeline\",\n category: \"signature\",\n severity: \"medium\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"CI pipeline signs with Apple codesign (classical RSA signing identity); forgeable once a CRQC exists.\",\n remediation: \"Classical only today; track Apple's PQC signing support and plan migration.\",\n },\n },\n {\n re: /\\bminisign\\b/g,\n meta: {\n id: \"ci-minisign\",\n title: \"minisign (Ed25519)\",\n description: \"minisign signing in a CI pipeline\",\n category: \"signature\",\n severity: \"low\",\n confidence: \"high\",\n algorithm: \"EdDSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"CI pipeline signs with minisign (Ed25519); modern but classical and forgeable once a CRQC exists.\",\n remediation: \"Plan migration to ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205).\",\n },\n },\n];\n\n/** Detects classical artifact / code signing in CI/CD pipeline definitions. */\nexport const cicdDetector: Detector = {\n id: \"cicd-signing\",\n description: \"Classical artifact / code signing in CI/CD pipelines\",\n scope: \"config\",\n language: \"any\",\n rules: CI_RULES.map((r) => r.meta),\n appliesTo: isCiPipelineFile,\n detect({ file, content }): Finding[] {\n const findings: Finding[] = [];\n for (const rule of CI_RULES) {\n eachMatch(rule.re, content, (m) => {\n findings.push(\n findingFromRule(rule.meta, { file, content, index: m.index, matchLength: m[0].length }),\n );\n });\n }\n return findings;\n },\n};\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud-KMS SDK detector: classical asymmetric keys minted at RUNTIME through a
|
|
3
|
+
* cloud KMS SDK call — the application-code counterpart to the Terraform detector
|
|
4
|
+
* (which covers the infrastructure-as-code path). AWS KMS `CreateKey` /
|
|
5
|
+
* `GenerateDataKeyPair` select the key type with a `KeySpec` / `KeyPairSpec`
|
|
6
|
+
* (legacy `CustomerMasterKeySpec`) field whose value is `RSA_*` or `ECC_*`.
|
|
7
|
+
*
|
|
8
|
+
* These PascalCase field names + `RSA_2048` / `ECC_NIST_P256` values are specific
|
|
9
|
+
* to the AWS KMS API across every SDK language (JS/TS, Python/boto3, Java, Go,
|
|
10
|
+
* the CLI, JSON policies), so a single lexical rule catches them all with a very
|
|
11
|
+
* low false-positive rate. Terraform uses the snake_case `customer_master_key_spec`
|
|
12
|
+
* instead, so this never double-counts with the IaC detector.
|
|
13
|
+
*
|
|
14
|
+
* HNDL: an RSA KMS key (encryption/KEM) and an EC KMS key (which AWS KMS can use
|
|
15
|
+
* for ECDH key agreement as well as ECDSA signing) are both harvest-now-decrypt-
|
|
16
|
+
* later exposed → hndl:true.
|
|
17
|
+
*/
|
|
18
|
+
import type { Detector } from "../types.js";
|
|
19
|
+
/** Detects classical asymmetric keys provisioned via a cloud KMS SDK call. */
|
|
20
|
+
export declare const cloudKmsDetector: Detector;
|
|
21
|
+
//# sourceMappingURL=cloud-kms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-kms.d.ts","sourceRoot":"","sources":["../../src/detectors/cloud-kms.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AAyC/D,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,EAAE,QA2B9B,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { eachMatch, findingFromRule } from "../detect-utils.js";
|
|
2
|
+
import { CWE_BROKEN_CRYPTO } from "../cwe.js";
|
|
3
|
+
// The AWS KMS key-spec fields (CreateKey / GenerateDataKeyPair / legacy CMK). The
|
|
4
|
+
// optional `"?` after the field name accepts both the JS/HCL form (`KeySpec:`) and
|
|
5
|
+
// the JSON form where the key is quoted (`"KeySpec":`).
|
|
6
|
+
const SPEC_KEYS = "KeySpec|KeyPairSpec|CustomerMasterKeySpec";
|
|
7
|
+
const RE_KMS_RSA = new RegExp(`\\b(?:${SPEC_KEYS})"?\\s*[:=]\\s*['"]RSA_\\d+['"]`, "g");
|
|
8
|
+
const RE_KMS_EC = new RegExp(`\\b(?:${SPEC_KEYS})"?\\s*[:=]\\s*['"]ECC_[A-Z0-9_]+['"]`, "g");
|
|
9
|
+
const RULE_KMS_RSA = {
|
|
10
|
+
id: "cloud-kms-rsa",
|
|
11
|
+
title: "AWS KMS RSA key",
|
|
12
|
+
description: "AWS KMS CreateKey / GenerateDataKeyPair with an RSA_* key spec",
|
|
13
|
+
category: "kem",
|
|
14
|
+
severity: "high",
|
|
15
|
+
confidence: "high",
|
|
16
|
+
algorithm: "RSA",
|
|
17
|
+
hndl: true,
|
|
18
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
19
|
+
message: "Mints a classical RSA key via the AWS KMS SDK (harvest-now-decrypt-later exposed for encryption).",
|
|
20
|
+
remediation: "Plan migration to PQC as cloud KMS adds ML-KEM / ML-DSA key specs.",
|
|
21
|
+
};
|
|
22
|
+
const RULE_KMS_EC = {
|
|
23
|
+
id: "cloud-kms-ec",
|
|
24
|
+
title: "AWS KMS EC key",
|
|
25
|
+
description: "AWS KMS CreateKey / GenerateDataKeyPair with an ECC_* key spec",
|
|
26
|
+
category: "key-exchange",
|
|
27
|
+
severity: "high",
|
|
28
|
+
confidence: "high",
|
|
29
|
+
algorithm: "ECDH",
|
|
30
|
+
hndl: true,
|
|
31
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
32
|
+
message: "Mints a classical EC key via the AWS KMS SDK; EC keys feed ECDSA signatures and ECDH key agreement (the ECDH path is harvest-now-decrypt-later exposed).",
|
|
33
|
+
remediation: "For key agreement: hybrid X25519MLKEM768 (ML-KEM-768). For signatures: ML-DSA-65 (FIPS 204).",
|
|
34
|
+
};
|
|
35
|
+
/** Detects classical asymmetric keys provisioned via a cloud KMS SDK call. */
|
|
36
|
+
export const cloudKmsDetector = {
|
|
37
|
+
id: "cloud-kms",
|
|
38
|
+
description: "Classical asymmetric keys minted via a cloud KMS SDK (AWS KMS)",
|
|
39
|
+
scope: "config",
|
|
40
|
+
language: "any",
|
|
41
|
+
rules: [RULE_KMS_RSA, RULE_KMS_EC],
|
|
42
|
+
appliesTo: () => true,
|
|
43
|
+
detect({ file, content }) {
|
|
44
|
+
// Fast reject: only proceed if a KMS key-spec field name is present.
|
|
45
|
+
if (!content.includes("KeySpec") &&
|
|
46
|
+
!content.includes("KeyPairSpec") &&
|
|
47
|
+
!content.includes("CustomerMasterKeySpec")) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const findings = [];
|
|
51
|
+
const add = (re, rule) => eachMatch(re, content, (m) => findings.push(findingFromRule(rule, { file, content, index: m.index, matchLength: m[0].length })));
|
|
52
|
+
add(RE_KMS_RSA, RULE_KMS_RSA);
|
|
53
|
+
add(RE_KMS_EC, RULE_KMS_EC);
|
|
54
|
+
return findings;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=cloud-kms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-kms.js","sourceRoot":"","sources":["../../src/detectors/cloud-kms.ts"],"names":[],"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EAAE,CAAC,IAAI;IACrB,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;QACtB,qEAAqE;QACrE,IACE,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC5B,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;YAChC,CAAC,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAC1C,CAAC;YACD,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,QAAQ,GAAc,EAAE,CAAC;QAC/B,MAAM,GAAG,GAAG,CAAC,EAAU,EAAE,IAAc,EAAQ,EAAE,CAC/C,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAC3B,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;QACJ,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAC9B,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAC5B,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC","sourcesContent":["/**\n * Cloud-KMS SDK detector: classical asymmetric keys minted at RUNTIME through a\n * cloud KMS SDK call — the application-code counterpart to the Terraform detector\n * (which covers the infrastructure-as-code path). AWS KMS `CreateKey` /\n * `GenerateDataKeyPair` select the key type with a `KeySpec` / `KeyPairSpec`\n * (legacy `CustomerMasterKeySpec`) field whose value is `RSA_*` or `ECC_*`.\n *\n * These PascalCase field names + `RSA_2048` / `ECC_NIST_P256` values are specific\n * to the AWS KMS API across every SDK language (JS/TS, Python/boto3, Java, Go,\n * the CLI, JSON policies), so a single lexical rule catches them all with a very\n * low false-positive rate. Terraform uses the snake_case `customer_master_key_spec`\n * instead, so this never double-counts with the IaC detector.\n *\n * HNDL: an RSA KMS key (encryption/KEM) and an EC KMS key (which AWS KMS can use\n * for ECDH key agreement as well as ECDSA signing) are both harvest-now-decrypt-\n * later exposed → hndl:true.\n */\nimport type { Detector, Finding, RuleMeta } from \"../types.js\";\nimport { eachMatch, findingFromRule } from \"../detect-utils.js\";\nimport { CWE_BROKEN_CRYPTO } from \"../cwe.js\";\n\n// The AWS KMS key-spec fields (CreateKey / GenerateDataKeyPair / legacy CMK). The\n// optional `\"?` after the field name accepts both the JS/HCL form (`KeySpec:`) and\n// the JSON form where the key is quoted (`\"KeySpec\":`).\nconst SPEC_KEYS = \"KeySpec|KeyPairSpec|CustomerMasterKeySpec\";\nconst RE_KMS_RSA = new RegExp(`\\\\b(?:${SPEC_KEYS})\"?\\\\s*[:=]\\\\s*['\"]RSA_\\\\d+['\"]`, \"g\");\nconst RE_KMS_EC = new RegExp(`\\\\b(?:${SPEC_KEYS})\"?\\\\s*[:=]\\\\s*['\"]ECC_[A-Z0-9_]+['\"]`, \"g\");\n\nconst RULE_KMS_RSA: RuleMeta = {\n id: \"cloud-kms-rsa\",\n title: \"AWS KMS RSA key\",\n description: \"AWS KMS CreateKey / GenerateDataKeyPair with an RSA_* key spec\",\n category: \"kem\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Mints a classical RSA key via the AWS KMS SDK (harvest-now-decrypt-later exposed for encryption).\",\n remediation: \"Plan migration to PQC as cloud KMS adds ML-KEM / ML-DSA key specs.\",\n};\nconst RULE_KMS_EC: RuleMeta = {\n id: \"cloud-kms-ec\",\n title: \"AWS KMS EC key\",\n description: \"AWS KMS CreateKey / GenerateDataKeyPair with an ECC_* key spec\",\n category: \"key-exchange\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"ECDH\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"Mints a classical EC key via the AWS KMS SDK; EC keys feed 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};\n\n/** Detects classical asymmetric keys provisioned via a cloud KMS SDK call. */\nexport const cloudKmsDetector: Detector = {\n id: \"cloud-kms\",\n description: \"Classical asymmetric keys minted via a cloud KMS SDK (AWS KMS)\",\n scope: \"config\",\n language: \"any\",\n rules: [RULE_KMS_RSA, RULE_KMS_EC],\n appliesTo: () => true,\n detect({ file, content }): Finding[] {\n // Fast reject: only proceed if a KMS key-spec field name is present.\n if (\n !content.includes(\"KeySpec\") &&\n !content.includes(\"KeyPairSpec\") &&\n !content.includes(\"CustomerMasterKeySpec\")\n ) {\n return [];\n }\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_KMS_RSA, RULE_KMS_RSA);\n add(RE_KMS_EC, RULE_KMS_EC);\n return findings;\n },\n};\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IaC detector: classical asymmetric cryptography (and legacy TLS config)
|
|
3
|
+
* declared in AWS CloudFormation / Azure ARM (incl. Bicep-compiled JSON)
|
|
4
|
+
* templates — plus CDK `cdk synth` output, which is plain CloudFormation
|
|
5
|
+
* JSON. This is a distinct surface from `terraform.ts`: CloudFormation/ARM
|
|
6
|
+
* use PascalCase JSON/YAML property names, never Terraform's snake_case HCL
|
|
7
|
+
* attributes, so the two detectors never collide on the same file.
|
|
8
|
+
*
|
|
9
|
+
* Covered:
|
|
10
|
+
* - AWS::KMS::Key `KeySpec`: `"RSA_…"` (kem) / `"ECC_…"` (key-exchange)
|
|
11
|
+
* - AWS::CertificateManager::Certificate
|
|
12
|
+
* `KeyAlgorithm`: `"RSA_…"` / `"EC_…"` (certificate)
|
|
13
|
+
* - CloudFront distribution `MinimumProtocolVersion`: legacy `TLSv1` / `TLSv1.1` (tls)
|
|
14
|
+
* - ELB/ALB listener `SslPolicy`: legacy `ELBSecurityPolicy-2016-08` /
|
|
15
|
+
* `-TLS-1-0-…` / `-TLS-1-1-…` (tls)
|
|
16
|
+
* - Azure ARM `Microsoft.KeyVault` key `kty`: `"RSA"` (kem) / `"EC"` (key-exchange)
|
|
17
|
+
*
|
|
18
|
+
* `KeySpec` is PascalCase and case-sensitive, so it never matches Terraform's
|
|
19
|
+
* snake_case `customer_master_key_spec` (same underlying AWS API, different
|
|
20
|
+
* authoring surface). A fast-reject on a CFN/ARM marker keeps this detector
|
|
21
|
+
* from ever firing on arbitrary JSON/YAML that happens to contain one of
|
|
22
|
+
* these property names in an unrelated context.
|
|
23
|
+
*/
|
|
24
|
+
import type { Detector } from "../types.js";
|
|
25
|
+
/**
|
|
26
|
+
* Detects classical asymmetric crypto and legacy TLS config declared in
|
|
27
|
+
* AWS CloudFormation / Azure ARM (incl. Bicep-compiled JSON) templates.
|
|
28
|
+
*/
|
|
29
|
+
export declare const cloudformationDetector: Detector;
|
|
30
|
+
//# sourceMappingURL=cloudformation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudformation.d.ts","sourceRoot":"","sources":["../../src/detectors/cloudformation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AAsJ/D;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,QAqCpC,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { eachMatch, findingFromRule, hasExtension } from "../detect-utils.js";
|
|
2
|
+
import { CWE_BROKEN_CRYPTO, CWE_WEAK_STRENGTH } from "../cwe.js";
|
|
3
|
+
const CFN_EXTENSIONS = [".json", ".yaml", ".yml"];
|
|
4
|
+
// Fast-reject markers: at least one must appear before any rule regex runs, so
|
|
5
|
+
// this detector never scans arbitrary JSON/YAML that merely happens to share
|
|
6
|
+
// an attribute name (`KeySpec`, `kty`, …) with an unrelated schema.
|
|
7
|
+
const CFN_MARKERS = [
|
|
8
|
+
"AWS::KMS",
|
|
9
|
+
"AWS::CertificateManager",
|
|
10
|
+
"AWSTemplateFormatVersion",
|
|
11
|
+
"MinimumProtocolVersion",
|
|
12
|
+
"Microsoft.KeyVault",
|
|
13
|
+
'"SslPolicy"',
|
|
14
|
+
];
|
|
15
|
+
// Each attribute is matched with an optional quote around the key and `:` as
|
|
16
|
+
// the separator (both plain-JSON and YAML-block-scalar forms use `:`). The
|
|
17
|
+
// `(?<![\w"-])` lookbehind stops a longer/prefixed attribute name from
|
|
18
|
+
// matching on its suffix.
|
|
19
|
+
const RE_CFN_KMS_RSA = /(?<![\w"-])"?KeySpec"?\s*:\s*"?RSA_\d+"?/g;
|
|
20
|
+
const RE_CFN_KMS_EC = /(?<![\w"-])"?KeySpec"?\s*:\s*"?ECC_[A-Z0-9_]+"?/g;
|
|
21
|
+
const RE_CFN_ACM_RSA = /(?<![\w"-])"?KeyAlgorithm"?\s*:\s*"?RSA_\d+"?/g;
|
|
22
|
+
const RE_CFN_ACM_EC = /(?<![\w"-])"?KeyAlgorithm"?\s*:\s*"?EC_[A-Za-z0-9]+"?/g;
|
|
23
|
+
// CloudFront: only the pre-2018 "TLSv1" / "TLSv1_2016" / "TLSv1.1_2016"
|
|
24
|
+
// values are legacy; the lookahead delimiter stops this from matching a
|
|
25
|
+
// "TLSv1.2_2018"-style value that merely starts with the same prefix.
|
|
26
|
+
const RE_CFN_CLOUDFRONT_TLS = /(?<![\w"-])"?MinimumProtocolVersion"?\s*:\s*"?(?:TLSv1(?:\.1)?_2016|TLSv1)(?=["'\s,}]|$)/gm;
|
|
27
|
+
// ELB/ALB legacy SSL negotiation policies (named, dated policy strings).
|
|
28
|
+
const RE_CFN_ELB_TLS = /(?<![\w"-])"?SslPolicy"?\s*:\s*"ELBSecurityPolicy-(?:2016-08|TLS-1-0-\d{4}-\d{2}|TLS-1-1-\d{4}-\d{2})"/g;
|
|
29
|
+
// Azure ARM Microsoft.KeyVault key resource `properties.kty`.
|
|
30
|
+
const RE_CFN_ARM_KV_RSA = /(?<![\w"-])"?kty"?\s*:\s*"?RSA"?(?!\w)/g;
|
|
31
|
+
const RE_CFN_ARM_KV_EC = /(?<![\w"-])"?kty"?\s*:\s*"?EC"?(?!\w)/g;
|
|
32
|
+
const RULE_CFN_KMS_RSA = {
|
|
33
|
+
id: "cfn-kms-rsa",
|
|
34
|
+
title: "CloudFormation KMS RSA key",
|
|
35
|
+
description: 'AWS::KMS::Key KeySpec = "RSA_*"',
|
|
36
|
+
category: "kem",
|
|
37
|
+
severity: "high",
|
|
38
|
+
confidence: "high",
|
|
39
|
+
algorithm: "RSA",
|
|
40
|
+
hndl: true,
|
|
41
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
42
|
+
message: "CloudFormation provisions a classical RSA KMS key (harvest-now-decrypt-later exposed for encryption CMKs).",
|
|
43
|
+
remediation: "Plan migration to PQC as cloud KMS adds ML-KEM / ML-DSA key specs.",
|
|
44
|
+
};
|
|
45
|
+
const RULE_CFN_KMS_EC = {
|
|
46
|
+
id: "cfn-kms-ec",
|
|
47
|
+
title: "CloudFormation KMS EC key",
|
|
48
|
+
description: 'AWS::KMS::Key KeySpec = "ECC_*"',
|
|
49
|
+
category: "key-exchange",
|
|
50
|
+
severity: "high",
|
|
51
|
+
confidence: "high",
|
|
52
|
+
algorithm: "ECDH",
|
|
53
|
+
hndl: true,
|
|
54
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
55
|
+
message: "CloudFormation provisions a classical EC KMS key; EC keys feed ECDSA signatures and ECDH key agreement (the ECDH path is harvest-now-decrypt-later exposed).",
|
|
56
|
+
remediation: "For key agreement: hybrid X25519MLKEM768 (ML-KEM-768). For signatures: ML-DSA-65 (FIPS 204).",
|
|
57
|
+
};
|
|
58
|
+
const RULE_CFN_ACM_RSA = {
|
|
59
|
+
id: "cfn-acm-rsa",
|
|
60
|
+
title: "CloudFormation ACM RSA certificate",
|
|
61
|
+
description: 'AWS::CertificateManager::Certificate KeyAlgorithm = "RSA_*"',
|
|
62
|
+
category: "certificate",
|
|
63
|
+
severity: "high",
|
|
64
|
+
confidence: "high",
|
|
65
|
+
algorithm: "RSA",
|
|
66
|
+
hndl: true,
|
|
67
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
68
|
+
message: "CloudFormation provisions an ACM certificate with a classical RSA key, which is not quantum-safe.",
|
|
69
|
+
remediation: "Plan migration to PQC (ML-KEM-768 for encryption, ML-DSA-65 for signatures).",
|
|
70
|
+
};
|
|
71
|
+
const RULE_CFN_ACM_EC = {
|
|
72
|
+
id: "cfn-acm-ec",
|
|
73
|
+
title: "CloudFormation ACM EC certificate",
|
|
74
|
+
description: 'AWS::CertificateManager::Certificate KeyAlgorithm = "EC_*"',
|
|
75
|
+
category: "certificate",
|
|
76
|
+
severity: "high",
|
|
77
|
+
confidence: "high",
|
|
78
|
+
algorithm: "ECDSA",
|
|
79
|
+
hndl: false,
|
|
80
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
81
|
+
message: "CloudFormation provisions an ACM certificate with a classical EC key, forgeable by a quantum attacker.",
|
|
82
|
+
remediation: "ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205).",
|
|
83
|
+
};
|
|
84
|
+
const RULE_CFN_CLOUDFRONT_TLS = {
|
|
85
|
+
id: "cfn-cloudfront-legacy-tls",
|
|
86
|
+
title: "CloudFormation CloudFront legacy TLS",
|
|
87
|
+
description: 'CloudFront Distribution MinimumProtocolVersion = "TLSv1" / "TLSv1.1"',
|
|
88
|
+
category: "tls",
|
|
89
|
+
severity: "medium",
|
|
90
|
+
confidence: "high",
|
|
91
|
+
hndl: false,
|
|
92
|
+
cwe: CWE_WEAK_STRENGTH,
|
|
93
|
+
message: "CloudFront distribution permits TLS 1.0/1.1, which are deprecated and insecure.",
|
|
94
|
+
remediation: "Set MinimumProtocolVersion to TLSv1.2_2021 (or later) and prefer PQC-hybrid key exchange.",
|
|
95
|
+
};
|
|
96
|
+
const RULE_CFN_ELB_TLS = {
|
|
97
|
+
id: "cfn-elb-legacy-tls",
|
|
98
|
+
title: "CloudFormation ELB/ALB legacy TLS policy",
|
|
99
|
+
description: "Elastic Load Balancer SslPolicy naming a pre-2017 legacy policy",
|
|
100
|
+
category: "tls",
|
|
101
|
+
severity: "medium",
|
|
102
|
+
confidence: "high",
|
|
103
|
+
hndl: false,
|
|
104
|
+
cwe: CWE_WEAK_STRENGTH,
|
|
105
|
+
message: "Load balancer listener uses a legacy SSL negotiation policy permitting TLS 1.0/1.1.",
|
|
106
|
+
remediation: "Use ELBSecurityPolicy-TLS13-1-2-2021-06 (or the latest FS+TLS1.2/1.3 policy).",
|
|
107
|
+
};
|
|
108
|
+
const RULE_CFN_ARM_KV_RSA = {
|
|
109
|
+
id: "cfn-arm-keyvault-rsa",
|
|
110
|
+
title: "ARM template Key Vault RSA key",
|
|
111
|
+
description: 'Microsoft.KeyVault key resource kty = "RSA"',
|
|
112
|
+
category: "kem",
|
|
113
|
+
severity: "high",
|
|
114
|
+
confidence: "high",
|
|
115
|
+
algorithm: "RSA",
|
|
116
|
+
hndl: true,
|
|
117
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
118
|
+
message: "ARM template provisions a classical RSA Azure Key Vault key, which is not quantum-safe.",
|
|
119
|
+
remediation: "Plan migration to PQC (ML-KEM-768 / ML-DSA-65).",
|
|
120
|
+
};
|
|
121
|
+
const RULE_CFN_ARM_KV_EC = {
|
|
122
|
+
id: "cfn-arm-keyvault-ec",
|
|
123
|
+
title: "ARM template Key Vault EC key",
|
|
124
|
+
description: 'Microsoft.KeyVault key resource kty = "EC"',
|
|
125
|
+
category: "key-exchange",
|
|
126
|
+
severity: "high",
|
|
127
|
+
confidence: "high",
|
|
128
|
+
algorithm: "ECDH",
|
|
129
|
+
hndl: true,
|
|
130
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
131
|
+
message: "ARM template provisions a classical EC Azure Key Vault key; EC keys feed ECDSA signatures and ECDH key agreement (the ECDH path is harvest-now-decrypt-later exposed).",
|
|
132
|
+
remediation: "For key agreement: hybrid X25519MLKEM768 (ML-KEM-768). For signatures: ML-DSA-65 (FIPS 204).",
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Detects classical asymmetric crypto and legacy TLS config declared in
|
|
136
|
+
* AWS CloudFormation / Azure ARM (incl. Bicep-compiled JSON) templates.
|
|
137
|
+
*/
|
|
138
|
+
export const cloudformationDetector = {
|
|
139
|
+
id: "cloudformation-crypto",
|
|
140
|
+
description: "Classical asymmetric crypto and legacy TLS config declared in CloudFormation / ARM templates (IaC)",
|
|
141
|
+
scope: "config",
|
|
142
|
+
language: "any",
|
|
143
|
+
rules: [
|
|
144
|
+
RULE_CFN_KMS_RSA,
|
|
145
|
+
RULE_CFN_KMS_EC,
|
|
146
|
+
RULE_CFN_ACM_RSA,
|
|
147
|
+
RULE_CFN_ACM_EC,
|
|
148
|
+
RULE_CFN_CLOUDFRONT_TLS,
|
|
149
|
+
RULE_CFN_ELB_TLS,
|
|
150
|
+
RULE_CFN_ARM_KV_RSA,
|
|
151
|
+
RULE_CFN_ARM_KV_EC,
|
|
152
|
+
],
|
|
153
|
+
appliesTo: (f) => hasExtension(f, CFN_EXTENSIONS),
|
|
154
|
+
detect({ file, content }) {
|
|
155
|
+
if (!CFN_MARKERS.some((marker) => content.includes(marker)))
|
|
156
|
+
return [];
|
|
157
|
+
const findings = [];
|
|
158
|
+
const add = (re, rule) => eachMatch(re, content, (m) => findings.push(findingFromRule(rule, { file, content, index: m.index, matchLength: m[0].length })));
|
|
159
|
+
add(RE_CFN_KMS_RSA, RULE_CFN_KMS_RSA);
|
|
160
|
+
add(RE_CFN_KMS_EC, RULE_CFN_KMS_EC);
|
|
161
|
+
add(RE_CFN_ACM_RSA, RULE_CFN_ACM_RSA);
|
|
162
|
+
add(RE_CFN_ACM_EC, RULE_CFN_ACM_EC);
|
|
163
|
+
add(RE_CFN_CLOUDFRONT_TLS, RULE_CFN_CLOUDFRONT_TLS);
|
|
164
|
+
add(RE_CFN_ELB_TLS, RULE_CFN_ELB_TLS);
|
|
165
|
+
add(RE_CFN_ARM_KV_RSA, RULE_CFN_ARM_KV_RSA);
|
|
166
|
+
add(RE_CFN_ARM_KV_EC, RULE_CFN_ARM_KV_EC);
|
|
167
|
+
return findings;
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
//# sourceMappingURL=cloudformation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudformation.js","sourceRoot":"","sources":["../../src/detectors/cloudformation.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEjE,MAAM,cAAc,GAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAErE,+EAA+E;AAC/E,6EAA6E;AAC7E,oEAAoE;AACpE,MAAM,WAAW,GAAsB;IACrC,UAAU;IACV,yBAAyB;IACzB,0BAA0B;IAC1B,wBAAwB;IACxB,oBAAoB;IACpB,aAAa;CACd,CAAC;AAEF,6EAA6E;AAC7E,2EAA2E;AAC3E,uEAAuE;AACvE,0BAA0B;AAC1B,MAAM,cAAc,GAAG,2CAA2C,CAAC;AACnE,MAAM,aAAa,GAAG,kDAAkD,CAAC;AACzE,MAAM,cAAc,GAAG,gDAAgD,CAAC;AACxE,MAAM,aAAa,GAAG,wDAAwD,CAAC;AAC/E,wEAAwE;AACxE,wEAAwE;AACxE,sEAAsE;AACtE,MAAM,qBAAqB,GACzB,4FAA4F,CAAC;AAC/F,yEAAyE;AACzE,MAAM,cAAc,GAClB,yGAAyG,CAAC;AAC5G,8DAA8D;AAC9D,MA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AAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC;QACpD,GAAG,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;QACtC,GAAG,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;QAC5C,GAAG,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;QAC1C,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC","sourcesContent":["/**\n * IaC detector: classical asymmetric cryptography (and legacy TLS config)\n * declared in AWS CloudFormation / Azure ARM (incl. Bicep-compiled JSON)\n * templates — plus CDK `cdk synth` output, which is plain CloudFormation\n * JSON. This is a distinct surface from `terraform.ts`: CloudFormation/ARM\n * use PascalCase JSON/YAML property names, never Terraform's snake_case HCL\n * attributes, so the two detectors never collide on the same file.\n *\n * Covered:\n * - AWS::KMS::Key `KeySpec`: `\"RSA_…\"` (kem) / `\"ECC_…\"` (key-exchange)\n * - AWS::CertificateManager::Certificate\n * `KeyAlgorithm`: `\"RSA_…\"` / `\"EC_…\"` (certificate)\n * - CloudFront distribution `MinimumProtocolVersion`: legacy `TLSv1` / `TLSv1.1` (tls)\n * - ELB/ALB listener `SslPolicy`: legacy `ELBSecurityPolicy-2016-08` /\n * `-TLS-1-0-…` / `-TLS-1-1-…` (tls)\n * - Azure ARM `Microsoft.KeyVault` key `kty`: `\"RSA\"` (kem) / `\"EC\"` (key-exchange)\n *\n * `KeySpec` is PascalCase and case-sensitive, so it never matches Terraform's\n * snake_case `customer_master_key_spec` (same underlying AWS API, different\n * authoring surface). A fast-reject on a CFN/ARM marker keeps this detector\n * from ever firing on arbitrary JSON/YAML that happens to contain one of\n * these property names in an unrelated context.\n */\nimport type { Detector, Finding, RuleMeta } from \"../types.js\";\nimport { eachMatch, findingFromRule, hasExtension } from \"../detect-utils.js\";\nimport { CWE_BROKEN_CRYPTO, CWE_WEAK_STRENGTH } from \"../cwe.js\";\n\nconst CFN_EXTENSIONS: readonly string[] = [\".json\", \".yaml\", \".yml\"];\n\n// Fast-reject markers: at least one must appear before any rule regex runs, so\n// this detector never scans arbitrary JSON/YAML that merely happens to share\n// an attribute name (`KeySpec`, `kty`, …) with an unrelated schema.\nconst CFN_MARKERS: readonly string[] = [\n \"AWS::KMS\",\n \"AWS::CertificateManager\",\n \"AWSTemplateFormatVersion\",\n \"MinimumProtocolVersion\",\n \"Microsoft.KeyVault\",\n '\"SslPolicy\"',\n];\n\n// Each attribute is matched with an optional quote around the key and `:` as\n// the separator (both plain-JSON and YAML-block-scalar forms use `:`). The\n// `(?<![\\w\"-])` lookbehind stops a longer/prefixed attribute name from\n// matching on its suffix.\nconst RE_CFN_KMS_RSA = /(?<![\\w\"-])\"?KeySpec\"?\\s*:\\s*\"?RSA_\\d+\"?/g;\nconst RE_CFN_KMS_EC = /(?<![\\w\"-])\"?KeySpec\"?\\s*:\\s*\"?ECC_[A-Z0-9_]+\"?/g;\nconst RE_CFN_ACM_RSA = /(?<![\\w\"-])\"?KeyAlgorithm\"?\\s*:\\s*\"?RSA_\\d+\"?/g;\nconst RE_CFN_ACM_EC = /(?<![\\w\"-])\"?KeyAlgorithm\"?\\s*:\\s*\"?EC_[A-Za-z0-9]+\"?/g;\n// CloudFront: only the pre-2018 \"TLSv1\" / \"TLSv1_2016\" / \"TLSv1.1_2016\"\n// values are legacy; the lookahead delimiter stops this from matching a\n// \"TLSv1.2_2018\"-style value that merely starts with the same prefix.\nconst RE_CFN_CLOUDFRONT_TLS =\n /(?<![\\w\"-])\"?MinimumProtocolVersion\"?\\s*:\\s*\"?(?:TLSv1(?:\\.1)?_2016|TLSv1)(?=[\"'\\s,}]|$)/gm;\n// ELB/ALB legacy SSL negotiation policies (named, dated policy strings).\nconst RE_CFN_ELB_TLS =\n /(?<![\\w\"-])\"?SslPolicy\"?\\s*:\\s*\"ELBSecurityPolicy-(?:2016-08|TLS-1-0-\\d{4}-\\d{2}|TLS-1-1-\\d{4}-\\d{2})\"/g;\n// Azure ARM Microsoft.KeyVault key resource `properties.kty`.\nconst RE_CFN_ARM_KV_RSA = /(?<![\\w\"-])\"?kty\"?\\s*:\\s*\"?RSA\"?(?!\\w)/g;\nconst RE_CFN_ARM_KV_EC = /(?<![\\w\"-])\"?kty\"?\\s*:\\s*\"?EC\"?(?!\\w)/g;\n\nconst RULE_CFN_KMS_RSA: RuleMeta = {\n id: \"cfn-kms-rsa\",\n title: \"CloudFormation KMS RSA key\",\n description: 'AWS::KMS::Key KeySpec = \"RSA_*\"',\n category: \"kem\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"CloudFormation provisions a classical RSA KMS key (harvest-now-decrypt-later exposed for encryption CMKs).\",\n remediation: \"Plan migration to PQC as cloud KMS adds ML-KEM / ML-DSA key specs.\",\n};\nconst RULE_CFN_KMS_EC: RuleMeta = {\n id: \"cfn-kms-ec\",\n title: \"CloudFormation KMS EC key\",\n description: 'AWS::KMS::Key KeySpec = \"ECC_*\"',\n category: \"key-exchange\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"ECDH\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"CloudFormation provisions a classical EC KMS key; EC keys feed 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_CFN_ACM_RSA: RuleMeta = {\n id: \"cfn-acm-rsa\",\n title: \"CloudFormation ACM RSA certificate\",\n description: 'AWS::CertificateManager::Certificate KeyAlgorithm = \"RSA_*\"',\n category: \"certificate\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"CloudFormation provisions an ACM certificate with a classical RSA key, which is not quantum-safe.\",\n remediation: \"Plan migration to PQC (ML-KEM-768 for encryption, ML-DSA-65 for signatures).\",\n};\nconst RULE_CFN_ACM_EC: RuleMeta = {\n id: \"cfn-acm-ec\",\n title: \"CloudFormation ACM EC certificate\",\n description: 'AWS::CertificateManager::Certificate KeyAlgorithm = \"EC_*\"',\n category: \"certificate\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"ECDSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"CloudFormation provisions an ACM certificate with a classical EC key, forgeable by a quantum attacker.\",\n remediation: \"ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205).\",\n};\nconst RULE_CFN_CLOUDFRONT_TLS: RuleMeta = {\n id: \"cfn-cloudfront-legacy-tls\",\n title: \"CloudFormation CloudFront legacy TLS\",\n description: 'CloudFront Distribution MinimumProtocolVersion = \"TLSv1\" / \"TLSv1.1\"',\n category: \"tls\",\n severity: \"medium\",\n confidence: \"high\",\n hndl: false,\n cwe: CWE_WEAK_STRENGTH,\n message: \"CloudFront distribution permits TLS 1.0/1.1, which are deprecated and insecure.\",\n remediation:\n \"Set MinimumProtocolVersion to TLSv1.2_2021 (or later) and prefer PQC-hybrid key exchange.\",\n};\nconst RULE_CFN_ELB_TLS: RuleMeta = {\n id: \"cfn-elb-legacy-tls\",\n title: \"CloudFormation ELB/ALB legacy TLS policy\",\n description: \"Elastic Load Balancer SslPolicy naming a pre-2017 legacy policy\",\n category: \"tls\",\n severity: \"medium\",\n confidence: \"high\",\n hndl: false,\n cwe: CWE_WEAK_STRENGTH,\n message: \"Load balancer listener uses a legacy SSL negotiation policy permitting TLS 1.0/1.1.\",\n remediation: \"Use ELBSecurityPolicy-TLS13-1-2-2021-06 (or the latest FS+TLS1.2/1.3 policy).\",\n};\nconst RULE_CFN_ARM_KV_RSA: RuleMeta = {\n id: \"cfn-arm-keyvault-rsa\",\n title: \"ARM template Key Vault RSA key\",\n description: 'Microsoft.KeyVault key resource kty = \"RSA\"',\n category: \"kem\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"ARM template provisions a classical RSA Azure Key Vault key, which is not quantum-safe.\",\n remediation: \"Plan migration to PQC (ML-KEM-768 / ML-DSA-65).\",\n};\nconst RULE_CFN_ARM_KV_EC: RuleMeta = {\n id: \"cfn-arm-keyvault-ec\",\n title: \"ARM template Key Vault EC key\",\n description: 'Microsoft.KeyVault key resource kty = \"EC\"',\n category: \"key-exchange\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"ECDH\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"ARM template provisions a classical EC Azure Key Vault key; EC keys feed ECDSA signatures and ECDH key agreement (the ECDH path is harvest-now-decrypt-later exposed).\",\n remediation:\n \"For key agreement: hybrid X25519MLKEM768 (ML-KEM-768). For signatures: ML-DSA-65 (FIPS 204).\",\n};\n\n/**\n * Detects classical asymmetric crypto and legacy TLS config declared in\n * AWS CloudFormation / Azure ARM (incl. Bicep-compiled JSON) templates.\n */\nexport const cloudformationDetector: Detector = {\n id: \"cloudformation-crypto\",\n description:\n \"Classical asymmetric crypto and legacy TLS config declared in CloudFormation / ARM templates (IaC)\",\n scope: \"config\",\n language: \"any\",\n rules: [\n RULE_CFN_KMS_RSA,\n RULE_CFN_KMS_EC,\n RULE_CFN_ACM_RSA,\n RULE_CFN_ACM_EC,\n RULE_CFN_CLOUDFRONT_TLS,\n RULE_CFN_ELB_TLS,\n RULE_CFN_ARM_KV_RSA,\n RULE_CFN_ARM_KV_EC,\n ],\n appliesTo: (f) => hasExtension(f, CFN_EXTENSIONS),\n detect({ file, content }): Finding[] {\n if (!CFN_MARKERS.some((marker) => content.includes(marker))) return [];\n\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_CFN_KMS_RSA, RULE_CFN_KMS_RSA);\n add(RE_CFN_KMS_EC, RULE_CFN_KMS_EC);\n add(RE_CFN_ACM_RSA, RULE_CFN_ACM_RSA);\n add(RE_CFN_ACM_EC, RULE_CFN_ACM_EC);\n add(RE_CFN_CLOUDFRONT_TLS, RULE_CFN_CLOUDFRONT_TLS);\n add(RE_CFN_ELB_TLS, RULE_CFN_ELB_TLS);\n add(RE_CFN_ARM_KV_RSA, RULE_CFN_ARM_KV_RSA);\n add(RE_CFN_ARM_KV_EC, RULE_CFN_ARM_KV_EC);\n return findings;\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csharp.d.ts","sourceRoot":"","sources":["../../src/detectors/csharp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"csharp.d.ts","sourceRoot":"","sources":["../../src/detectors/csharp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AA8L/D,gFAAgF;AAChF,eAAO,MAAM,cAAc,EAAE,QA8C5B,CAAC"}
|
package/dist/detectors/csharp.js
CHANGED
|
@@ -1,9 +1,38 @@
|
|
|
1
1
|
import { CSHARP_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
|
const RE_CS_RSA = /\bRSA\.Create\s*\(|\bnew\s+RSACryptoServiceProvider\s*\(|\bnew\s+RSACng\s*\(|\bnew\s+RSAOpenSsl\s*\(/g;
|
|
4
4
|
const RE_CS_ECDSA = /\bECDsa\.Create\s*\(|\bnew\s+ECDsaCng\s*\(|\bnew\s+ECDsaOpenSsl\s*\(/g;
|
|
5
5
|
const RE_CS_ECDH = /\bECDiffieHellman\.Create\s*\(|\bnew\s+ECDiffieHellmanCng\s*\(|\bnew\s+ECDiffieHellmanOpenSsl\s*\(/g;
|
|
6
6
|
const RE_CS_DSA = /\bDSA\.Create\s*\(|\bnew\s+DSACryptoServiceProvider\s*\(|\bnew\s+DSACng\s*\(/g;
|
|
7
|
+
// Insecure TLS configuration (.NET). Mirrors source.ts's tlsDetector split of a
|
|
8
|
+
// cert-verification-disabled rule (tls-reject-unauthorized) and a legacy-version
|
|
9
|
+
// rule (tls-legacy-version) for the equivalent C# idioms:
|
|
10
|
+
// - DangerousAcceptAnyServerCertificateValidator / a custom
|
|
11
|
+
// ServerCertificateCustomValidationCallback → accepts any cert (MITM).
|
|
12
|
+
// - SslProtocols.Ssl3 / .Tls / .Tls11 → deprecated SSL 3.0 / TLS 1.0 / 1.1.
|
|
13
|
+
// `SslProtocols.Tls` (no suffix) is the legacy TLS 1.0 constant; `Tls12`/`Tls13`
|
|
14
|
+
// are excluded by the trailing \b (the following digit is a word char).
|
|
15
|
+
const RE_CS_TLS_CERT_VALIDATION = /\bDangerousAcceptAnyServerCertificateValidator\b|ServerCertificateCustomValidationCallback\s*=/g;
|
|
16
|
+
const RE_CS_TLS_LEGACY_VERSION = /\bSslProtocols\.(?:Tls|Tls11|Ssl3)\b/g;
|
|
17
|
+
// Identifier-form JWT/JOSE signature algorithms (audit F7). The quoted-string
|
|
18
|
+
// alg token ("RS256") is caught by the language-agnostic jwt-jose detector, but
|
|
19
|
+
// Microsoft.IdentityModel passes the alg as an IDENTIFIER, not a string literal:
|
|
20
|
+
// SecurityAlgorithms.RsaSha256 / SecurityAlgorithms.EcdsaSha256.
|
|
21
|
+
const RE_CS_JWT_ALG = /\bSecurityAlgorithms\.(?:Rsa|Ecdsa)Sha(?:256|384|512)\b/g;
|
|
22
|
+
// BouncyCastle (Org.BouncyCastle) modern-curve and finite-field DH primitives,
|
|
23
|
+
// which System.Security.Cryptography does not expose directly. Each regex is
|
|
24
|
+
// anchored to the distinctive BouncyCastle class names for one family so it
|
|
25
|
+
// can't misfire on unrelated identifiers:
|
|
26
|
+
// - Ed25519KeyPairGenerator / Ed25519Signer / Ed25519PrivateKeyParameters → EdDSA
|
|
27
|
+
// - X25519KeyPairGenerator / X25519Agreement / X25519PrivateKeyParameters → X25519
|
|
28
|
+
// - X448KeyPairGenerator / X448Agreement / X448PrivateKeyParameters → X448
|
|
29
|
+
// - DHParametersGenerator / DHBasicAgreement / DH(Basic)KeyPairGenerator / DHParameters → DH
|
|
30
|
+
// The trailing \b keeps each token whole (e.g. Ed25519KeyGenerationParameters,
|
|
31
|
+
// X25519PublicKeyParameters and DHKeyGenerationParameters are NOT matched).
|
|
32
|
+
const RE_CS_BC_EDDSA = /\bEd25519(?:KeyPairGenerator|Signer|PrivateKeyParameters)\b/g;
|
|
33
|
+
const RE_CS_BC_X25519 = /\bX25519(?:KeyPairGenerator|Agreement|PrivateKeyParameters)\b/g;
|
|
34
|
+
const RE_CS_BC_X448 = /\bX448(?:KeyPairGenerator|Agreement|PrivateKeyParameters)\b/g;
|
|
35
|
+
const RE_CS_BC_DH = /\bDH(?:ParametersGenerator|BasicAgreement|BasicKeyPairGenerator|KeyPairGenerator|Parameters)\b/g;
|
|
7
36
|
const RULE_CS_RSA = {
|
|
8
37
|
id: "csharp-rsa",
|
|
9
38
|
title: "C# RSA key/usage",
|
|
@@ -54,13 +83,111 @@ const RULE_CS_DSA = {
|
|
|
54
83
|
message: "Classical DSA (.NET) is deprecated and forgeable by a quantum attacker.",
|
|
55
84
|
remediation: "Rotate off DSA and migrate to ML-DSA-65 (FIPS 204).",
|
|
56
85
|
};
|
|
86
|
+
const RULE_CS_TLS_CERT = {
|
|
87
|
+
id: "csharp-tls-cert-validation",
|
|
88
|
+
title: "C# TLS certificate verification disabled",
|
|
89
|
+
description: "DangerousAcceptAnyServerCertificateValidator / ServerCertificateCustomValidationCallback override",
|
|
90
|
+
category: "tls",
|
|
91
|
+
severity: "high",
|
|
92
|
+
confidence: "high",
|
|
93
|
+
hndl: false,
|
|
94
|
+
cwe: CWE_CERT_VALIDATION,
|
|
95
|
+
message: "Accepting any server certificate disables TLS certificate verification (MITM risk).",
|
|
96
|
+
remediation: "Remove the custom validator and verify certificates properly; prefer PQC-hybrid key exchange.",
|
|
97
|
+
};
|
|
98
|
+
const RULE_CS_TLS_LEGACY = {
|
|
99
|
+
id: "csharp-tls-legacy-version",
|
|
100
|
+
title: "C# legacy TLS/SSL version pinned",
|
|
101
|
+
description: "SslProtocols pinned to Ssl3 / TLS 1.0 / TLS 1.1",
|
|
102
|
+
category: "tls",
|
|
103
|
+
severity: "medium",
|
|
104
|
+
confidence: "high",
|
|
105
|
+
hndl: false,
|
|
106
|
+
cwe: CWE_WEAK_STRENGTH,
|
|
107
|
+
message: "SSL 3.0 / TLS 1.0 / TLS 1.1 are deprecated and insecure; require TLS 1.2+ (prefer 1.3).",
|
|
108
|
+
remediation: "Use SslProtocols.Tls13 (or Tls12) and prefer PQC-hybrid key exchange.",
|
|
109
|
+
};
|
|
110
|
+
const RULE_CS_JWT_ALG = {
|
|
111
|
+
id: "csharp-jwt-alg",
|
|
112
|
+
title: "C# identifier-form JWT/JOSE algorithm",
|
|
113
|
+
description: "Microsoft.IdentityModel SecurityAlgorithms.RsaSha* / EcdsaSha*",
|
|
114
|
+
category: "signature",
|
|
115
|
+
severity: "high",
|
|
116
|
+
confidence: "high",
|
|
117
|
+
algorithm: "unknown",
|
|
118
|
+
hndl: false,
|
|
119
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
120
|
+
message: "A classical JWT/JOSE signature algorithm (.NET, identifier form) is used, forgeable by a quantum attacker.",
|
|
121
|
+
remediation: "ML-DSA-65 (FIPS 204); track IETF PQC JOSE/COSE algorithms",
|
|
122
|
+
};
|
|
123
|
+
const RULE_CS_BC_EDDSA = {
|
|
124
|
+
id: "csharp-bouncycastle-eddsa",
|
|
125
|
+
title: "C# Ed25519 signature (BouncyCastle)",
|
|
126
|
+
description: "Org.BouncyCastle Ed25519KeyPairGenerator / Ed25519Signer / Ed25519PrivateKeyParameters",
|
|
127
|
+
category: "signature",
|
|
128
|
+
severity: "high",
|
|
129
|
+
confidence: "high",
|
|
130
|
+
algorithm: "EdDSA",
|
|
131
|
+
hndl: false,
|
|
132
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
133
|
+
message: "Classical Ed25519 signing (BouncyCastle) is forgeable by a quantum attacker.",
|
|
134
|
+
remediation: "ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)",
|
|
135
|
+
};
|
|
136
|
+
const RULE_CS_BC_X25519 = {
|
|
137
|
+
id: "csharp-bouncycastle-x25519",
|
|
138
|
+
title: "C# X25519 key agreement (BouncyCastle)",
|
|
139
|
+
description: "Org.BouncyCastle X25519KeyPairGenerator / X25519Agreement / X25519PrivateKeyParameters",
|
|
140
|
+
category: "key-exchange",
|
|
141
|
+
severity: "high",
|
|
142
|
+
confidence: "high",
|
|
143
|
+
algorithm: "X25519",
|
|
144
|
+
hndl: true,
|
|
145
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
146
|
+
message: "X25519 Diffie-Hellman key agreement (BouncyCastle) is broken by Shor's algorithm (harvest-now-decrypt-later).",
|
|
147
|
+
};
|
|
148
|
+
const RULE_CS_BC_X448 = {
|
|
149
|
+
id: "csharp-bouncycastle-x448",
|
|
150
|
+
title: "C# X448 key agreement (BouncyCastle)",
|
|
151
|
+
description: "Org.BouncyCastle X448KeyPairGenerator / X448Agreement / X448PrivateKeyParameters",
|
|
152
|
+
category: "key-exchange",
|
|
153
|
+
severity: "high",
|
|
154
|
+
confidence: "high",
|
|
155
|
+
algorithm: "X448",
|
|
156
|
+
hndl: true,
|
|
157
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
158
|
+
message: "X448 Diffie-Hellman key agreement (BouncyCastle) is broken by Shor's algorithm (harvest-now-decrypt-later).",
|
|
159
|
+
};
|
|
160
|
+
const RULE_CS_BC_DH = {
|
|
161
|
+
id: "csharp-bouncycastle-dh",
|
|
162
|
+
title: "C# finite-field Diffie-Hellman (BouncyCastle)",
|
|
163
|
+
description: "Org.BouncyCastle DHParametersGenerator / DHBasicAgreement / DHKeyPairGenerator / DHParameters",
|
|
164
|
+
category: "key-exchange",
|
|
165
|
+
severity: "high",
|
|
166
|
+
confidence: "high",
|
|
167
|
+
algorithm: "DH",
|
|
168
|
+
hndl: true,
|
|
169
|
+
cwe: CWE_BROKEN_CRYPTO,
|
|
170
|
+
message: "Finite-field Diffie-Hellman (BouncyCastle) is broken by Shor's algorithm (harvest-now-decrypt-later).",
|
|
171
|
+
};
|
|
57
172
|
/** Detects classical asymmetric crypto in C# (System.Security.Cryptography). */
|
|
58
173
|
export const csharpDetector = {
|
|
59
174
|
id: "csharp-crypto",
|
|
60
|
-
description: "Classical asymmetric crypto
|
|
175
|
+
description: "Classical asymmetric crypto (System.Security.Cryptography) and insecure TLS config in C#/.NET",
|
|
61
176
|
scope: "source",
|
|
62
177
|
language: "csharp",
|
|
63
|
-
rules: [
|
|
178
|
+
rules: [
|
|
179
|
+
RULE_CS_RSA,
|
|
180
|
+
RULE_CS_ECDSA,
|
|
181
|
+
RULE_CS_ECDH,
|
|
182
|
+
RULE_CS_DSA,
|
|
183
|
+
RULE_CS_TLS_CERT,
|
|
184
|
+
RULE_CS_TLS_LEGACY,
|
|
185
|
+
RULE_CS_JWT_ALG,
|
|
186
|
+
RULE_CS_BC_EDDSA,
|
|
187
|
+
RULE_CS_BC_X25519,
|
|
188
|
+
RULE_CS_BC_X448,
|
|
189
|
+
RULE_CS_BC_DH,
|
|
190
|
+
],
|
|
64
191
|
appliesTo: (f) => hasExtension(f, CSHARP_EXTENSIONS),
|
|
65
192
|
detect({ file, content }) {
|
|
66
193
|
const findings = [];
|
|
@@ -70,6 +197,17 @@ export const csharpDetector = {
|
|
|
70
197
|
add(RE_CS_ECDH, RULE_CS_ECDH);
|
|
71
198
|
add(RE_CS_RSA, RULE_CS_RSA);
|
|
72
199
|
add(RE_CS_DSA, RULE_CS_DSA);
|
|
200
|
+
// Insecure TLS configuration (disjoint from the crypto factories above).
|
|
201
|
+
add(RE_CS_TLS_CERT_VALIDATION, RULE_CS_TLS_CERT);
|
|
202
|
+
add(RE_CS_TLS_LEGACY_VERSION, RULE_CS_TLS_LEGACY);
|
|
203
|
+
// Identifier-form JWT/JOSE signature algorithms (Microsoft.IdentityModel).
|
|
204
|
+
add(RE_CS_JWT_ALG, RULE_CS_JWT_ALG);
|
|
205
|
+
// BouncyCastle (Org.BouncyCastle) curve / finite-field DH primitives that
|
|
206
|
+
// System.Security.Cryptography does not expose directly.
|
|
207
|
+
add(RE_CS_BC_EDDSA, RULE_CS_BC_EDDSA);
|
|
208
|
+
add(RE_CS_BC_X25519, RULE_CS_BC_X25519);
|
|
209
|
+
add(RE_CS_BC_X448, RULE_CS_BC_X448);
|
|
210
|
+
add(RE_CS_BC_DH, RULE_CS_BC_DH);
|
|
73
211
|
return findings;
|
|
74
212
|
},
|
|
75
213
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csharp.js","sourceRoot":"","sources":["../../src/detectors/csharp.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,SAAS,GACb,uGAAuG,CAAC;AAC1G,MAAM,WAAW,GAAG,uEAAuE,CAAC;AAC5F,MAAM,UAAU,GACd,qGAAqG,CAAC;AACxG,MAAM,SAAS,GAAG,+EAA+E,CAAC;AAElG,MAAM,WAAW,GAAa;IAC5B,EAAE,EAAE,YAAY;IAChB,KAAK,EAAE,kBAAkB;IACzB,WAAW,EAAE,6EAA6E;IAC1F,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,KAAK;IAChB,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,i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,CAAC,CAAC;QAClD,2EAA2E;QAC3E,GAAG,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;QACpC,0EAA0E;QAC1E,yDAAyD;QACzD,GAAG,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;QACtC,GAAG,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;QACxC,GAAG,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;QACpC,GAAG,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAChC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC","sourcesContent":["/**\n * Source-code detector for classical asymmetric cryptography in C# / .NET\n * (`System.Security.Cryptography`). Same lexical strategy as the other packs.\n * .NET exposes each algorithm through a factory (`RSA.Create()`,\n * `ECDsa.Create()`, `ECDiffieHellman.Create()`) or a concrete CSP/CNG class\n * (`RSACryptoServiceProvider`, `ECDsaCng`, …), all of which are precise signals.\n *\n * HNDL: RSA (keygen/encryption) and (EC)DH key agreement are harvest-now-\n * decrypt-later exposed (hndl:true); ECDSA/DSA signatures are hndl:false but\n * forgeable by a quantum attacker.\n */\nimport type { Detector, Finding, RuleMeta } from \"../types.js\";\nimport { CSHARP_EXTENSIONS, eachMatch, findingFromRule, hasExtension } from \"../detect-utils.js\";\nimport { CWE_BROKEN_CRYPTO, CWE_CERT_VALIDATION, CWE_WEAK_STRENGTH } from \"../cwe.js\";\n\nconst RE_CS_RSA =\n /\\bRSA\\.Create\\s*\\(|\\bnew\\s+RSACryptoServiceProvider\\s*\\(|\\bnew\\s+RSACng\\s*\\(|\\bnew\\s+RSAOpenSsl\\s*\\(/g;\nconst RE_CS_ECDSA = /\\bECDsa\\.Create\\s*\\(|\\bnew\\s+ECDsaCng\\s*\\(|\\bnew\\s+ECDsaOpenSsl\\s*\\(/g;\nconst RE_CS_ECDH =\n /\\bECDiffieHellman\\.Create\\s*\\(|\\bnew\\s+ECDiffieHellmanCng\\s*\\(|\\bnew\\s+ECDiffieHellmanOpenSsl\\s*\\(/g;\nconst RE_CS_DSA = /\\bDSA\\.Create\\s*\\(|\\bnew\\s+DSACryptoServiceProvider\\s*\\(|\\bnew\\s+DSACng\\s*\\(/g;\n// Insecure TLS configuration (.NET). Mirrors source.ts's tlsDetector split of a\n// cert-verification-disabled rule (tls-reject-unauthorized) and a legacy-version\n// rule (tls-legacy-version) for the equivalent C# idioms:\n// - DangerousAcceptAnyServerCertificateValidator / a custom\n// ServerCertificateCustomValidationCallback → accepts any cert (MITM).\n// - SslProtocols.Ssl3 / .Tls / .Tls11 → deprecated SSL 3.0 / TLS 1.0 / 1.1.\n// `SslProtocols.Tls` (no suffix) is the legacy TLS 1.0 constant; `Tls12`/`Tls13`\n// are excluded by the trailing \\b (the following digit is a word char).\nconst RE_CS_TLS_CERT_VALIDATION =\n /\\bDangerousAcceptAnyServerCertificateValidator\\b|ServerCertificateCustomValidationCallback\\s*=/g;\nconst RE_CS_TLS_LEGACY_VERSION = /\\bSslProtocols\\.(?:Tls|Tls11|Ssl3)\\b/g;\n// Identifier-form JWT/JOSE signature algorithms (audit F7). The quoted-string\n// alg token (\"RS256\") is caught by the language-agnostic jwt-jose detector, but\n// Microsoft.IdentityModel passes the alg as an IDENTIFIER, not a string literal:\n// SecurityAlgorithms.RsaSha256 / SecurityAlgorithms.EcdsaSha256.\nconst RE_CS_JWT_ALG = /\\bSecurityAlgorithms\\.(?:Rsa|Ecdsa)Sha(?:256|384|512)\\b/g;\n// BouncyCastle (Org.BouncyCastle) modern-curve and finite-field DH primitives,\n// which System.Security.Cryptography does not expose directly. Each regex is\n// anchored to the distinctive BouncyCastle class names for one family so it\n// can't misfire on unrelated identifiers:\n// - Ed25519KeyPairGenerator / Ed25519Signer / Ed25519PrivateKeyParameters → EdDSA\n// - X25519KeyPairGenerator / X25519Agreement / X25519PrivateKeyParameters → X25519\n// - X448KeyPairGenerator / X448Agreement / X448PrivateKeyParameters → X448\n// - DHParametersGenerator / DHBasicAgreement / DH(Basic)KeyPairGenerator / DHParameters → DH\n// The trailing \\b keeps each token whole (e.g. Ed25519KeyGenerationParameters,\n// X25519PublicKeyParameters and DHKeyGenerationParameters are NOT matched).\nconst RE_CS_BC_EDDSA = /\\bEd25519(?:KeyPairGenerator|Signer|PrivateKeyParameters)\\b/g;\nconst RE_CS_BC_X25519 = /\\bX25519(?:KeyPairGenerator|Agreement|PrivateKeyParameters)\\b/g;\nconst RE_CS_BC_X448 = /\\bX448(?:KeyPairGenerator|Agreement|PrivateKeyParameters)\\b/g;\nconst RE_CS_BC_DH =\n /\\bDH(?:ParametersGenerator|BasicAgreement|BasicKeyPairGenerator|KeyPairGenerator|Parameters)\\b/g;\n\nconst RULE_CS_RSA: RuleMeta = {\n id: \"csharp-rsa\",\n title: \"C# RSA key/usage\",\n description: \"System.Security.Cryptography RSA.Create / RSACryptoServiceProvider / RSACng\",\n category: \"kem\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"RSA\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"Classical RSA (.NET) is not quantum-safe and RSA encryption is HNDL-exposed.\",\n};\nconst RULE_CS_ECDSA: RuleMeta = {\n id: \"csharp-ecdsa\",\n title: \"C# ECDSA signature\",\n description: \"System.Security.Cryptography ECDsa.Create / ECDsaCng\",\n category: \"signature\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"ECDSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"Classical ECDSA signing (.NET) is forgeable by a quantum attacker.\",\n remediation: \"ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)\",\n};\nconst RULE_CS_ECDH: RuleMeta = {\n id: \"csharp-ecdh\",\n title: \"C# ECDH key agreement\",\n description: \"System.Security.Cryptography ECDiffieHellman.Create / ECDiffieHellmanCng\",\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 (.NET) is broken by Shor's algorithm (harvest-now-decrypt-later).\",\n};\nconst RULE_CS_DSA: RuleMeta = {\n id: \"csharp-dsa\",\n title: \"C# DSA key/signature\",\n description: \"System.Security.Cryptography DSA.Create / DSACryptoServiceProvider\",\n category: \"signature\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"DSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"Classical DSA (.NET) is deprecated and forgeable by a quantum attacker.\",\n remediation: \"Rotate off DSA and migrate to ML-DSA-65 (FIPS 204).\",\n};\nconst RULE_CS_TLS_CERT: RuleMeta = {\n id: \"csharp-tls-cert-validation\",\n title: \"C# TLS certificate verification disabled\",\n description:\n \"DangerousAcceptAnyServerCertificateValidator / ServerCertificateCustomValidationCallback override\",\n category: \"tls\",\n severity: \"high\",\n confidence: \"high\",\n hndl: false,\n cwe: CWE_CERT_VALIDATION,\n message: \"Accepting any server certificate disables TLS certificate verification (MITM risk).\",\n remediation:\n \"Remove the custom validator and verify certificates properly; prefer PQC-hybrid key exchange.\",\n};\nconst RULE_CS_TLS_LEGACY: RuleMeta = {\n id: \"csharp-tls-legacy-version\",\n title: \"C# legacy TLS/SSL version pinned\",\n description: \"SslProtocols pinned to Ssl3 / TLS 1.0 / TLS 1.1\",\n category: \"tls\",\n severity: \"medium\",\n confidence: \"high\",\n hndl: false,\n cwe: CWE_WEAK_STRENGTH,\n message:\n \"SSL 3.0 / TLS 1.0 / TLS 1.1 are deprecated and insecure; require TLS 1.2+ (prefer 1.3).\",\n remediation: \"Use SslProtocols.Tls13 (or Tls12) and prefer PQC-hybrid key exchange.\",\n};\nconst RULE_CS_JWT_ALG: RuleMeta = {\n id: \"csharp-jwt-alg\",\n title: \"C# identifier-form JWT/JOSE algorithm\",\n description: \"Microsoft.IdentityModel SecurityAlgorithms.RsaSha* / EcdsaSha*\",\n category: \"signature\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"unknown\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"A classical JWT/JOSE signature algorithm (.NET, identifier form) is used, forgeable by a quantum attacker.\",\n remediation: \"ML-DSA-65 (FIPS 204); track IETF PQC JOSE/COSE algorithms\",\n};\nconst RULE_CS_BC_EDDSA: RuleMeta = {\n id: \"csharp-bouncycastle-eddsa\",\n title: \"C# Ed25519 signature (BouncyCastle)\",\n description:\n \"Org.BouncyCastle Ed25519KeyPairGenerator / Ed25519Signer / Ed25519PrivateKeyParameters\",\n category: \"signature\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"EdDSA\",\n hndl: false,\n cwe: CWE_BROKEN_CRYPTO,\n message: \"Classical Ed25519 signing (BouncyCastle) is forgeable by a quantum attacker.\",\n remediation: \"ML-DSA-65 (FIPS 204) or SLH-DSA (FIPS 205)\",\n};\nconst RULE_CS_BC_X25519: RuleMeta = {\n id: \"csharp-bouncycastle-x25519\",\n title: \"C# X25519 key agreement (BouncyCastle)\",\n description:\n \"Org.BouncyCastle X25519KeyPairGenerator / X25519Agreement / X25519PrivateKeyParameters\",\n category: \"key-exchange\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"X25519\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"X25519 Diffie-Hellman key agreement (BouncyCastle) is broken by Shor's algorithm (harvest-now-decrypt-later).\",\n};\nconst RULE_CS_BC_X448: RuleMeta = {\n id: \"csharp-bouncycastle-x448\",\n title: \"C# X448 key agreement (BouncyCastle)\",\n description: \"Org.BouncyCastle X448KeyPairGenerator / X448Agreement / X448PrivateKeyParameters\",\n category: \"key-exchange\",\n severity: \"high\",\n confidence: \"high\",\n algorithm: \"X448\",\n hndl: true,\n cwe: CWE_BROKEN_CRYPTO,\n message:\n \"X448 Diffie-Hellman key agreement (BouncyCastle) is broken by Shor's algorithm (harvest-now-decrypt-later).\",\n};\nconst RULE_CS_BC_DH: RuleMeta = {\n id: \"csharp-bouncycastle-dh\",\n title: \"C# finite-field Diffie-Hellman (BouncyCastle)\",\n description:\n \"Org.BouncyCastle DHParametersGenerator / DHBasicAgreement / DHKeyPairGenerator / DHParameters\",\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 (BouncyCastle) is broken by Shor's algorithm (harvest-now-decrypt-later).\",\n};\n\n/** Detects classical asymmetric crypto in C# (System.Security.Cryptography). */\nexport const csharpDetector: Detector = {\n id: \"csharp-crypto\",\n description:\n \"Classical asymmetric crypto (System.Security.Cryptography) and insecure TLS config in C#/.NET\",\n scope: \"source\",\n language: \"csharp\",\n rules: [\n RULE_CS_RSA,\n RULE_CS_ECDSA,\n RULE_CS_ECDH,\n RULE_CS_DSA,\n RULE_CS_TLS_CERT,\n RULE_CS_TLS_LEGACY,\n RULE_CS_JWT_ALG,\n RULE_CS_BC_EDDSA,\n RULE_CS_BC_X25519,\n RULE_CS_BC_X448,\n RULE_CS_BC_DH,\n ],\n appliesTo: (f) => hasExtension(f, CSHARP_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 // ECDSA / ECDH before RSA/DSA so the specific EC factories win.\n add(RE_CS_ECDSA, RULE_CS_ECDSA);\n add(RE_CS_ECDH, RULE_CS_ECDH);\n add(RE_CS_RSA, RULE_CS_RSA);\n add(RE_CS_DSA, RULE_CS_DSA);\n // Insecure TLS configuration (disjoint from the crypto factories above).\n add(RE_CS_TLS_CERT_VALIDATION, RULE_CS_TLS_CERT);\n add(RE_CS_TLS_LEGACY_VERSION, RULE_CS_TLS_LEGACY);\n // Identifier-form JWT/JOSE signature algorithms (Microsoft.IdentityModel).\n add(RE_CS_JWT_ALG, RULE_CS_JWT_ALG);\n // BouncyCastle (Org.BouncyCastle) curve / finite-field DH primitives that\n // System.Security.Cryptography does not expose directly.\n add(RE_CS_BC_EDDSA, RULE_CS_BC_EDDSA);\n add(RE_CS_BC_X25519, RULE_CS_BC_X25519);\n add(RE_CS_BC_X448, RULE_CS_BC_X448);\n add(RE_CS_BC_DH, RULE_CS_BC_DH);\n return findings;\n },\n};\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config detector: classical crypto in database usage — public-key encryption of
|
|
3
|
+
* stored data (pgcrypto) and weak client TLS posture. Data-at-rest is the sharpest
|
|
4
|
+
* harvest-now-decrypt-later target: a column encrypted to an RSA key today is a
|
|
5
|
+
* time capsule an adversary can hold until key recovery is cheap.
|
|
6
|
+
*
|
|
7
|
+
* Covered:
|
|
8
|
+
* - pgcrypto `pgp_pub_encrypt` / `pgp_pub_decrypt` in `.sql` (RSA/ElGamal public-key
|
|
9
|
+
* encryption of column data) → `hndl:true`.
|
|
10
|
+
* - libpq `sslmode = disable | allow | prefer | require` in any config/connection
|
|
11
|
+
* file — a mode that does NOT verify the server certificate, so the classical
|
|
12
|
+
* TLS session it does (or doesn't) negotiate is both MITM-able and harvestable.
|
|
13
|
+
*/
|
|
14
|
+
import type { Detector } from "../types.js";
|
|
15
|
+
/** Detects classical database at-rest / transport crypto. */
|
|
16
|
+
export declare const databaseDetector: Detector;
|
|
17
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/detectors/database.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,aAAa,CAAC;AAqC/D,6DAA6D;AAC7D,eAAO,MAAM,gBAAgB,EAAE,QAoC9B,CAAC"}
|