@hardkeel/benthic 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +121 -0
- package/LICENSE +92 -0
- package/NOTICE +16 -0
- package/README.md +424 -2
- package/action.yml +54 -0
- package/dist/agility.js +80 -0
- package/dist/badge.js +62 -0
- package/dist/baseline.js +81 -0
- package/dist/cbom-diff.js +273 -0
- package/dist/cbom.js +418 -0
- package/dist/cli.js +834 -0
- package/dist/cloud-aws-services.js +375 -0
- package/dist/cloud-aws.js +354 -0
- package/dist/cloud-azure-services.js +73 -0
- package/dist/cloud-azure.js +144 -0
- package/dist/cloud-common.js +242 -0
- package/dist/cloud-gcp-services.js +90 -0
- package/dist/cloud-gcp.js +150 -0
- package/dist/comments.js +138 -0
- package/dist/community-rules.js +37 -0
- package/dist/community.js +30 -0
- package/dist/deps.js +406 -0
- package/dist/der.js +571 -0
- package/dist/evidence-cli.js +235 -0
- package/dist/evidence-live.js +109 -0
- package/dist/evidence.js +512 -0
- package/dist/ignore.js +90 -0
- package/dist/image.js +1224 -0
- package/dist/infra.js +635 -0
- package/dist/inventory.js +277 -0
- package/dist/map-activity.js +24 -0
- package/dist/map-areas.js +60 -0
- package/dist/map-cloud-keys.js +110 -0
- package/dist/map-cloud.js +34 -0
- package/dist/map-ct.js +107 -0
- package/dist/map-host.js +335 -0
- package/dist/map-network.js +520 -0
- package/dist/map-people.js +79 -0
- package/dist/map-rank.js +70 -0
- package/dist/map-report.js +304 -0
- package/dist/map-run.js +327 -0
- package/dist/map-sarif.js +61 -0
- package/dist/map-signin.js +247 -0
- package/dist/map-types.js +19 -0
- package/dist/map-web.js +666 -0
- package/dist/native.js +168 -0
- package/dist/policy.js +221 -0
- package/dist/pqc.js +46 -0
- package/dist/profile.js +65 -0
- package/dist/project.js +928 -0
- package/dist/prose.js +159 -0
- package/dist/protocols.js +207 -0
- package/dist/registry.js +326 -0
- package/dist/report.js +190 -0
- package/dist/rules.js +230 -0
- package/dist/sarif-common.js +30 -0
- package/dist/sarif.js +114 -0
- package/dist/scan.js +601 -0
- package/dist/score.js +124 -0
- package/dist/secrets.js +192 -0
- package/dist/share-config.js +129 -0
- package/dist/share-lists.js +19 -0
- package/dist/share.js +125 -0
- package/dist/sonar.js +83 -0
- package/dist/structure.js +218 -0
- package/dist/suites.js +402 -0
- package/dist/tls-check.js +122 -0
- package/dist/types.js +4 -0
- package/dist/walk.js +78 -0
- package/dist/yaml.js +173 -0
- package/package.json +73 -4
package/dist/suites.js
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
// SPDX-License-Identifier: PolyForm-Shield-1.0.0
|
|
2
|
+
// Copyright 2026 Hard Keel (https://hardkeel.com)
|
|
3
|
+
// TLS cipher suites and protocol versions: a maintained table of the suites in common use, an
|
|
4
|
+
// expander for OpenSSL cipher strings ("HIGH:!aNULL:!MD5"), and the suite lists of named cloud
|
|
5
|
+
// load balancer policies. Turns one config line into the list of suites it actually enables, so the
|
|
6
|
+
// inventory can list every suite in use, the good ones as well as the ones to fix.
|
|
7
|
+
// iana | openssl | code | kx | au | enc | bits | mac | min
|
|
8
|
+
const RAW = `
|
|
9
|
+
TLS_AES_128_GCM_SHA256|TLS_AES_128_GCM_SHA256|1301|any|any|AES128-GCM|128|AEAD|1.3
|
|
10
|
+
TLS_AES_256_GCM_SHA384|TLS_AES_256_GCM_SHA384|1302|any|any|AES256-GCM|256|AEAD|1.3
|
|
11
|
+
TLS_CHACHA20_POLY1305_SHA256|TLS_CHACHA20_POLY1305_SHA256|1303|any|any|CHACHA20|256|AEAD|1.3
|
|
12
|
+
TLS_AES_128_CCM_SHA256|TLS_AES_128_CCM_SHA256|1304|any|any|AES128-CCM|128|AEAD|1.3
|
|
13
|
+
TLS_AES_128_CCM_8_SHA256|TLS_AES_128_CCM_8_SHA256|1305|any|any|AES128-CCM8|128|AEAD|1.3
|
|
14
|
+
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384|ECDHE-ECDSA-AES256-GCM-SHA384|C02C|ECDHE|ECDSA|AES256-GCM|256|AEAD|1.2
|
|
15
|
+
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384|ECDHE-RSA-AES256-GCM-SHA384|C030|ECDHE|RSA|AES256-GCM|256|AEAD|1.2
|
|
16
|
+
TLS_DHE_DSS_WITH_AES_256_GCM_SHA384|DHE-DSS-AES256-GCM-SHA384|00A3|DHE|DSS|AES256-GCM|256|AEAD|1.2
|
|
17
|
+
TLS_DHE_RSA_WITH_AES_256_GCM_SHA384|DHE-RSA-AES256-GCM-SHA384|009F|DHE|RSA|AES256-GCM|256|AEAD|1.2
|
|
18
|
+
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256|ECDHE-ECDSA-CHACHA20-POLY1305|CCA9|ECDHE|ECDSA|CHACHA20|256|AEAD|1.2
|
|
19
|
+
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256|ECDHE-RSA-CHACHA20-POLY1305|CCA8|ECDHE|RSA|CHACHA20|256|AEAD|1.2
|
|
20
|
+
TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256|DHE-RSA-CHACHA20-POLY1305|CCAA|DHE|RSA|CHACHA20|256|AEAD|1.2
|
|
21
|
+
TLS_ECDHE_ECDSA_WITH_AES_256_CCM|ECDHE-ECDSA-AES256-CCM|C0AD|ECDHE|ECDSA|AES256-CCM|256|AEAD|1.2
|
|
22
|
+
TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8|ECDHE-ECDSA-AES256-CCM8|C0AF|ECDHE|ECDSA|AES256-CCM8|256|AEAD|1.2
|
|
23
|
+
TLS_DHE_RSA_WITH_AES_256_CCM|DHE-RSA-AES256-CCM|C09F|DHE|RSA|AES256-CCM|256|AEAD|1.2
|
|
24
|
+
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256|ECDHE-ECDSA-AES128-GCM-SHA256|C02B|ECDHE|ECDSA|AES128-GCM|128|AEAD|1.2
|
|
25
|
+
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256|ECDHE-RSA-AES128-GCM-SHA256|C02F|ECDHE|RSA|AES128-GCM|128|AEAD|1.2
|
|
26
|
+
TLS_DHE_DSS_WITH_AES_128_GCM_SHA256|DHE-DSS-AES128-GCM-SHA256|00A2|DHE|DSS|AES128-GCM|128|AEAD|1.2
|
|
27
|
+
TLS_DHE_RSA_WITH_AES_128_GCM_SHA256|DHE-RSA-AES128-GCM-SHA256|009E|DHE|RSA|AES128-GCM|128|AEAD|1.2
|
|
28
|
+
TLS_ECDHE_ECDSA_WITH_AES_128_CCM|ECDHE-ECDSA-AES128-CCM|C0AC|ECDHE|ECDSA|AES128-CCM|128|AEAD|1.2
|
|
29
|
+
TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8|ECDHE-ECDSA-AES128-CCM8|C0AE|ECDHE|ECDSA|AES128-CCM8|128|AEAD|1.2
|
|
30
|
+
TLS_DHE_RSA_WITH_AES_128_CCM|DHE-RSA-AES128-CCM|C09E|DHE|RSA|AES128-CCM|128|AEAD|1.2
|
|
31
|
+
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384|ECDHE-ECDSA-AES256-SHA384|C024|ECDHE|ECDSA|AES256-CBC|256|SHA384|1.2
|
|
32
|
+
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384|ECDHE-RSA-AES256-SHA384|C028|ECDHE|RSA|AES256-CBC|256|SHA384|1.2
|
|
33
|
+
TLS_DHE_RSA_WITH_AES_256_CBC_SHA256|DHE-RSA-AES256-SHA256|006B|DHE|RSA|AES256-CBC|256|SHA256|1.2
|
|
34
|
+
TLS_DHE_DSS_WITH_AES_256_CBC_SHA256|DHE-DSS-AES256-SHA256|006A|DHE|DSS|AES256-CBC|256|SHA256|1.2
|
|
35
|
+
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256|ECDHE-ECDSA-AES128-SHA256|C023|ECDHE|ECDSA|AES128-CBC|128|SHA256|1.2
|
|
36
|
+
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256|ECDHE-RSA-AES128-SHA256|C027|ECDHE|RSA|AES128-CBC|128|SHA256|1.2
|
|
37
|
+
TLS_DHE_RSA_WITH_AES_128_CBC_SHA256|DHE-RSA-AES128-SHA256|0067|DHE|RSA|AES128-CBC|128|SHA256|1.2
|
|
38
|
+
TLS_DHE_DSS_WITH_AES_128_CBC_SHA256|DHE-DSS-AES128-SHA256|0040|DHE|DSS|AES128-CBC|128|SHA256|1.2
|
|
39
|
+
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA|ECDHE-ECDSA-AES256-SHA|C00A|ECDHE|ECDSA|AES256-CBC|256|SHA1|1.0
|
|
40
|
+
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA|ECDHE-RSA-AES256-SHA|C014|ECDHE|RSA|AES256-CBC|256|SHA1|1.0
|
|
41
|
+
TLS_DHE_RSA_WITH_AES_256_CBC_SHA|DHE-RSA-AES256-SHA|0039|DHE|RSA|AES256-CBC|256|SHA1|1.0
|
|
42
|
+
TLS_DHE_DSS_WITH_AES_256_CBC_SHA|DHE-DSS-AES256-SHA|0038|DHE|DSS|AES256-CBC|256|SHA1|1.0
|
|
43
|
+
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA|ECDHE-ECDSA-AES128-SHA|C009|ECDHE|ECDSA|AES128-CBC|128|SHA1|1.0
|
|
44
|
+
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA|ECDHE-RSA-AES128-SHA|C013|ECDHE|RSA|AES128-CBC|128|SHA1|1.0
|
|
45
|
+
TLS_DHE_RSA_WITH_AES_128_CBC_SHA|DHE-RSA-AES128-SHA|0033|DHE|RSA|AES128-CBC|128|SHA1|1.0
|
|
46
|
+
TLS_DHE_DSS_WITH_AES_128_CBC_SHA|DHE-DSS-AES128-SHA|0032|DHE|DSS|AES128-CBC|128|SHA1|1.0
|
|
47
|
+
TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA|DHE-RSA-CAMELLIA256-SHA|0088|DHE|RSA|CAMELLIA256|256|SHA1|1.0
|
|
48
|
+
TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA|DHE-RSA-CAMELLIA128-SHA|0045|DHE|RSA|CAMELLIA128|128|SHA1|1.0
|
|
49
|
+
TLS_RSA_WITH_AES_256_GCM_SHA384|AES256-GCM-SHA384|009D|RSA|RSA|AES256-GCM|256|AEAD|1.2
|
|
50
|
+
TLS_RSA_WITH_AES_128_GCM_SHA256|AES128-GCM-SHA256|009C|RSA|RSA|AES128-GCM|128|AEAD|1.2
|
|
51
|
+
TLS_RSA_WITH_AES_256_CCM|AES256-CCM|C09D|RSA|RSA|AES256-CCM|256|AEAD|1.2
|
|
52
|
+
TLS_RSA_WITH_AES_128_CCM|AES128-CCM|C09C|RSA|RSA|AES128-CCM|128|AEAD|1.2
|
|
53
|
+
TLS_RSA_WITH_AES_256_CBC_SHA256|AES256-SHA256|003D|RSA|RSA|AES256-CBC|256|SHA256|1.2
|
|
54
|
+
TLS_RSA_WITH_AES_128_CBC_SHA256|AES128-SHA256|003C|RSA|RSA|AES128-CBC|128|SHA256|1.2
|
|
55
|
+
TLS_RSA_WITH_AES_256_CBC_SHA|AES256-SHA|0035|RSA|RSA|AES256-CBC|256|SHA1|1.0
|
|
56
|
+
TLS_RSA_WITH_AES_128_CBC_SHA|AES128-SHA|002F|RSA|RSA|AES128-CBC|128|SHA1|1.0
|
|
57
|
+
TLS_RSA_WITH_CAMELLIA_256_CBC_SHA|CAMELLIA256-SHA|0084|RSA|RSA|CAMELLIA256|256|SHA1|1.0
|
|
58
|
+
TLS_RSA_WITH_CAMELLIA_128_CBC_SHA|CAMELLIA128-SHA|0041|RSA|RSA|CAMELLIA128|128|SHA1|1.0
|
|
59
|
+
TLS_RSA_WITH_SEED_CBC_SHA|SEED-SHA|0096|RSA|RSA|SEED|128|SHA1|1.0
|
|
60
|
+
TLS_RSA_WITH_IDEA_CBC_SHA|IDEA-CBC-SHA|0007|RSA|RSA|IDEA|128|SHA1|1.0
|
|
61
|
+
TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA|ECDHE-ECDSA-DES-CBC3-SHA|C008|ECDHE|ECDSA|3DES|112|SHA1|1.0
|
|
62
|
+
TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA|ECDHE-RSA-DES-CBC3-SHA|C012|ECDHE|RSA|3DES|112|SHA1|1.0
|
|
63
|
+
TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA|EDH-RSA-DES-CBC3-SHA|0016|DHE|RSA|3DES|112|SHA1|1.0
|
|
64
|
+
TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA|EDH-DSS-DES-CBC3-SHA|0013|DHE|DSS|3DES|112|SHA1|1.0
|
|
65
|
+
TLS_RSA_WITH_3DES_EDE_CBC_SHA|DES-CBC3-SHA|000A|RSA|RSA|3DES|112|SHA1|1.0
|
|
66
|
+
TLS_ECDHE_ECDSA_WITH_RC4_128_SHA|ECDHE-ECDSA-RC4-SHA|C007|ECDHE|ECDSA|RC4|128|SHA1|1.0
|
|
67
|
+
TLS_ECDHE_RSA_WITH_RC4_128_SHA|ECDHE-RSA-RC4-SHA|C011|ECDHE|RSA|RC4|128|SHA1|1.0
|
|
68
|
+
TLS_RSA_WITH_RC4_128_SHA|RC4-SHA|0005|RSA|RSA|RC4|128|SHA1|1.0
|
|
69
|
+
TLS_RSA_WITH_RC4_128_MD5|RC4-MD5|0004|RSA|RSA|RC4|128|MD5|1.0
|
|
70
|
+
TLS_DH_anon_WITH_AES_256_GCM_SHA384|ADH-AES256-GCM-SHA384|00A7|DHE|none|AES256-GCM|256|AEAD|1.2
|
|
71
|
+
TLS_DH_anon_WITH_AES_128_GCM_SHA256|ADH-AES128-GCM-SHA256|00A6|DHE|none|AES128-GCM|128|AEAD|1.2
|
|
72
|
+
TLS_DH_anon_WITH_AES_256_CBC_SHA|ADH-AES256-SHA|003A|DHE|none|AES256-CBC|256|SHA1|1.0
|
|
73
|
+
TLS_DH_anon_WITH_AES_128_CBC_SHA|ADH-AES128-SHA|0034|DHE|none|AES128-CBC|128|SHA1|1.0
|
|
74
|
+
TLS_ECDH_anon_WITH_AES_256_CBC_SHA|AECDH-AES256-SHA|C019|ECDHE|none|AES256-CBC|256|SHA1|1.0
|
|
75
|
+
TLS_ECDH_anon_WITH_AES_128_CBC_SHA|AECDH-AES128-SHA|C018|ECDHE|none|AES128-CBC|128|SHA1|1.0
|
|
76
|
+
TLS_DH_anon_WITH_3DES_EDE_CBC_SHA|ADH-DES-CBC3-SHA|001B|DHE|none|3DES|112|SHA1|1.0
|
|
77
|
+
TLS_DH_anon_WITH_RC4_128_MD5|ADH-RC4-MD5|0018|DHE|none|RC4|128|MD5|1.0
|
|
78
|
+
TLS_PSK_WITH_AES_256_GCM_SHA384|PSK-AES256-GCM-SHA384|00A9|PSK|none|AES256-GCM|256|AEAD|1.2
|
|
79
|
+
TLS_PSK_WITH_AES_128_GCM_SHA256|PSK-AES128-GCM-SHA256|00A8|PSK|none|AES128-GCM|128|AEAD|1.2
|
|
80
|
+
TLS_RSA_WITH_NULL_SHA256|NULL-SHA256|003B|RSA|RSA|NULL|0|SHA256|1.2
|
|
81
|
+
TLS_RSA_WITH_NULL_SHA|NULL-SHA|0002|RSA|RSA|NULL|0|SHA1|1.0
|
|
82
|
+
TLS_RSA_WITH_NULL_MD5|NULL-MD5|0001|RSA|RSA|NULL|0|MD5|1.0
|
|
83
|
+
`;
|
|
84
|
+
export const SUITES = RAW.trim()
|
|
85
|
+
.split("\n")
|
|
86
|
+
.map((l) => {
|
|
87
|
+
const [iana, openssl, code, kx, au, enc, bits, mac, min] = l.split("|");
|
|
88
|
+
return { iana, openssl, code: parseInt(code, 16), kx: kx, au: au, enc: enc, bits: Number(bits), mac: mac, min: min };
|
|
89
|
+
});
|
|
90
|
+
const BY_NAME = new Map();
|
|
91
|
+
for (const s of SUITES) {
|
|
92
|
+
BY_NAME.set(s.openssl.toUpperCase(), s);
|
|
93
|
+
BY_NAME.set(s.iana.toUpperCase(), s);
|
|
94
|
+
}
|
|
95
|
+
// Other spellings in common use: SSL_ prefixes (Java), and OpenSSL's own aliases.
|
|
96
|
+
for (const [alias, name] of [
|
|
97
|
+
["DHE-RSA-DES-CBC3-SHA", "EDH-RSA-DES-CBC3-SHA"],
|
|
98
|
+
["DHE-DSS-DES-CBC3-SHA", "EDH-DSS-DES-CBC3-SHA"],
|
|
99
|
+
])
|
|
100
|
+
BY_NAME.set(alias, BY_NAME.get(name));
|
|
101
|
+
/** A suite by its OpenSSL name, IANA name, Java SSL_ name or hex code ("0xC02F"). */
|
|
102
|
+
export function suiteByName(name) {
|
|
103
|
+
const n = name.trim().toUpperCase();
|
|
104
|
+
if (/^0X[0-9A-F]{4}$/.test(n))
|
|
105
|
+
return SUITES.find((s) => s.code === parseInt(n.slice(2), 16));
|
|
106
|
+
return BY_NAME.get(n) ?? BY_NAME.get(n.replace(/^SSL_/, "TLS_"));
|
|
107
|
+
}
|
|
108
|
+
export const TLS13_DEFAULT = ["TLS_AES_256_GCM_SHA384", "TLS_CHACHA20_POLY1305_SHA256", "TLS_AES_128_GCM_SHA256"];
|
|
109
|
+
// ---------- OpenSSL cipher strings ----------
|
|
110
|
+
const strength = (s) => (s.enc === "NULL" ? "NONE" : s.enc === "3DES" || s.enc === "RC4" || s.enc === "SEED" || s.enc === "IDEA" ? "MEDIUM" : "HIGH");
|
|
111
|
+
/** What one OpenSSL cipher-list word selects. TLS 1.3 suites are configured apart (Ciphersuites) and never match. */
|
|
112
|
+
function aliasMatch(word) {
|
|
113
|
+
const w = word.toUpperCase();
|
|
114
|
+
const tls12 = (f) => (s) => s.min !== "1.3" && f(s);
|
|
115
|
+
const table = {
|
|
116
|
+
ALL: (s) => s.enc !== "NULL" && s.kx !== "PSK",
|
|
117
|
+
DEFAULT: (s) => s.enc !== "NULL" && s.au !== "none" && s.kx !== "PSK" && strength(s) === "HIGH",
|
|
118
|
+
COMPLEMENTOFDEFAULT: (s) => s.enc !== "NULL" && (s.au === "none" || strength(s) !== "HIGH"),
|
|
119
|
+
COMPLEMENTOFALL: (s) => s.enc === "NULL",
|
|
120
|
+
// OpenSSL counts PSK suites as HIGH, but a server negotiates them only with a pre-shared key set up, so a
|
|
121
|
+
// plain HIGH list doesn't put them in use. Name PSK or kPSK to list them.
|
|
122
|
+
HIGH: (s) => strength(s) === "HIGH" && s.kx !== "PSK",
|
|
123
|
+
MEDIUM: (s) => strength(s) === "MEDIUM" && s.kx !== "PSK",
|
|
124
|
+
LOW: () => false,
|
|
125
|
+
EXPORT: () => false,
|
|
126
|
+
EXP: () => false,
|
|
127
|
+
EXPORT40: () => false,
|
|
128
|
+
EXPORT56: () => false,
|
|
129
|
+
ENULL: (s) => s.enc === "NULL",
|
|
130
|
+
NULL: (s) => s.enc === "NULL",
|
|
131
|
+
ANULL: (s) => s.au === "none" && s.kx !== "PSK",
|
|
132
|
+
KRSA: (s) => s.kx === "RSA",
|
|
133
|
+
RSA: (s) => s.kx === "RSA",
|
|
134
|
+
ARSA: (s) => s.au === "RSA",
|
|
135
|
+
KEECDH: (s) => s.kx === "ECDHE",
|
|
136
|
+
KECDHE: (s) => s.kx === "ECDHE",
|
|
137
|
+
ECDHE: (s) => s.kx === "ECDHE" && s.au !== "none",
|
|
138
|
+
EECDH: (s) => s.kx === "ECDHE" && s.au !== "none",
|
|
139
|
+
ECDH: (s) => s.kx === "ECDHE",
|
|
140
|
+
AECDH: (s) => s.kx === "ECDHE" && s.au === "none",
|
|
141
|
+
KEDH: (s) => s.kx === "DHE",
|
|
142
|
+
KDHE: (s) => s.kx === "DHE",
|
|
143
|
+
DHE: (s) => s.kx === "DHE" && s.au !== "none",
|
|
144
|
+
EDH: (s) => s.kx === "DHE" && s.au !== "none",
|
|
145
|
+
DH: (s) => s.kx === "DHE",
|
|
146
|
+
ADH: (s) => s.kx === "DHE" && s.au === "none",
|
|
147
|
+
AECDSA: (s) => s.au === "ECDSA",
|
|
148
|
+
ECDSA: (s) => s.au === "ECDSA",
|
|
149
|
+
ADSS: (s) => s.au === "DSS",
|
|
150
|
+
DSS: (s) => s.au === "DSS",
|
|
151
|
+
KPSK: (s) => s.kx === "PSK",
|
|
152
|
+
PSK: (s) => s.kx === "PSK",
|
|
153
|
+
SRP: () => false,
|
|
154
|
+
AES: (s) => s.enc.startsWith("AES"),
|
|
155
|
+
AES128: (s) => s.enc.startsWith("AES128"),
|
|
156
|
+
AES256: (s) => s.enc.startsWith("AES256"),
|
|
157
|
+
AESGCM: (s) => s.enc.endsWith("-GCM"),
|
|
158
|
+
AESCCM: (s) => /-CCM8?$/.test(s.enc),
|
|
159
|
+
AESCCM8: (s) => s.enc.endsWith("-CCM8"),
|
|
160
|
+
CHACHA20: (s) => s.enc === "CHACHA20",
|
|
161
|
+
CAMELLIA: (s) => s.enc.startsWith("CAMELLIA"),
|
|
162
|
+
CAMELLIA128: (s) => s.enc === "CAMELLIA128",
|
|
163
|
+
CAMELLIA256: (s) => s.enc === "CAMELLIA256",
|
|
164
|
+
"3DES": (s) => s.enc === "3DES",
|
|
165
|
+
DES: () => false,
|
|
166
|
+
RC4: (s) => s.enc === "RC4",
|
|
167
|
+
SEED: (s) => s.enc === "SEED",
|
|
168
|
+
IDEA: (s) => s.enc === "IDEA",
|
|
169
|
+
MD5: (s) => s.mac === "MD5",
|
|
170
|
+
SHA1: (s) => s.mac === "SHA1",
|
|
171
|
+
SHA: (s) => s.mac === "SHA1",
|
|
172
|
+
SHA256: (s) => s.mac === "SHA256" || (s.mac === "AEAD" && !/SHA384$/.test(s.iana)),
|
|
173
|
+
SHA384: (s) => s.mac === "SHA384" || /SHA384$/.test(s.iana),
|
|
174
|
+
"TLSV1.2": (s) => s.min === "1.2",
|
|
175
|
+
TLSV1: (s) => s.min === "1.0",
|
|
176
|
+
SSLV3: (s) => s.min === "1.0",
|
|
177
|
+
FIPS: (s) => s.enc.startsWith("AES") && s.au !== "none" && s.mac !== "MD5",
|
|
178
|
+
};
|
|
179
|
+
const f = table[w];
|
|
180
|
+
if (f)
|
|
181
|
+
return tls12(f);
|
|
182
|
+
const one = suiteByName(word);
|
|
183
|
+
if (one && one.min !== "1.3")
|
|
184
|
+
return (s) => s === one;
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The TLS 1.2 and earlier suites an OpenSSL cipher string enables, in the order OpenSSL would list them,
|
|
189
|
+
* following its rules: plain words add, "-" removes, "!" removes for good, "+" moves to the end, words
|
|
190
|
+
* joined with "+" must all match, @STRENGTH sorts by key length, @SECLEVEL drops what a level forbids.
|
|
191
|
+
* Weak suites a string asks for are kept even though OpenSSL 1.1.0 and later builds leave RC4 and some
|
|
192
|
+
* 3DES suites out: the string still asks for them, and an older library will serve them.
|
|
193
|
+
*/
|
|
194
|
+
export function expandCipherString(str) {
|
|
195
|
+
let list = [];
|
|
196
|
+
const killed = new Set();
|
|
197
|
+
const unknown = [];
|
|
198
|
+
let secLevel;
|
|
199
|
+
const words = str.replace(/["']/g, "").split(/[:,\s]+/).filter(Boolean);
|
|
200
|
+
for (const raw of words) {
|
|
201
|
+
const op = /^[!+-]/.test(raw) ? raw[0] : "";
|
|
202
|
+
const word = op ? raw.slice(1) : raw;
|
|
203
|
+
const up = word.toUpperCase();
|
|
204
|
+
// @STRENGHT is a common slip for @STRENGTH; OpenSSL rejects the whole string over it, which leaves the
|
|
205
|
+
// server on its defaults. Read it the way the person meant it.
|
|
206
|
+
if (up === "@STRENGTH" || up === "@STRENGHT") {
|
|
207
|
+
list = [...list].sort((a, b) => b.bits - a.bits);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
const sl = up.match(/^@SECLEVEL=(\d)$/);
|
|
211
|
+
if (sl) {
|
|
212
|
+
secLevel = Number(sl[1]);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const parts = word.split("+").filter(Boolean);
|
|
216
|
+
const tests = parts.map(aliasMatch);
|
|
217
|
+
if (tests.some((t) => t === null)) {
|
|
218
|
+
unknown.push(raw);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
const sel = SUITES.filter((s) => tests.every((t) => t(s)));
|
|
222
|
+
if (op === "!") {
|
|
223
|
+
sel.forEach((s) => killed.add(s));
|
|
224
|
+
list = list.filter((s) => !killed.has(s));
|
|
225
|
+
}
|
|
226
|
+
else if (op === "-") {
|
|
227
|
+
const drop = new Set(sel);
|
|
228
|
+
list = list.filter((s) => !drop.has(s));
|
|
229
|
+
}
|
|
230
|
+
else if (op === "+") {
|
|
231
|
+
const move = new Set(sel);
|
|
232
|
+
list = [...list.filter((s) => !move.has(s)), ...list.filter((s) => move.has(s))];
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
for (const s of sel)
|
|
236
|
+
if (!killed.has(s) && !list.includes(s))
|
|
237
|
+
list.push(s);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// Level 2 forbids RC4; level 3 also forbids key exchange without forward secrecy (OpenSSL SSL_CTX_set_security_level).
|
|
241
|
+
if (secLevel !== undefined && secLevel >= 2)
|
|
242
|
+
list = list.filter((s) => s.enc !== "RC4");
|
|
243
|
+
if (secLevel !== undefined && secLevel >= 3)
|
|
244
|
+
list = list.filter((s) => s.kx !== "RSA" && s.kx !== "PSK");
|
|
245
|
+
return { suites: list, unknown, ...(secLevel !== undefined ? { secLevel } : {}) };
|
|
246
|
+
}
|
|
247
|
+
const AWS_SRC = "AWS Elastic Load Balancing security policy table";
|
|
248
|
+
const T13 = ["TLS_AES_128_GCM_SHA256", "TLS_AES_256_GCM_SHA384", "TLS_CHACHA20_POLY1305_SHA256"];
|
|
249
|
+
const T13_FIPS = ["TLS_AES_128_GCM_SHA256", "TLS_AES_256_GCM_SHA384"];
|
|
250
|
+
const E_GCM = ["ECDHE-ECDSA-AES128-GCM-SHA256", "ECDHE-RSA-AES128-GCM-SHA256", "ECDHE-ECDSA-AES256-GCM-SHA384", "ECDHE-RSA-AES256-GCM-SHA384"];
|
|
251
|
+
const E_SHA2 = ["ECDHE-ECDSA-AES128-SHA256", "ECDHE-RSA-AES128-SHA256", "ECDHE-ECDSA-AES256-SHA384", "ECDHE-RSA-AES256-SHA384"];
|
|
252
|
+
const E_SHA1 = ["ECDHE-ECDSA-AES128-SHA", "ECDHE-RSA-AES128-SHA", "ECDHE-ECDSA-AES256-SHA", "ECDHE-RSA-AES256-SHA"];
|
|
253
|
+
const R_SHA2 = ["AES128-GCM-SHA256", "AES128-SHA256", "AES256-GCM-SHA384", "AES256-SHA256"];
|
|
254
|
+
const R_SHA1 = ["AES128-SHA", "AES256-SHA"];
|
|
255
|
+
const P = (protocols, suites, pq = false) => ({ provider: "AWS", protocols, suites, ...(pq ? { pq } : {}), source: AWS_SRC });
|
|
256
|
+
const V13 = ["1.3"];
|
|
257
|
+
const V12 = ["1.2", "1.3"];
|
|
258
|
+
const AWS = {
|
|
259
|
+
"TLS13-1-3-2021-06": P(V13, T13),
|
|
260
|
+
"TLS13-1-2-2021-06": P(V12, [...T13, ...E_GCM, ...E_SHA2]),
|
|
261
|
+
"TLS13-1-2-Res-2021-06": P(V12, [...T13, ...E_GCM]),
|
|
262
|
+
"TLS13-1-2-Ext1-2021-06": P(V12, [...T13, ...E_GCM, ...E_SHA2, ...R_SHA2]),
|
|
263
|
+
"TLS13-1-2-Ext2-2021-06": P(V12, [...T13, ...E_GCM, ...E_SHA2, ...E_SHA1, ...R_SHA2, ...R_SHA1]),
|
|
264
|
+
"TLS13-1-2-Ext3-2021-06": P(V12, [...T13, ...E_GCM, ...E_SHA2, ...E_SHA1, ...R_SHA2]),
|
|
265
|
+
"TLS13-1-1-2021-06": P(["1.1", ...V12], [...T13, ...E_GCM, ...E_SHA2, ...E_SHA1, ...R_SHA2, ...R_SHA1]),
|
|
266
|
+
"TLS13-1-0-2021-06": P(["1.0", "1.1", ...V12], [...T13, ...E_GCM, ...E_SHA2, ...E_SHA1, ...R_SHA2, ...R_SHA1]),
|
|
267
|
+
"TLS-1-2-Ext-2018-06": P(["1.2"], [...E_GCM, ...E_SHA2, ...E_SHA1, ...R_SHA2, ...R_SHA1]),
|
|
268
|
+
"TLS-1-2-2017-01": P(["1.2"], [...E_GCM, ...E_SHA2, ...R_SHA2]),
|
|
269
|
+
"TLS-1-1-2017-01": P(["1.1", "1.2"], [...E_GCM, ...E_SHA2, ...E_SHA1, ...R_SHA2, ...R_SHA1]),
|
|
270
|
+
"2016-08": P(["1.0", "1.1", "1.2"], [...E_GCM, ...E_SHA2, ...E_SHA1, ...R_SHA2, ...R_SHA1]),
|
|
271
|
+
"TLS13-1-3-FIPS-2023-04": P(V13, T13_FIPS),
|
|
272
|
+
"TLS13-1-2-FIPS-2023-04": P(V12, [...T13_FIPS, ...E_GCM, ...E_SHA2]),
|
|
273
|
+
"TLS13-1-2-Res-FIPS-2023-04": P(V12, [...T13_FIPS, ...E_GCM]),
|
|
274
|
+
"TLS13-1-2-Ext0-FIPS-2023-04": P(V12, [...T13_FIPS, ...E_GCM, ...E_SHA2, ...E_SHA1]),
|
|
275
|
+
"TLS13-1-2-Ext1-FIPS-2023-04": P(V12, [...T13_FIPS, ...E_GCM, ...E_SHA2, ...R_SHA2]),
|
|
276
|
+
"TLS13-1-2-Ext2-FIPS-2023-04": P(V12, [...T13_FIPS, ...E_GCM, ...E_SHA2, ...E_SHA1, ...R_SHA2, ...R_SHA1]),
|
|
277
|
+
"TLS13-1-1-FIPS-2023-04": P(["1.1", ...V12], [...T13_FIPS, ...E_GCM, ...E_SHA2, ...E_SHA1, ...R_SHA2, ...R_SHA1]),
|
|
278
|
+
"TLS13-1-0-FIPS-2023-04": P(["1.0", "1.1", ...V12], [...T13_FIPS, ...E_GCM, ...E_SHA2, ...E_SHA1, ...R_SHA2, ...R_SHA1]),
|
|
279
|
+
};
|
|
280
|
+
// The post-quantum policies keep the suites of the policy they are named after and add hybrid ML-KEM groups.
|
|
281
|
+
for (const [base, pq] of [
|
|
282
|
+
["TLS13-1-3-2021-06", "TLS13-1-3-PQ-2025-09"],
|
|
283
|
+
["TLS13-1-2-2021-06", "TLS13-1-2-PQ-2025-09"],
|
|
284
|
+
["TLS13-1-2-Res-2021-06", "TLS13-1-2-Res-PQ-2025-09"],
|
|
285
|
+
["TLS13-1-2-Ext1-2021-06", "TLS13-1-2-Ext1-PQ-2025-09"],
|
|
286
|
+
["TLS13-1-2-Ext2-2021-06", "TLS13-1-2-Ext2-PQ-2025-09"],
|
|
287
|
+
["TLS13-1-0-2021-06", "TLS13-1-0-PQ-2025-09"],
|
|
288
|
+
["TLS13-1-3-FIPS-2023-04", "TLS13-1-3-FIPS-PQ-2025-09"],
|
|
289
|
+
["TLS13-1-2-FIPS-2023-04", "TLS13-1-2-FIPS-PQ-2025-09"],
|
|
290
|
+
["TLS13-1-2-Res-FIPS-2023-04", "TLS13-1-2-Res-FIPS-PQ-2025-09"],
|
|
291
|
+
["TLS13-1-2-Ext0-FIPS-2023-04", "TLS13-1-2-Ext0-FIPS-PQ-2025-09"],
|
|
292
|
+
["TLS13-1-2-Ext1-FIPS-2023-04", "TLS13-1-2-Ext1-FIPS-PQ-2025-09"],
|
|
293
|
+
["TLS13-1-2-Ext2-FIPS-2023-04", "TLS13-1-2-Ext2-FIPS-PQ-2025-09"],
|
|
294
|
+
["TLS13-1-0-FIPS-2023-04", "TLS13-1-0-FIPS-PQ-2025-09"],
|
|
295
|
+
])
|
|
296
|
+
AWS[pq] = { ...AWS[base], pq: true };
|
|
297
|
+
const AZ_SRC = "Azure Application Gateway predefined TLS policy table";
|
|
298
|
+
const AZ_2015 = ["TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_256_GCM_SHA384", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_256_CBC_SHA256", "TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_RSA_WITH_AES_256_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", "TLS_DHE_DSS_WITH_AES_256_CBC_SHA", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_3DES_EDE_CBC_SHA", "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA"];
|
|
299
|
+
const AZ_2017 = ["TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_256_GCM_SHA384", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_256_CBC_SHA256", "TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_RSA_WITH_AES_256_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA"];
|
|
300
|
+
const AZ_2022 = ["TLS_AES_256_GCM_SHA384", "TLS_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256"];
|
|
301
|
+
const AZ_2022S = ["TLS_AES_256_GCM_SHA384", "TLS_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"];
|
|
302
|
+
const A = (protocols, suites) => ({ provider: "Azure", protocols, suites, source: AZ_SRC });
|
|
303
|
+
const AZURE = {
|
|
304
|
+
AppGwSslPolicy20150501: A(["1.0", "1.1", "1.2"], AZ_2015),
|
|
305
|
+
AppGwSslPolicy20170401: A(["1.1", "1.2"], AZ_2017),
|
|
306
|
+
AppGwSslPolicy20170401S: A(["1.2"], AZ_2017),
|
|
307
|
+
AppGwSslPolicy20220101: A(["1.2", "1.3"], AZ_2022),
|
|
308
|
+
AppGwSslPolicy20220101S: A(["1.2", "1.3"], AZ_2022S),
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* Google Cloud profiles: the minimum TLS version is set apart, and the exact suite list depends on it, so
|
|
312
|
+
* the inventory names the profile and asks for the account's own list (benthic cloud reads it).
|
|
313
|
+
*/
|
|
314
|
+
const GCP = {
|
|
315
|
+
COMPATIBLE: { provider: "Google Cloud", protocols: [], suites: [], source: "Google Cloud SSL policy profiles" },
|
|
316
|
+
MODERN: { provider: "Google Cloud", protocols: [], suites: [], source: "Google Cloud SSL policy profiles" },
|
|
317
|
+
RESTRICTED: { provider: "Google Cloud", protocols: [], suites: [], source: "Google Cloud SSL policy profiles" },
|
|
318
|
+
FIPS_202205: { provider: "Google Cloud", protocols: ["1.2", "1.3"], suites: [...T13_FIPS, ...E_GCM], source: "Google Cloud SSL policy profiles" },
|
|
319
|
+
};
|
|
320
|
+
/** A named load balancer TLS policy: "ELBSecurityPolicy-TLS13-1-2-2021-06", "AppGwSslPolicy20220101", "MODERN". */
|
|
321
|
+
export function namedPolicy(name) {
|
|
322
|
+
const aws = name.match(/^ELBSecurityPolicy-(.+)$/);
|
|
323
|
+
if (aws)
|
|
324
|
+
return AWS[aws[1]];
|
|
325
|
+
if (AZURE[name])
|
|
326
|
+
return AZURE[name];
|
|
327
|
+
return GCP[name.toUpperCase()];
|
|
328
|
+
}
|
|
329
|
+
const SP800_52 = "NIST SP 800-52 Rev. 2";
|
|
330
|
+
const RFC8996 = "RFC 8996";
|
|
331
|
+
const SP800_131 = "NIST SP 800-131A Rev. 2";
|
|
332
|
+
/** A TLS or SSL version: "1.3", "1.2", "1.1", "1.0", "SSLv3", "SSLv2". */
|
|
333
|
+
export function protocolVerdict(version) {
|
|
334
|
+
if (version === "1.3")
|
|
335
|
+
return { strength: "strong", quantum: "depends", why: "Current version. Quantum safety depends on the key exchange group (hybrid ML-KEM is quantum-safe).", source: SP800_52 };
|
|
336
|
+
if (version === "1.2")
|
|
337
|
+
return { strength: "strong", quantum: "depends", why: "Acceptable with strong suites. No hybrid ML-KEM key exchange in TLS 1.2, so recorded traffic stays exposed to a future quantum computer.", source: SP800_52 };
|
|
338
|
+
if (version === "1.1" || version === "1.0")
|
|
339
|
+
return { strength: "weak", quantum: "breakable", why: `TLS ${version} is deprecated and doesn't meet PCI DSS strong cryptography.`, source: `${RFC8996}; ${SP800_52}` };
|
|
340
|
+
return { strength: "weak", quantum: "breakable", why: `${version} is broken and prohibited.`, source: `RFC 7568; ${SP800_52}` };
|
|
341
|
+
}
|
|
342
|
+
/** One cipher suite. */
|
|
343
|
+
export function suiteVerdict(s) {
|
|
344
|
+
const weak = (why, source = SP800_52) => ({ strength: "weak", quantum: "breakable", why, source });
|
|
345
|
+
if (s.enc === "NULL")
|
|
346
|
+
return weak("No encryption at all.");
|
|
347
|
+
if (s.au === "none" && s.kx !== "PSK")
|
|
348
|
+
return weak("Anonymous: the server is never authenticated, so anyone in the middle can read the traffic.");
|
|
349
|
+
if (s.enc === "RC4")
|
|
350
|
+
return weak("RC4 is broken and prohibited in TLS.", "RFC 7465");
|
|
351
|
+
if (s.enc === "3DES")
|
|
352
|
+
return weak("3DES has a 64-bit block (Sweet32) and is disallowed for new encryption.", SP800_131);
|
|
353
|
+
if (s.enc === "IDEA" || s.enc === "SEED")
|
|
354
|
+
return weak(`${s.enc} is not an approved cipher and was removed from TLS 1.2 guidance.`, SP800_131);
|
|
355
|
+
if (s.mac === "MD5")
|
|
356
|
+
return weak("Uses MD5 for integrity.", SP800_131);
|
|
357
|
+
if (s.min === "1.3")
|
|
358
|
+
return { strength: "strong", quantum: "depends", why: "Approved TLS 1.3 suite. The key exchange group is set apart.", source: "NIST SP 800-52 Rev. 2; RFC 8446" };
|
|
359
|
+
const q = s.kx === "PSK" ? "depends" : "breakable";
|
|
360
|
+
if (s.kx === "RSA")
|
|
361
|
+
return { strength: "legacy", quantum: "breakable", why: "Static RSA key exchange: no forward secrecy, so a stolen server key decrypts every recorded session.", source: SP800_52 };
|
|
362
|
+
if (s.enc.startsWith("CAMELLIA"))
|
|
363
|
+
return { strength: "legacy", quantum: q, why: "Camellia is strong but not NIST-approved; assessors may ask why it's enabled.", source: SP800_131 };
|
|
364
|
+
if (s.mac === "SHA1")
|
|
365
|
+
return { strength: "legacy", quantum: q, why: "CBC with SHA-1 HMAC: still acceptable in TLS 1.2, but legacy. Prefer GCM or ChaCha20.", source: SP800_52 };
|
|
366
|
+
if (s.mac !== "AEAD")
|
|
367
|
+
return { strength: "strong", quantum: q, why: "Forward secret, CBC mode with SHA-2 HMAC. Acceptable; GCM is preferred.", source: SP800_52 };
|
|
368
|
+
return { strength: "strong", quantum: q, why: s.kx === "PSK" ? "Pre-shared key with authenticated encryption." : "Forward secret, authenticated encryption.", source: SP800_52 };
|
|
369
|
+
}
|
|
370
|
+
const SSH_SRC = "RFC 9142; RFC 8332; RFC 8758";
|
|
371
|
+
export function sshVerdict(list, name) {
|
|
372
|
+
const n = name.toLowerCase();
|
|
373
|
+
const weak = (why) => ({ strength: "weak", quantum: "breakable", why, source: SSH_SRC });
|
|
374
|
+
if (list === "kex") {
|
|
375
|
+
if (/^(mlkem768x25519-sha256|sntrup761x25519-sha512(@openssh\.com)?|mlkem768nistp256-sha256|mlkem1024nistp384-sha384)$/.test(n))
|
|
376
|
+
return { strength: "strong", quantum: "safe", why: "Hybrid post-quantum key exchange.", source: "RFC 9142; draft-ietf-sshm-mlkem-hybrid-kex" };
|
|
377
|
+
if (/sha1$/.test(n))
|
|
378
|
+
return weak("SHA-1 key exchange; RFC 9142 says not to use it.");
|
|
379
|
+
if (/group1-/.test(n))
|
|
380
|
+
return weak("1024-bit Diffie-Hellman group.");
|
|
381
|
+
if (/^(ext-info|kex-strict)/.test(n))
|
|
382
|
+
return { strength: "strong", quantum: "depends", why: "Protocol extension marker, not a key exchange.", source: SSH_SRC };
|
|
383
|
+
return { strength: "strong", quantum: "breakable", why: "Strong today; breakable by a large quantum computer.", source: SSH_SRC };
|
|
384
|
+
}
|
|
385
|
+
if (list === "cipher") {
|
|
386
|
+
if (/^(3des|arcfour|blowfish|cast128|des)/.test(n))
|
|
387
|
+
return weak(`${name} is broken or has a 64-bit block.`);
|
|
388
|
+
if (/-cbc$/.test(n))
|
|
389
|
+
return weak("CBC mode in SSH is open to plaintext-recovery attacks; use CTR or GCM.");
|
|
390
|
+
return { strength: "strong", quantum: "safe", why: "Strong symmetric cipher; key length holds against quantum search.", source: SSH_SRC };
|
|
391
|
+
}
|
|
392
|
+
if (list === "mac") {
|
|
393
|
+
if (/md5|sha1|umac-64|ripemd/.test(n))
|
|
394
|
+
return weak(`${name} uses a short or weak hash.`);
|
|
395
|
+
return { strength: "strong", quantum: "safe", why: "SHA-2 or UMAC-128 integrity.", source: SSH_SRC };
|
|
396
|
+
}
|
|
397
|
+
if (n === "ssh-rsa")
|
|
398
|
+
return weak("RSA with SHA-1 signatures; RFC 8332 replaces it with rsa-sha2-256 and rsa-sha2-512.");
|
|
399
|
+
if (n === "ssh-dss")
|
|
400
|
+
return weak("DSA host keys are 1024-bit and disabled in current OpenSSH.");
|
|
401
|
+
return { strength: "strong", quantum: "breakable", why: "Strong today; breakable by a large quantum computer.", source: SSH_SRC };
|
|
402
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// SPDX-License-Identifier: PolyForm-Shield-1.0.0
|
|
2
|
+
// Copyright 2026 Hard Keel (https://hardkeel.com)
|
|
3
|
+
// Quick check of hosts the person names. For TLS: the two handshakes a current browser makes.
|
|
4
|
+
// One with normal settings, and one offering only the hybrid ML-KEM groups, to see whether the
|
|
5
|
+
// server can do quantum-safe key exchange. Then the certificate's key and signature.
|
|
6
|
+
// For SSH (ssh://host, or port 22): the settings the server announces before any login, read from
|
|
7
|
+
// one connection that sends only a client banner.
|
|
8
|
+
// Nothing else is probed (no old TLS versions, no cipher sweeps): the full checks stay in
|
|
9
|
+
// `benthic map`, which needs proof that the domain is yours.
|
|
10
|
+
import { canTestHybrid, handshake, HYBRID_GROUPS, parseTarget, sshFindings, sshKexInit } from "./map-web.js";
|
|
11
|
+
import { toFinding } from "./map-rank.js";
|
|
12
|
+
import { materialFindings, parseCertificate } from "./der.js";
|
|
13
|
+
export const MAX_TLS_TARGETS = 20;
|
|
14
|
+
/** Parses the hosts typed on the command line. */
|
|
15
|
+
export function tlsTargets(args) {
|
|
16
|
+
const targets = [];
|
|
17
|
+
const errors = [];
|
|
18
|
+
for (const a of args) {
|
|
19
|
+
const t = parseTarget(a);
|
|
20
|
+
if ("error" in t)
|
|
21
|
+
errors.push(t.error.replace("under a domain you proved, ", ""));
|
|
22
|
+
else if (!targets.some((x) => x.label === t.label))
|
|
23
|
+
targets.push(t);
|
|
24
|
+
}
|
|
25
|
+
if (targets.length > MAX_TLS_TARGETS)
|
|
26
|
+
errors.push(`At most ${MAX_TLS_TARGETS} hosts at a time.`);
|
|
27
|
+
return { targets: targets.slice(0, MAX_TLS_TARGETS), errors };
|
|
28
|
+
}
|
|
29
|
+
/** Reads what an SSH server offers and whether any of its key exchange methods is quantum-safe. */
|
|
30
|
+
export async function checkSshQuick(t, ssh = sshKexInit) {
|
|
31
|
+
const k = await ssh(t.host, t.port);
|
|
32
|
+
if ("error" in k)
|
|
33
|
+
return { target: t.label, kind: "ssh", ok: false, error: k.message, hybrid: null, findings: [] };
|
|
34
|
+
const r = sshFindings(k, "web", t.label, true);
|
|
35
|
+
const kex = k.kex.filter((x) => !x.startsWith("ext-info") && !x.startsWith("kex-strict"));
|
|
36
|
+
return {
|
|
37
|
+
target: t.label,
|
|
38
|
+
kind: "ssh",
|
|
39
|
+
ok: true,
|
|
40
|
+
protocol: "SSH",
|
|
41
|
+
keyExchange: r.pqc ? kex.find((x) => /mlkem|sntrup/.test(x)) : kex[0],
|
|
42
|
+
hybrid: r.pqc,
|
|
43
|
+
ssh: { banner: k.banner, kex, hostKeys: k.hostKeys },
|
|
44
|
+
findings: r.findings.map((f) => ({ ...toFinding(f), snippet: `${t.label} ${k.banner}` })),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export async function checkTlsQuick(t, hs = handshake, hybridTestable = canTestHybrid()) {
|
|
48
|
+
const main = await hs(t.host, t.port, { minVersion: "TLSv1.2" });
|
|
49
|
+
if (!main.ok)
|
|
50
|
+
return { target: t.label, ok: false, error: main.message ?? main.error ?? "couldn't connect", hybrid: null, findings: [] };
|
|
51
|
+
let hybrid = null;
|
|
52
|
+
let kx = main.keyExchange;
|
|
53
|
+
if (main.protocol === "TLSv1.3" && hybridTestable) {
|
|
54
|
+
const h = await hs(t.host, t.port, { minVersion: "TLSv1.3", ecdhCurve: HYBRID_GROUPS });
|
|
55
|
+
hybrid = h.ok;
|
|
56
|
+
if (h.ok && h.keyExchange)
|
|
57
|
+
kx = h.keyExchange;
|
|
58
|
+
}
|
|
59
|
+
else if (main.protocol !== "TLSv1.3") {
|
|
60
|
+
hybrid = false;
|
|
61
|
+
}
|
|
62
|
+
const findings = [];
|
|
63
|
+
if (hybrid === false) {
|
|
64
|
+
findings.push({
|
|
65
|
+
kind: "config",
|
|
66
|
+
ruleId: "tls-kex",
|
|
67
|
+
title: `${t.label} offers no quantum-safe key exchange (${main.keyExchange ?? "classical"}${main.protocol === "TLSv1.3" ? "" : `, ${main.protocol ?? "old TLS"}`})`,
|
|
68
|
+
algorithm: "TLS key exchange",
|
|
69
|
+
primitive: "key-agreement",
|
|
70
|
+
risk: "quantum-vulnerable",
|
|
71
|
+
severity: "high",
|
|
72
|
+
file: t.label,
|
|
73
|
+
line: 0,
|
|
74
|
+
snippet: `${main.protocol ?? "TLS"} ${main.keyExchange ?? ""}`.trim(),
|
|
75
|
+
fix: main.protocol === "TLSv1.3"
|
|
76
|
+
? "Turn on hybrid X25519MLKEM768 key exchange. Recent OpenSSL (3.5+), BoringSSL, nginx, Caddy and most CDNs support it."
|
|
77
|
+
: "Move to TLS 1.3 first, then turn on hybrid X25519MLKEM768 key exchange.",
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
let certificate;
|
|
81
|
+
if (main.cert) {
|
|
82
|
+
const p = parseCertificate(new Uint8Array(main.cert.raw));
|
|
83
|
+
if (p) {
|
|
84
|
+
const k = p.key;
|
|
85
|
+
certificate = { ...p.material, key: k ? (k.algorithm ? `${k.algorithm}${k.keySize ? `-${k.keySize}` : ""}${k.curve ? ` ${k.curve}` : ""}` : k.pqc?.algorithm) ?? undefined : undefined };
|
|
86
|
+
findings.push(...materialFindings(t.label, 0, "CERTIFICATE", p).findings.map((f) => ({ ...f, snippet: `${t.label} certificate ${p.material.subject ?? ""}`.trim() })));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return { target: t.label, ok: true, protocol: main.protocol ?? undefined, keyExchange: kx, hybrid, certificate, findings };
|
|
90
|
+
}
|
|
91
|
+
export function tlsText(results) {
|
|
92
|
+
const out = [];
|
|
93
|
+
for (const r of results) {
|
|
94
|
+
out.push(r.kind === "ssh" ? `ssh://${r.target}` : r.target);
|
|
95
|
+
if (!r.ok) {
|
|
96
|
+
out.push(` Couldn't connect: ${r.error}`, "");
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (r.kind === "ssh" && r.ssh) {
|
|
100
|
+
out.push(` ${r.ssh.banner}`, ` Key exchange ${r.keyExchange ?? "unknown"}${r.hybrid ? ", quantum-safe hybrid offered" : ", no quantum-safe option offered"}`);
|
|
101
|
+
out.push(` Host keys: ${r.ssh.hostKeys.join(", ") || "none listed"}`);
|
|
102
|
+
for (const f of r.findings)
|
|
103
|
+
out.push(` ! ${f.title}`, ` ${f.fix}`);
|
|
104
|
+
out.push("");
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const proto = (r.protocol ?? "TLS").replace("TLSv", "TLS ");
|
|
108
|
+
const kx = r.hybrid === true
|
|
109
|
+
? `${r.keyExchange ?? "hybrid ML-KEM"}, quantum-safe hybrid`
|
|
110
|
+
: r.hybrid === false
|
|
111
|
+
? `${r.keyExchange ?? "classical"}, no quantum-safe option offered`
|
|
112
|
+
: `${r.keyExchange ?? "unknown"}; hybrid ML-KEM not tested (needs Node.js with OpenSSL 3.5 or later)`;
|
|
113
|
+
out.push(` ${proto}, key exchange ${kx}`);
|
|
114
|
+
const c = r.certificate;
|
|
115
|
+
if (c)
|
|
116
|
+
out.push(` Certificate: ${c.key ?? "unknown key"}, signed with ${c.signatureAlgorithm ?? "unknown"}${c.notAfter ? `, valid until ${c.notAfter.slice(0, 10)}` : ""}`);
|
|
117
|
+
for (const f of r.findings)
|
|
118
|
+
out.push(` ! ${f.title}`, ` ${f.fix}`);
|
|
119
|
+
out.push("");
|
|
120
|
+
}
|
|
121
|
+
return out.join("\n").trimEnd();
|
|
122
|
+
}
|
package/dist/types.js
ADDED
package/dist/walk.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// SPDX-License-Identifier: PolyForm-Shield-1.0.0
|
|
2
|
+
// Copyright 2026 Hard Keel (https://hardkeel.com)
|
|
3
|
+
// Reads the files in a folder that the scanner looks at.
|
|
4
|
+
// A folder or file that can't be read (no permission, removed mid-scan) is noted and skipped,
|
|
5
|
+
// so one locked folder can't stop the whole scan.
|
|
6
|
+
import { existsSync, lstatSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
7
|
+
import { join, relative } from "node:path";
|
|
8
|
+
import { shouldScan } from "./scan.js";
|
|
9
|
+
function reasonOf(e) {
|
|
10
|
+
const code = String(e?.code ?? "");
|
|
11
|
+
if (code === "EACCES" || code === "EPERM")
|
|
12
|
+
return "permission denied";
|
|
13
|
+
if (code === "ENOENT")
|
|
14
|
+
return "removed during the scan";
|
|
15
|
+
return code || (e instanceof Error ? e.message : String(e));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* File bytes as text. UTF-16 files with a byte-order mark (common for files saved by Windows tools
|
|
19
|
+
* and PowerShell) are decoded as UTF-16, so they are scanned instead of being taken for binary.
|
|
20
|
+
*/
|
|
21
|
+
export function decodeText(buf) {
|
|
22
|
+
if (buf.length >= 2 && buf[0] === 0xff && buf[1] === 0xfe)
|
|
23
|
+
return new TextDecoder("utf-16le").decode(buf.subarray(2));
|
|
24
|
+
if (buf.length >= 2 && buf[0] === 0xfe && buf[1] === 0xff)
|
|
25
|
+
return new TextDecoder("utf-16be").decode(buf.subarray(2));
|
|
26
|
+
if (buf.length >= 3 && buf[0] === 0xef && buf[1] === 0xbb && buf[2] === 0xbf)
|
|
27
|
+
return new TextDecoder("utf-8").decode(buf.subarray(3));
|
|
28
|
+
return new TextDecoder("utf-8").decode(buf);
|
|
29
|
+
}
|
|
30
|
+
/** Throws a plain-English error when the folder itself is missing or isn't a folder. */
|
|
31
|
+
export function walkFolder(root) {
|
|
32
|
+
if (!existsSync(root))
|
|
33
|
+
throw new Error(`Can't scan ${root}: that folder doesn't exist.`);
|
|
34
|
+
if (!statSync(root).isDirectory())
|
|
35
|
+
throw new Error(`Can't scan ${root}: that's a file, not a folder.`);
|
|
36
|
+
const res = { files: [], unreadable: [] };
|
|
37
|
+
const visit = (dir) => {
|
|
38
|
+
let names;
|
|
39
|
+
try {
|
|
40
|
+
names = readdirSync(dir);
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
if (dir === root)
|
|
44
|
+
throw new Error(`Can't scan ${root}: ${reasonOf(e)}.`);
|
|
45
|
+
res.unreadable.push({ path: relative(root, dir).split("\\").join("/") + "/", reason: reasonOf(e) });
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
for (const name of names) {
|
|
49
|
+
const full = join(dir, name);
|
|
50
|
+
const rel = relative(root, full).split("\\").join("/");
|
|
51
|
+
// lstat: symbolic links are skipped, so a broken or looping link can't stop the scan.
|
|
52
|
+
let st;
|
|
53
|
+
try {
|
|
54
|
+
st = lstatSync(full);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (st.isDirectory()) {
|
|
60
|
+
if (name !== ".git" && shouldScan(`${rel}/x`))
|
|
61
|
+
visit(full);
|
|
62
|
+
}
|
|
63
|
+
else if (st.isFile() && st.size <= 1_000_000 && shouldScan(rel)) {
|
|
64
|
+
try {
|
|
65
|
+
res.files.push({ path: rel, content: decodeText(readFileSync(full)) });
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
res.unreadable.push({ path: rel, reason: reasonOf(e) });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
visit(root);
|
|
74
|
+
return res;
|
|
75
|
+
}
|
|
76
|
+
export function walk(root) {
|
|
77
|
+
return walkFolder(root).files;
|
|
78
|
+
}
|