@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/README.md
CHANGED
|
@@ -1,3 +1,425 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Hard Keel Benthic
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A free post-quantum readiness scanner. It finds encryption that quantum computers will break (RSA, elliptic curve and Diffie-Hellman), weak encryption, exposed infrastructure settings, and leaked keys or passwords in your code and infrastructure config, and with `map` and `cloud`, on your own websites, network equipment, cloud accounts and the machine you run it on.
|
|
4
|
+
|
|
5
|
+
It grades readiness from A+ to F and writes an encryption inventory (a CycloneDX cryptography bill of materials, or CBOM), SARIF for code scanning, and a plan for moving to post-quantum (PQC) methods on NIST's timeline. Use it from the command line or as a GitHub Action.
|
|
6
|
+
|
|
7
|
+
Free to use and source available under the [PolyForm Shield License](#license). No account and no dependencies. Your code and results stay on your machine; see [Anonymized sharing](#anonymized-sharing) for the one small summary it sends, and how to turn it off.
|
|
8
|
+
|
|
9
|
+
Benthic was called Quantum Scan before 1.0. The `quantum-scan` command, `.quantum-scan-ignore`, `.quantum-scan.yml` and the `QUANTUM_SCAN_` settings still work.
|
|
10
|
+
|
|
11
|
+
## Run it
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npx @hardkeel/benthic
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Scans the current folder and prints what to fix now and what to plan for:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
Hard Keel Benthic · 4 files scanned
|
|
21
|
+
|
|
22
|
+
Quantum readiness: C (75/100, Hard Keel method v1). Weak encryption or exposed settings hold the grade at C or lower until they are fixed.
|
|
23
|
+
|
|
24
|
+
Found 2 uses of weak encryption and 1 use of encryption quantum computers will break.
|
|
25
|
+
|
|
26
|
+
Fix now
|
|
27
|
+
payments.py:6 RSA-1024 key
|
|
28
|
+
Use 3072-bit keys or larger now, then plan the move to post-quantum methods.
|
|
29
|
+
payments.py:10 ECB mode
|
|
30
|
+
Switch to AES-256-GCM.
|
|
31
|
+
|
|
32
|
+
Plan for later
|
|
33
|
+
Safe today, but quantum computers will be able to break these. NIST plans to phase them out between 2030 and 2035.
|
|
34
|
+
auth.ts:6 ECDH key exchange
|
|
35
|
+
Move key exchange to ML-KEM (FIPS 203), or hybrid X25519 + ML-KEM-768 for TLS.
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Options
|
|
39
|
+
|
|
40
|
+
| Option | What it does |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| `--cbom <file>` | Write the encryption inventory as a CycloneDX 1.6 CBOM |
|
|
43
|
+
| `--report <file>` | Write the migration report, in the order to fix things |
|
|
44
|
+
| `--badge <file>` | Write a quantum readiness badge (SVG) to put on your README |
|
|
45
|
+
| `--format text\|json\|sarif\|cyclonedx\|sonar` | What to print. SARIF works with GitHub code scanning; `cyclonedx` prints the encryption inventory (CBOM); `sonar` writes SonarQube external issues |
|
|
46
|
+
| `--output <file>` | Write that output to a file |
|
|
47
|
+
| `--fail-on <list>` | Exit with 1 on `secret`, `weak-now`, `exposed`, `quantum-vulnerable`, `increase`, `policy`, `profile`, or `none`. Default `secret,weak-now,exposed`. A name it doesn't know stops the scan with exit 2, as does any option it doesn't know |
|
|
48
|
+
| `--policy <file>` | Check results against your own policy file. Without it, `.benthic.yml` at the top of the scanned folder is used if there is one |
|
|
49
|
+
| `--profile cnsa2` | Also list what NSA's CNSA 2.0 suite doesn't allow, like AES-128, SHA-256, ML-KEM-768 or SLH-DSA. With `--fail-on profile`, exit with 1 if there is any. Doesn't change the grade |
|
|
50
|
+
| `--baseline <file>` | Compare with an earlier run (a CBOM from `--cbom`, or `--format json` output) and show what went up or down. With `--fail-on increase`, exit with 1 if anything quantum-breakable went up |
|
|
51
|
+
| `--ignore-file <file>` | Use this ignore file instead of the one in the scanned folder |
|
|
52
|
+
| `--no-repo-config` | Don't read `.benthic-ignore` or `.benthic.yml` from the scanned folder. Use it for changes from people you don't know, so a change can't hide its own findings |
|
|
53
|
+
| `--quiet` | Leave out the closing line about installing on GitHub |
|
|
54
|
+
| `--offline` | Send nothing to Hard Keel |
|
|
55
|
+
|
|
56
|
+
## Quantum readiness score
|
|
57
|
+
|
|
58
|
+
Every scan ends with a grade from A+ to F and a score out of 100. The method is open and versioned: [how the score works](https://hardkeel.com/learn/quantum-readiness-score/).
|
|
59
|
+
|
|
60
|
+
- **A+:** nothing to fix, and post-quantum encryption (ML-KEM, ML-DSA, SLH-DSA) is already in use.
|
|
61
|
+
- **A:** nothing to fix now, or only signatures left to move before 2035.
|
|
62
|
+
- **B:** key exchange that quantum computers will break, due to move by 2030.
|
|
63
|
+
- **C or lower:** weak encryption or exposed settings to fix now. A leaked key or password holds the grade at D or lower.
|
|
64
|
+
|
|
65
|
+
Put the grade on your README with `--badge quantum-readiness.svg`, or install Hard Keel Benthic on GitHub to keep a live badge current for public repositories.
|
|
66
|
+
|
|
67
|
+
## What it looks for
|
|
68
|
+
|
|
69
|
+
- **Encryption quantum computers will break:** RSA, elliptic-curve (ECDSA, ECDH, Ed25519, X25519) and Diffie-Hellman.
|
|
70
|
+
- **Weak encryption:** MD5, SHA-1, DES, 3DES, RC4, ECB mode, DSA, RSA under 2048 bits, TLS 1.0 and 1.1.
|
|
71
|
+
- **Exposed infrastructure settings:** storage or databases open to the public, admin and database ports open to the whole internet, encryption at rest turned off, unencrypted traffic allowed, and certificate checks turned off, in config and in application code (`InsecureSkipVerify`, `rejectUnauthorized: false`, `verify=False`).
|
|
72
|
+
- **Weak TLS in config:** old TLS versions and weak cipher suites in nginx, Apache, HAProxy, load balancer and CDN settings.
|
|
73
|
+
- **Keys and certificates in files:** PEM certificates, certificate requests and public keys, read for their real algorithm, curve and size (including ones pasted into JSON or code strings and JWKS `x5c` entries). JSON Web Keys, JOSE algorithm settings, and Ethereum signatures (EIP-712, EIP-2612 permit, EIP-3009, `ecrecover`) on secp256k1. TLS key exchange group settings without ML-KEM in nginx, Apache, HAProxy, Caddy, OpenSSL, Envoy, Traefik and Java, and AWS load balancer policies that aren't post-quantum.
|
|
74
|
+
- **Encryption libraries you depend on:** package.json, requirements.txt, pyproject.toml, go.mod, pom.xml, build.gradle, Cargo.toml, Gemfile, composer.json and .csproj are read for JWT, JOSE, TLS, SSH, wallet and post-quantum libraries, with what each one offers. Only runtime dependencies count. They're listed in the inventory and the CBOM (with package URLs) and never change the grade.
|
|
75
|
+
- **Wallet addresses:** Ethereum account addresses in code and settings are listed to check, since an account someone holds a key for is controlled by secp256k1.
|
|
76
|
+
- **Hash-based signature parameters:** LMS and XMSS parameter sets that SP 800-208 doesn't approve, or that use SHA-256 where a SHAKE256 set gives more margin, are listed as worth a look. They never change the grade.
|
|
77
|
+
- **Lattice parameter sets and agility:** ML-KEM-512 and ML-DSA-44 (Kyber512 and Dilithium2), the smallest sets, are listed as worth a look with the larger set to move to. The summary and the CBOM also say how much of the post-quantum encryption found rests on lattice math alone, and suggest a hybrid key exchange or a hash-based signature where none is in use. ML-KEM and ML-DSA stay the recommended standards. None of this changes the grade or fails a build.
|
|
78
|
+
- **Leaked keys and passwords:** private keys, cloud and API tokens, passwords in connection strings, Terraform, CloudFormation, Dockerfiles and Kubernetes Secrets. They are masked in all output: only a public prefix like `AKIA` or `ghp_` is shown, never any part of the key itself, and a key is removed from every line printed, including lines reported for something else.
|
|
79
|
+
|
|
80
|
+
A comment after code on the same line is left out, so `# was RS256` doesn't count as RSA and `# TODO: ML-KEM` doesn't count as post-quantum work.
|
|
81
|
+
|
|
82
|
+
It reads code the way it's written, not one line at a time. A key size or algorithm held in a constant is read where it's used (`key_size=KEY_BITS`), a call spread over several lines is read as one, Python import aliases are followed (`RSA as PyRSA`), and import lines, type names and regular expressions that only mention an algorithm don't count.
|
|
83
|
+
|
|
84
|
+
It reads Python, JavaScript and TypeScript, Go, Java, plus Rust, C#, PHP, Ruby, Swift and C or C++ with OpenSSL through community rules, and Terraform and OpenTofu, CloudFormation, Kubernetes manifests, Dockerfiles, and nginx, Apache and HAProxy configs. A plain scan looks at files only. To check live websites and this machine too, use `benthic map`. To check your AWS, Azure or Google Cloud account, use `benthic cloud`.
|
|
85
|
+
|
|
86
|
+
## Container images
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
npx @hardkeel/benthic image ghcr.io/shop/api:1.4
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Pulls the image straight from its registry, read-only, using the `docker login` or `podman login` already on your machine (credential helpers included). No Docker daemon is needed and nothing in the image is run. Every manifest and layer is checked against its digest, and what each layer gave is cached by that digest, so a second image on the same base only reads its own layers (`--no-cache` turns that off). Multi-platform images default to `linux/amd64`; pick another with `--platform linux/arm64`.
|
|
93
|
+
|
|
94
|
+
A saved image works too, offline: `docker save` or `podman save` archives, OCI layouts, and unpacked root filesystems, with gzip or zstd layers (zstd needs Node 22.15 or later).
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
docker save shop/api:1.4 -o api.tar
|
|
98
|
+
npx @hardkeel/benthic image api.tar
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
It applies the layers in order (deleted files stay deleted) and reports:
|
|
102
|
+
|
|
103
|
+
- **System encryption packages** from the Debian, Ubuntu or Alpine package list: OpenSSL, OpenSSH, Java, Go, GnuTLS, NSS and others, with whether that version can do post-quantum key exchange.
|
|
104
|
+
- **Encryption built into programs** that no package list shows: OpenSSL compiled in statically or shipped as the app's own `libssl.so`, BoringSSL, AWS-LC, LibreSSL, Mbed TLS, wolfSSL, Libgcrypt, libsodium, liboqs and Rust's ring, found by the version text each library compiles in. A program that links to the system's OpenSSL isn't counted twice.
|
|
105
|
+
- **Go programs** built into the image, read for the Go version and modules they were built with. Go 1.24 and later use hybrid ML-KEM by default.
|
|
106
|
+
- **Java keystores** (JKS, JCEKS and PKCS #12) left in the image: which entries hold private keys, and the key type and size of the certificates stored with them. No password is ever tried.
|
|
107
|
+
- **Settings** in the image: sshd and OpenSSL config, nginx, Apache and HAProxy, host keys and certificates.
|
|
108
|
+
- **Package signing keys** the distribution ships (Alpine's keys and the OpenPGP keyrings apt and rpm use), counted by type and size, post-quantum ones included.
|
|
109
|
+
- **Your application code and keys or passwords** left in any layer, and secrets set with `ENV` in the image's build history.
|
|
110
|
+
|
|
111
|
+
It takes the same options as a folder scan, so `--cbom`, `--format sarif` and `--fail-on` work the same way.
|
|
112
|
+
|
|
113
|
+
## How accurate it is
|
|
114
|
+
|
|
115
|
+
Measured, and repeatable with one command. On a labeled corpus of 104 findings with many look-alike negatives, it reports 102 of them and nothing wrong. On 14 public repositories at pinned commits, 206 of the 217 findings it reports are right (94.9%), each one labeled by hand. The method, the caveats and every wrong finding are in [docs/ACCURACY.md](docs/ACCURACY.md); run it yourself with `npm run bench` and `npm run bench:real`.
|
|
116
|
+
|
|
117
|
+
## Checking a release
|
|
118
|
+
|
|
119
|
+
Every release is built and signed by this repository's release workflow, with npm provenance and Sigstore build attestations for the package, its SBOM and the built Action files. No long-lived signing keys exist. To check one:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
npm audit signatures
|
|
123
|
+
gh attestation verify hardkeel-benthic-<version>.tgz --repo Hard-Keel/benthic
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
More in [docs/VERIFYING.md](docs/VERIFYING.md).
|
|
127
|
+
|
|
128
|
+
## Encryption map
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
npx @hardkeel/benthic map
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Checks more than code, one area at a time, and asks before each one. For every area it says what it will touch, what it reads and what it never does. The answer is no unless you type yes.
|
|
135
|
+
|
|
136
|
+
- **Code and config:** the same checks as a plain scan.
|
|
137
|
+
- **Websites and public services:** the encryption your sites, APIs and SSH servers offer, from about six normal connections each, a quarter second apart. It never logs in or sends attack traffic. It checks only domains you've proved are yours, with one DNS record that covers the domain and everything under it:
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
npx @hardkeel/benthic prove example.com
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Just want to know whether a site offers quantum-safe TLS? `benthic tls example.com api.example.com:8443` makes two ordinary handshakes with each host you name (up to 20) and reports whether hybrid ML-KEM key exchange was agreed, plus the certificate's key. For SSH, name `ssh://git.example.com`: it reads the key exchange and host key methods the server announces before any login, and sends nothing but a client banner. Add `--require-pq` to exit with 1 if any host doesn't offer it, or `--cbom <file>` for the result as a CBOM. It contacts only the hosts you list and sends nothing to Hard Keel.
|
|
144
|
+
|
|
145
|
+
Not sure which hostnames you have? `benthic hosts example.com` lists the names under your domain from public certificate logs (crt.sh), including old APIs and staging sites people forget. It reads the public log only and contacts none of the hosts; paste the list into `map` to check them. Add `--all` for names seen only on certificates that expired in the last year, or `--json`.
|
|
146
|
+
|
|
147
|
+
For each proved website that answers, `map` also reads its sign-in setup, if it has one, and reports how its tokens are signed: the OpenID Connect discovery document at `/.well-known/openid-configuration` and its signing keys, or SAML metadata if you list the metadata URL (for example `https://adfs.example.com/FederationMetadata/2007-06/FederationMetadata.xml`). RSA and ECDSA signatures are quantum-breakable, and SAML signing certificates tend to live for years, so they rank high. Unsigned tokens (`none`), RSA keys under 2048 bits and SHA-1 signatures are flagged as broken now. Keys hosted on a domain you haven't proved are not fetched.
|
|
148
|
+
|
|
149
|
+
- **Network and connected equipment:** routers, switches, printers, cameras, storage boxes and smart devices on your own network. For each address it checks whether about 30 common ports answer, reads the title of any web page they serve and the certificate on secure admin pages, and reads the router's list of automatic port forwards (UPnP) if it publishes one. It flags Telnet and plain FTP, open remote desktop, VNC and remote support tools, devices still on their setup page, admin pages without encryption or with the factory certificate, open print ports, camera and recorder ports, unencrypted MQTT, open databases and Docker, and router forwards from the internet. It never logs in, tries a password, sends commands to equipment or changes a setting. Only private address ranges this computer is on (or other segments of your own network that you confirm), at most 1,024 addresses, one connection at a time per device. List fragile equipment, like older industrial or medical controllers, under `exclude` and it's never touched:
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
"network": { "ranges": ["192.168.1.0/24"], "routed": ["192.168.20.0/24"], "exclude": ["192.168.1.250"] }
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
- **This machine:** SSH server settings and host keys, OpenSSL settings, certificates on disk, and on Windows the TLS settings and machine certificate store. Read only. It changes nothing and never reads private key files.
|
|
156
|
+
|
|
157
|
+
Two more parts of the report aren't scans:
|
|
158
|
+
|
|
159
|
+
- **Who can read your cloud data:** where your Terraform or CloudFormation stores data in cloud storage, databases, disks or backups with keys the provider holds, or with your key in the provider's key service. Those keys protect against a stolen disk, not against the provider, someone working there, or a legal demand made to them. For data no third party should be able to read, it recommends encrypting before upload or keeping the keys in an external key store you hold. Listed as advice, not scored.
|
|
160
|
+
- **People and process:** 18 optional yes/no questions about what no scan can see: phishing and social-engineering training, call-back checks on payment and password requests, multi-factor sign-in, admin accounts, leavers, vendor access, default passwords, firmware, printer job storage, guest and payment network separation, containment, sandboxing, cloud keys, backups, a breach plan and logs. Your answers get their own score next to the technical findings. They're saved in `benthic-map/people.json`, kept out of the scope file, and never sent anywhere.
|
|
161
|
+
|
|
162
|
+
Results get the same readiness grade as a code scan, and are ranked by when to act: broken now, at risk from data recorded now and read later, long-lived signatures, then the rest. Each finding is also rated high, medium or low: internet-facing systems and keys that must stay trusted for years come first, short-lived signatures inside your own systems last. The map is written to `benthic-map/` as `map.html` (a report you can open in any browser and save as a PDF), `map.json`, a CycloneDX CBOM (`map.cbom.json`), the findings as SARIF (`map.sarif.json`, for security tools that read SARIF; code findings point at their file and line) and `activity.log`, which lists every connection and every file read, with the time and the reason. Nothing leaves your machine except the summary below.
|
|
163
|
+
|
|
164
|
+
For pipelines, save your answers to `benthic.scope.json` when asked, then run `benthic map --scope benthic.scope.json`. It checks only what the file lists. Add `--fail-on broken` to fail the build when anything is broken now.
|
|
165
|
+
|
|
166
|
+
## Cloud accounts
|
|
167
|
+
|
|
168
|
+
```sh
|
|
169
|
+
npx @hardkeel/benthic cloud --provider aws
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Reads the encryption settings of your AWS, Azure or Google Cloud account through the provider's own command line tool (`aws`, `az` or `gcloud`) and the sign-in already on your machine, including profiles and single sign-on. It makes only list, describe, get and show calls, from a fixed list built into the tool. It never creates, changes or deletes anything, never uses a key, never reads secrets or private keys, and never asks for, stores or sends credentials.
|
|
173
|
+
|
|
174
|
+
- **AWS:** KMS keys (RSA and elliptic-curve signing and encryption keys, ML-DSA keys), ACM and uploaded IAM certificates (key type, size, expired certificates still in use), and Private CA certificate authorities (including ML-DSA). TLS on Application, Network and Classic Load Balancers (old TLS versions, weak ciphers, plain HTTP with no redirect, and whether key exchange is post-quantum with `ELBSecurityPolicy-TLS13-1-2-Res-PQ-2025-09`), API Gateway custom domains and REST APIs (including the post-quantum `SecurityPolicy_TLS13_1_2_PQ_2025_09`), CloudFront (minimum TLS, plain HTTP to viewers or origins), OpenSearch domains and Transfer Family SFTP and FTP servers (SSH algorithms, and post-quantum key exchange with `TransferSecurityPolicy-2025-03`). Encryption in transit and at rest for ElastiCache, RDS, Aurora, Redshift, EFS and MSK, RDS certificate authorities that have expired or expire soon, default EBS encryption, SSH key pair types, and S3 buckets that accept requests without TLS. CloudFront already offers hybrid ML-KEM to browsers, so that's listed as a strength.
|
|
175
|
+
- **Azure:** Key Vault keys and certificates in every vault you can read, storage accounts that accept plain HTTP, App Service and Functions apps (HTTPS only, minimum TLS version, plain FTP for deployments), and Azure Cache for Redis with its unencrypted port open. Settings Azure now enforces itself, like TLS 1.2 on Storage and SQL, aren't reported.
|
|
176
|
+
- **Google Cloud:** Cloud KMS keys in every location and key ring, including post-quantum ML-DSA, SLH-DSA and ML-KEM keys, load balancer SSL policies (including front ends left on Google's default policy, which accepts TLS 1.0), load balancer certificates, and Cloud SQL databases that accept unencrypted connections or whose server certificate authority is expiring.
|
|
177
|
+
|
|
178
|
+
A full AWS account with every region takes a few minutes, because each region is read separately. Use `--region` to check fewer.
|
|
179
|
+
|
|
180
|
+
```sh
|
|
181
|
+
benthic cloud --provider aws --profile prod --region us-east-1,us-west-2
|
|
182
|
+
benthic cloud --provider aws,azure,gcp --cbom cloud.cbom.json --report cloud-report.md --html cloud.html
|
|
183
|
+
benthic cloud --provider gcp --project my-project --format sarif --output cloud.sarif.json
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
| Option | What it does |
|
|
187
|
+
| --- | --- |
|
|
188
|
+
| `--provider aws,azure,gcp` | Which accounts to read. Required |
|
|
189
|
+
| `--profile <name>` | AWS profile. Default: your default profile |
|
|
190
|
+
| `--region <list>` | AWS regions. Default: every region enabled for the account |
|
|
191
|
+
| `--subscription <list>` | Azure subscriptions. Default: the current one |
|
|
192
|
+
| `--project <list>` | Google Cloud projects. Default: the current one |
|
|
193
|
+
| `--location <list>` | Google Cloud KMS locations. Default: all |
|
|
194
|
+
| `--html <file>` | Write the report as HTML, ready to save as a PDF |
|
|
195
|
+
|
|
196
|
+
`--cbom`, `--report`, `--format`, `--output`, `--fail-on broken` and `--offline` work as they do for a code scan. Results get the same tiers and high, medium and low ratings as `map`. You can also add cloud accounts to `benthic map`, which asks first, or to a scope file:
|
|
197
|
+
|
|
198
|
+
```json
|
|
199
|
+
"cloud": { "aws": { "profile": "prod", "regions": ["us-east-1"] }, "azure": { "subscriptions": ["..."] }, "gcp": { "projects": ["my-project"] } }
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Nothing about your account leaves your machine. The anonymized summary holds only rule ids and algorithm names, never account ids, ARNs, resource names or regions.
|
|
203
|
+
|
|
204
|
+
### Read-only permissions
|
|
205
|
+
|
|
206
|
+
AWS: attach this policy to the role or user you sign in with. The AWS-managed `ReadOnlyAccess` policy also covers it. Checking who you're signed in as needs no permission. A KMS key whose key policy doesn't allow IAM access is listed as not checked. Reading an uploaded certificate returns only the public certificate, never its private key.
|
|
207
|
+
|
|
208
|
+
```json
|
|
209
|
+
{
|
|
210
|
+
"Version": "2012-10-17",
|
|
211
|
+
"Statement": [
|
|
212
|
+
{
|
|
213
|
+
"Sid": "BenthicReadOnly",
|
|
214
|
+
"Effect": "Allow",
|
|
215
|
+
"Action": [
|
|
216
|
+
"ec2:DescribeRegions",
|
|
217
|
+
"ec2:GetEbsEncryptionByDefault",
|
|
218
|
+
"ec2:DescribeKeyPairs",
|
|
219
|
+
"kms:ListKeys",
|
|
220
|
+
"kms:ListAliases",
|
|
221
|
+
"kms:DescribeKey",
|
|
222
|
+
"acm:ListCertificates",
|
|
223
|
+
"acm-pca:ListCertificateAuthorities",
|
|
224
|
+
"iam:ListServerCertificates",
|
|
225
|
+
"iam:GetServerCertificate",
|
|
226
|
+
"elasticloadbalancing:DescribeLoadBalancers",
|
|
227
|
+
"elasticloadbalancing:DescribeListeners",
|
|
228
|
+
"elasticloadbalancing:DescribeSSLPolicies",
|
|
229
|
+
"elasticloadbalancing:DescribeLoadBalancerPolicies",
|
|
230
|
+
"cloudfront:ListDistributions",
|
|
231
|
+
"apigateway:GET",
|
|
232
|
+
"es:ListDomainNames",
|
|
233
|
+
"es:DescribeDomains",
|
|
234
|
+
"elasticache:DescribeReplicationGroups",
|
|
235
|
+
"elasticache:DescribeCacheClusters",
|
|
236
|
+
"rds:DescribeDBInstances",
|
|
237
|
+
"rds:DescribeDBClusters",
|
|
238
|
+
"redshift:DescribeClusters",
|
|
239
|
+
"elasticfilesystem:DescribeFileSystems",
|
|
240
|
+
"kafka:ListClustersV2",
|
|
241
|
+
"transfer:ListServers",
|
|
242
|
+
"transfer:DescribeServer",
|
|
243
|
+
"transfer:DescribeSecurityPolicy",
|
|
244
|
+
"s3:ListAllMyBuckets",
|
|
245
|
+
"s3:GetBucketPolicy"
|
|
246
|
+
],
|
|
247
|
+
"Resource": "*"
|
|
248
|
+
}
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
`apigateway:GET` covers only reads. API Gateway has no narrower read permission.
|
|
254
|
+
|
|
255
|
+
Azure: `Reader` on the subscription and `Key Vault Reader` on the vaults (or, for vaults using access policies, Get and List on keys and certificates). Reader can't see app settings or connection strings, and the tool doesn't ask for them.
|
|
256
|
+
|
|
257
|
+
Google Cloud: `roles/cloudkms.viewer`, `roles/compute.viewer` and `roles/cloudsql.viewer` on the project.
|
|
258
|
+
|
|
259
|
+
If a permission is missing, that service is listed as not checked and the rest still runs.
|
|
260
|
+
|
|
261
|
+
## Leaving out findings you've reviewed
|
|
262
|
+
|
|
263
|
+
Add a `.benthic-ignore` file to the scanned folder:
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
# a check everywhere
|
|
267
|
+
rule:py-weak-hash
|
|
268
|
+
# a folder or a file
|
|
269
|
+
legacy/
|
|
270
|
+
tools/migrate.py
|
|
271
|
+
# one check in one file
|
|
272
|
+
src/hash.py:py-weak-hash
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
A leaked key or password can only be left out by naming its file, never by check or folder alone.
|
|
276
|
+
|
|
277
|
+
The ignore file arrives with the code, so the scan says how many findings it hid, and how many of those were leaked keys, in the text output, `--format json` (`suppressed`), SARIF (`runs[0].properties.suppressed`) and the migration report. Review changes to `.benthic-ignore` the way you review code. To scan changes from people you don't know, add `--no-repo-config`, and keep your own ignore file outside the code with `--ignore-file`.
|
|
278
|
+
|
|
279
|
+
For `benthic map`, the same file in the folder you run it from can accept a known leftover on a website or this machine, for example a setting your host won't let you change:
|
|
280
|
+
|
|
281
|
+
```
|
|
282
|
+
# one check on one site
|
|
283
|
+
example.com:443:web-tls-static-rsa
|
|
284
|
+
# everything on one site, any port
|
|
285
|
+
legacy.example.com
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Accepted items still appear in the report, in their own section, but don't count toward the score.
|
|
289
|
+
|
|
290
|
+
## Your own policy
|
|
291
|
+
|
|
292
|
+
Put a `.benthic.yml` at the top of the repository, or pass `--policy <file>`:
|
|
293
|
+
|
|
294
|
+
```yaml
|
|
295
|
+
name: Acme encryption policy
|
|
296
|
+
deny: [SHA-1, 3DES, RSA-1024] # not allowed anywhere, in findings or the inventory
|
|
297
|
+
min-key-size:
|
|
298
|
+
RSA: 3072
|
|
299
|
+
AES: 256
|
|
300
|
+
allow: # agreed exceptions, each with a reason
|
|
301
|
+
- path: legacy/**
|
|
302
|
+
algorithm: RSA
|
|
303
|
+
reason: The payments partner only takes RSA until its 2027 upgrade
|
|
304
|
+
expires: 2027-06-30
|
|
305
|
+
severity: # by algorithm or rule id
|
|
306
|
+
MD5: critical
|
|
307
|
+
fail: true # same as --fail-on policy
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Each break of the policy is listed with its file and line. An exception past its `expires` date stops counting and is reported, and so is an exception that no longer matches anything. A policy changes severities in the report, SARIF, SonarQube and JSON output, but never the grade, which is the same for everyone. A mistake in the file stops the run with exit code 2 and the line it's on.
|
|
311
|
+
|
|
312
|
+
## Evidence for a compliance review
|
|
313
|
+
|
|
314
|
+
```
|
|
315
|
+
benthic evidence . --scope scope.yml --out crypto-inventory
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Writes a cryptographic inventory for a review such as PCI DSS 12.3.3: every protocol version, cipher suite and encryption method in use, the strong ones too, not only the problems. Each row has its system, whether that system handles cardholder data, a purpose, where it was seen (file and line, live host or cloud account), and how it holds up today and against a quantum computer, with the source for that rating (NIST SP 800-52r2, RFC 8996 and the like). There's no grade.
|
|
319
|
+
|
|
320
|
+
- **Cipher suites are expanded.** An OpenSSL cipher string like `HIGH:!aNULL:!MD5` is turned into the suites it actually enables, and so is a named cloud policy, like `ELBSecurityPolicy-TLS13-1-2-2021-06` or `AppGwSslPolicy20220101`. Settings are read from nginx, Apache, HAProxy, sshd and ssh config, Terraform and CloudFormation, Kubernetes ingress annotations, and Node, Go, Java and Python code.
|
|
321
|
+
- **Live checks.** For each host the scope names, it makes read-only handshakes, one at a time, to list every TLS version and suite the server accepts and its certificate's issuer and expiry. An `ssh://` host, or port 22, lists every SSH algorithm offered. `--no-live` skips them. A saved `benthic cloud --format json` result can be added with `--cloud`.
|
|
322
|
+
- **The scope is yours.** `--scope` names which folders, hosts and cloud accounts make up each system. It's never read from the scanned folder by itself, and `.benthic-ignore` isn't read either, so nothing in the code can quietly hide a finding. What's found outside the scope goes in an appendix, not the inventory.
|
|
323
|
+
- **Ready for review.** The pack has a review record (reviewer, role, date, a decision for each weak or legacy item, next review due and a signature line), a plan for when an algorithm breaks, a table of how it lines up with 12.3.3 and notes on 4.2.1, 4.2.1.1 and 3.6/3.7. Pass last year's `crypto-inventory.json` with `--baseline` to list what changed. Leaked keys go in their own appendix, masked.
|
|
324
|
+
- **Proof of what was scanned.** The commit, whether it had uncommitted changes, the rules version and date, the hash of the scope file, and a `manifest.sha256` of the three files written.
|
|
325
|
+
|
|
326
|
+
It writes `crypto-inventory.md`, `.csv` and `.json`. `--fail-on weak` exits with 1 when anything in scope is rated weak. Nothing is sent to Hard Keel. The pack is input to your own review; it is not an assessment by a QSA or a Report on Compliance. Run `benthic evidence --help` for a scope file example.
|
|
327
|
+
|
|
328
|
+
## Comparing two inventories
|
|
329
|
+
|
|
330
|
+
```
|
|
331
|
+
benthic diff before.cbom.json after.cbom.json
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Lists the encryption methods and libraries added, removed and changed (risk, version, properties or where they're used) between two CycloneDX CBOMs, from this tool or any other. Assets are matched on their OID plus parameter set or curve, so two tools that name the same algorithm differently (`ML-DSA-65` and `ML-DSA (FIPS 204)`) still line up; names are only compared when an asset has no OID. Between two tools, a field only one of them writes isn't counted as a change. Add `--format json` for the full result, and `--fail-on added,removed,changed,new-risk` to fail CI. `new-risk` fails only when something weak or quantum-breakable was added or got worse.
|
|
335
|
+
|
|
336
|
+
## How findings are traced
|
|
337
|
+
|
|
338
|
+
A constant is followed from where it's set to where it's used, in the same file or in another file that imports it. A value passed into a function is followed to the call inside it, up to three calls deep, and a default value counts when a caller leaves the argument out. Calls from tests, examples and docs don't count. A traced finding shows the lines it came through:
|
|
339
|
+
|
|
340
|
+
```
|
|
341
|
+
python/digest.py:5 MD5 hash
|
|
342
|
+
from python/accounts.py:3 LEGACY_HASH = "md5"
|
|
343
|
+
from python/accounts.py:7 password_digest() is called with algo = "md5"
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
In SARIF the same lines are related locations and a code flow, and in SonarQube they're secondary locations. This is not full data-flow analysis: values built at run time, kept in objects, or reached through dynamic dispatch are not followed.
|
|
347
|
+
|
|
348
|
+
## Anonymized sharing
|
|
349
|
+
|
|
350
|
+
We share anonymized, aggregated usage stats about how our checks perform and what kinds of encryption they find, to improve our products. It never includes your code, keys, files, server names, IP addresses or company name. You can turn this off at any time, or run fully offline.
|
|
351
|
+
|
|
352
|
+
**In CI pipelines nothing is sent.** When `CI` or `GITHUB_ACTIONS` is set, the scan makes no outbound call unless you turn sharing on with `BENTHIC_SHARING=on`. A build that must not call out to anything it hasn't approved can run the scan as is.
|
|
353
|
+
|
|
354
|
+
Everything is rounded into bands and tied to a random ID that links to nothing. Industry and company size are optional, and asked once. To see exactly what a run sends, run `benthic config show-shared`. Details: [hardkeel.com/privacy](https://hardkeel.com/privacy/).
|
|
355
|
+
|
|
356
|
+
| Command | What it does |
|
|
357
|
+
| --- | --- |
|
|
358
|
+
| `benthic config show-shared` | Shows exactly what the last run sent, or would have sent |
|
|
359
|
+
| `benthic config sharing off` | Turns sharing off (or set `BENTHIC_SHARING=off`) |
|
|
360
|
+
| `BENTHIC_SHARING=on` | Turns sharing on in a CI pipeline, where it is off by default |
|
|
361
|
+
| `--offline` | Sends nothing at all (or set `BENTHIC_OFFLINE=1`, or `benthic config offline on`) |
|
|
362
|
+
|
|
363
|
+
`DO_NOT_TRACK=1` is respected too.
|
|
364
|
+
|
|
365
|
+
## SARIF and CycloneDX
|
|
366
|
+
|
|
367
|
+
Results drop into the security tools you already use.
|
|
368
|
+
|
|
369
|
+
**SARIF 2.1.0** (`--format sarif`) for GitHub code scanning and any tool that reads SARIF.
|
|
370
|
+
|
|
371
|
+
- One rule per kind of problem, with ids that stay the same from run to run, like `weak-now/md5-hash`, `quantum-vulnerable/rsa-key` or `secret/aws-access-key`.
|
|
372
|
+
- Each rule carries a `security-severity` score, so code scanning sorts alerts into Critical, High, Medium and Low. Anything to fix now (weak encryption, exposed settings, leaked keys) is an error. Encryption quantum computers will break is a warning, scored Medium or lower, so it lands in the plan rather than ahead of what is broken today.
|
|
373
|
+
- Rules have help text with the fix. Paths are relative to the repository root, even when you scan a subfolder, and each result has a fingerprint that survives lines moving.
|
|
374
|
+
- `benthic map` also writes `map.sarif.json`. Code findings point to files and lines; findings on websites, network equipment and this machine name the site, address or setting instead. GitHub code scanning only shows results tied to a file, so upload the code scan's output there.
|
|
375
|
+
|
|
376
|
+
**CycloneDX 1.6 CBOM** (`--cbom <file>`, or `--format cyclonedx` to print it) for Dependency-Track and other CycloneDX tools.
|
|
377
|
+
|
|
378
|
+
- Every encryption method in use is a cryptographic asset, not only the ones to fix, with its primitive, key size or parameter set, what it's used for, its object identifier where one applies, its NIST quantum security level (0 means no protection against a quantum attacker), and every file and line or host where it was seen.
|
|
379
|
+
- Every TLS version in use is a protocol asset with the cipher suites it allows, by name and code, and SSH is one asset with its key exchange, cipher, MAC and host key algorithms. TLS and SSH findings are protocol assets of the right type. Certificate problems, like an expired certificate, are findings, not encryption methods, so they stay out of the inventory.
|
|
380
|
+
- Certificates and public keys found in files or on websites are their own assets, with subject, issuer, validity dates, signature algorithm and key, linked to the algorithm they use. Curves and classical security levels are listed too.
|
|
381
|
+
- Post-quantum encryption already in use (ML-KEM, ML-DSA, SLH-DSA and hybrids) is marked `quantum-safe`, so the inventory shows progress as well as problems.
|
|
382
|
+
|
|
383
|
+
**SonarQube** (`--format sonar`) in SonarQube's generic external issue format, read by SonarQube Server 10.3 and later and SonarQube Cloud. Point `sonar.externalIssuesReportPaths` at the file:
|
|
384
|
+
|
|
385
|
+
```
|
|
386
|
+
benthic . --offline --format sonar --output benthic.sonar.json
|
|
387
|
+
sonar-scanner -Dsonar.externalIssuesReportPaths=benthic.sonar.json
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
Each kind of problem is its own rule, with severity and impact set from ours (critical is Blocker, high is High, and so on), an effort estimate, and traced lines as secondary locations. This uses SonarQube's own import, so there's no plugin to install.
|
|
391
|
+
|
|
392
|
+
SARIF and CycloneDX output are checked against the official SARIF 2.1.0 and CycloneDX 1.6 schemas.
|
|
393
|
+
|
|
394
|
+
## In GitHub Actions
|
|
395
|
+
|
|
396
|
+
```yaml
|
|
397
|
+
- uses: actions/checkout@v4
|
|
398
|
+
- uses: Hard-Keel/benthic@v1
|
|
399
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
400
|
+
if: always()
|
|
401
|
+
with:
|
|
402
|
+
sarif_file: quantum-scan.sarif
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
The migration report goes to the job summary. The scan runs once and the step fails with the scanner's own exit code. For pull requests from forks, set `repo-config: false` so the ignore file and policy in the change aren't used, and `ignore-file:` to point at a trusted one. Code scanning results need a public repository or GitHub Advanced Security, and the job needs `security-events: write`. A complete workflow, with a weekly scan and the encryption inventory saved as an artifact, is in [docs/examples/code-scanning.yml](docs/examples/code-scanning.yml). Nothing is sent from a pipeline unless you set `BENTHIC_SHARING: on` in the job's `env`.
|
|
406
|
+
|
|
407
|
+
## Contributing
|
|
408
|
+
|
|
409
|
+
Bug reports, false positives, rule requests and ideas are welcome as [issues](https://github.com/Hard-Keel/benthic/issues/new/choose). Hard Keel writes every line of the scanner, so pull requests from outside the team aren't accepted. See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
410
|
+
|
|
411
|
+
## On every pull request
|
|
412
|
+
|
|
413
|
+
[Install Hard Keel Benthic on GitHub](https://github.com/apps/hard-keel-quantum-scan) to run the same checks on every pull request with nothing to set up. It comments on the pull request, posts a check result, and keeps a report link for each repository that stays current.
|
|
414
|
+
|
|
415
|
+
Built by [Hard Keel](https://hardkeel.com). Questions: contact@hardkeel.com. Security reports: security@hardkeel.com.
|
|
416
|
+
|
|
417
|
+
## License
|
|
418
|
+
|
|
419
|
+
Source available under the PolyForm Shield License 1.0.0 ([PolyForm-Shield-1.0.0](LICENSE)). You can read, build and audit every line, and use the scanner on your own code and systems, at work too. The one thing it rules out is using it, or something built from it, to compete with Hard Keel: offering a product that competes with the scanner or with anything Hard Keel offers using it.
|
|
420
|
+
|
|
421
|
+
What the scanner makes for you (reports, CBOMs, SARIF files, badges and plans) is yours to use however you want. The license covers the scanner's code only.
|
|
422
|
+
|
|
423
|
+
Versions 0.7.0 and earlier were released under the Apache License 2.0 and stay under it.
|
|
424
|
+
|
|
425
|
+
Copyright 2026 Hard Keel ([hardkeel.com](https://hardkeel.com)).
|
package/action.yml
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: Hard Keel Benthic
|
|
2
|
+
description: Find encryption quantum computers will break, weak encryption, exposed infrastructure settings and leaked keys, and write an encryption inventory.
|
|
3
|
+
author: Hard Keel
|
|
4
|
+
branding:
|
|
5
|
+
icon: shield
|
|
6
|
+
color: gray-dark
|
|
7
|
+
inputs:
|
|
8
|
+
path:
|
|
9
|
+
description: Folder to scan
|
|
10
|
+
default: "."
|
|
11
|
+
fail-on:
|
|
12
|
+
description: "Fail the step on these: secret, weak-now, exposed, quantum-vulnerable, or none"
|
|
13
|
+
default: "secret,weak-now,exposed"
|
|
14
|
+
sarif:
|
|
15
|
+
description: Where to write SARIF results, for GitHub code scanning
|
|
16
|
+
default: quantum-scan.sarif
|
|
17
|
+
cbom:
|
|
18
|
+
description: Where to write the encryption inventory (CycloneDX 1.6 CBOM)
|
|
19
|
+
default: quantum-scan.cbom.json
|
|
20
|
+
report:
|
|
21
|
+
description: Where to write the migration report (Markdown)
|
|
22
|
+
default: quantum-scan-report.md
|
|
23
|
+
repo-config:
|
|
24
|
+
description: "Read .benthic-ignore and the policy file from the scanned folder. Set to false for pull requests from people you don't know, so a change can't hide its own findings."
|
|
25
|
+
default: "true"
|
|
26
|
+
ignore-file:
|
|
27
|
+
description: A trusted ignore file to use instead, for example one kept outside the scanned code
|
|
28
|
+
default: ""
|
|
29
|
+
outputs:
|
|
30
|
+
sarif:
|
|
31
|
+
description: Path of the SARIF file
|
|
32
|
+
value: ${{ inputs.sarif }}
|
|
33
|
+
runs:
|
|
34
|
+
using: composite
|
|
35
|
+
steps:
|
|
36
|
+
- shell: bash
|
|
37
|
+
env:
|
|
38
|
+
QS: ${{ github.action_path }}/dist/cli.js
|
|
39
|
+
IN_PATH: ${{ inputs.path }}
|
|
40
|
+
IN_FAIL: ${{ inputs.fail-on }}
|
|
41
|
+
IN_SARIF: ${{ inputs.sarif }}
|
|
42
|
+
IN_CBOM: ${{ inputs.cbom }}
|
|
43
|
+
IN_REPORT: ${{ inputs.report }}
|
|
44
|
+
REPO: ${{ github.repository }}
|
|
45
|
+
IN_REPO_CONFIG: ${{ inputs.repo-config }}
|
|
46
|
+
IN_IGNORE: ${{ inputs.ignore-file }}
|
|
47
|
+
run: |
|
|
48
|
+
args=("$IN_PATH" --name "$REPO" --format sarif --output "$IN_SARIF" --cbom "$IN_CBOM" --report "$IN_REPORT" --fail-on "$IN_FAIL")
|
|
49
|
+
if [ "$IN_REPO_CONFIG" = "false" ]; then args+=(--no-repo-config); fi
|
|
50
|
+
if [ -n "$IN_IGNORE" ]; then args+=(--ignore-file "$IN_IGNORE"); fi
|
|
51
|
+
status=0
|
|
52
|
+
node "$QS" "${args[@]}" || status=$?
|
|
53
|
+
if [ -f "$IN_REPORT" ]; then cat "$IN_REPORT" >> "$GITHUB_STEP_SUMMARY"; fi
|
|
54
|
+
exit $status
|
package/dist/agility.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// SPDX-License-Identifier: PolyForm-Shield-1.0.0
|
|
2
|
+
// Copyright 2026 Hard Keel (https://hardkeel.com)
|
|
3
|
+
// Encryption agility: the smallest lattice parameter sets, and how much of the post-quantum
|
|
4
|
+
// encryption in use rests on lattice math alone. ML-KEM and ML-DSA are NIST's standards and stay the
|
|
5
|
+
// right default. A hybrid key exchange, and a hash-based signature where keys must last, keep a
|
|
6
|
+
// system covered if attacks on lattices improve. Advice only: nothing here changes the grade or
|
|
7
|
+
// fails a build.
|
|
8
|
+
const KEM_512 = "ML-KEM-512 is the smallest ML-KEM parameter set (NIST category 1). It isn't broken, but it leaves the least room if attacks on lattice math keep improving. Use ML-KEM-768 or ML-KEM-1024 for new work, ideally as a hybrid such as X25519MLKEM768.";
|
|
9
|
+
const DSA_44 = "ML-DSA-44 is the smallest ML-DSA parameter set (NIST category 2). It isn't broken, but it leaves the least room if attacks on lattice math keep improving. Use ML-DSA-65 or ML-DSA-87, above all for keys that must last, such as root or firmware signing keys.";
|
|
10
|
+
/** The note for ML-KEM-512 and ML-DSA-44 (Kyber512 and Dilithium2 are named the same way). Still post-quantum, still listed as such. */
|
|
11
|
+
export function latticeLevelCaution(algorithm) {
|
|
12
|
+
const caution = algorithm === "ML-KEM-512" ? KEM_512 : algorithm === "ML-DSA-44" ? DSA_44 : undefined;
|
|
13
|
+
return caution ? { risk: "quantum-safe", caution } : {};
|
|
14
|
+
}
|
|
15
|
+
/** Hash-based signature families: their security rests on the hash, not on lattices. */
|
|
16
|
+
const HASH_BASED = new Set(["SLH-DSA", "LMS", "XMSS", "XMSS^MT", "HSS-Lanyard"]);
|
|
17
|
+
function signalKind(s) {
|
|
18
|
+
if (s.algorithm === "Hybrid ML-KEM key exchange")
|
|
19
|
+
return "kem-hybrid";
|
|
20
|
+
if (s.algorithm === "ML-KEM")
|
|
21
|
+
return "kem-lattice";
|
|
22
|
+
if (s.algorithm === "ML-DSA" || s.algorithm === "FN-DSA")
|
|
23
|
+
return "sig-lattice";
|
|
24
|
+
if (s.algorithm === "SLH-DSA")
|
|
25
|
+
return "sig-hash";
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
function itemKind(i) {
|
|
29
|
+
// A hybrid is named for its classical half first: X25519MLKEM768, SecP256r1MLKEM768.
|
|
30
|
+
if (i.family === "ML-KEM")
|
|
31
|
+
return i.algorithm.startsWith("ML-KEM") ? "kem-lattice" : "kem-hybrid";
|
|
32
|
+
if (i.family === "ML-DSA" || i.family === "FN-DSA")
|
|
33
|
+
return "sig-lattice";
|
|
34
|
+
if (HASH_BASED.has(i.family))
|
|
35
|
+
return "sig-hash";
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const plural = (n, one, many = one + "s") => `${n} ${n === 1 ? one : many}`;
|
|
39
|
+
/** How much of the post-quantum encryption found rests on lattice math alone, with calm advice where all of it does. */
|
|
40
|
+
export function pqcReliance(pqc, inventory) {
|
|
41
|
+
// One kind per place and use; on a line that names both, the hybrid wins.
|
|
42
|
+
const at = new Map();
|
|
43
|
+
const add = (kind, file, line) => {
|
|
44
|
+
if (!kind)
|
|
45
|
+
return;
|
|
46
|
+
const key = `${kind.slice(0, 3)}|${file}|${line}`;
|
|
47
|
+
if (at.get(key) !== "kem-hybrid")
|
|
48
|
+
at.set(key, kind);
|
|
49
|
+
};
|
|
50
|
+
for (const s of pqc)
|
|
51
|
+
add(signalKind(s), s.file, s.line);
|
|
52
|
+
for (const i of inventory)
|
|
53
|
+
add(itemKind(i), i.file, i.line);
|
|
54
|
+
const count = (k) => [...at.values()].filter((v) => v === k).length;
|
|
55
|
+
const keyExchange = { latticeOnly: count("kem-lattice"), hybrid: count("kem-hybrid") };
|
|
56
|
+
const signatures = { lattice: count("sig-lattice"), hashBased: count("sig-hash") };
|
|
57
|
+
const notes = [];
|
|
58
|
+
if (keyExchange.latticeOnly && !keyExchange.hybrid)
|
|
59
|
+
notes.push(`Post-quantum key exchange here is ML-KEM on its own (${plural(keyExchange.latticeOnly, "place")}), with no hybrid. ML-KEM is the NIST standard and the right choice. Pairing it with X25519, as X25519MLKEM768 does, keeps the key exchange safe even if attacks on lattice math improve.`);
|
|
60
|
+
if (signatures.lattice && !signatures.hashBased)
|
|
61
|
+
notes.push(`Post-quantum signatures here all rest on lattice math (${plural(signatures.lattice, "place")}). That's fine today. For keys that must last, such as root or firmware signing keys, SLH-DSA is a NIST standard that rests on hash functions instead.`);
|
|
62
|
+
if (notes.length)
|
|
63
|
+
notes.push("Keep the choice of algorithm in one place, so moving to another one is a configuration change rather than a rewrite.");
|
|
64
|
+
return {
|
|
65
|
+
places: at.size,
|
|
66
|
+
latticeOnly: keyExchange.latticeOnly + signatures.lattice,
|
|
67
|
+
keyExchange,
|
|
68
|
+
signatures,
|
|
69
|
+
notes,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** One line for the text summary: "3 places, 2 resting on lattice math alone." */
|
|
73
|
+
export function relianceLine(r) {
|
|
74
|
+
const rest = r.places - r.latticeOnly;
|
|
75
|
+
if (!r.latticeOnly)
|
|
76
|
+
return `${plural(r.places, "place")}, none resting on lattice math alone.`;
|
|
77
|
+
if (r.latticeOnly === r.places)
|
|
78
|
+
return `${plural(r.places, "place")}, ${r.places === 1 ? "resting" : "all resting"} on lattice math alone.`;
|
|
79
|
+
return `${plural(r.places, "place")}, ${r.latticeOnly} resting on lattice math alone and ${rest} hybrid or hash-based.`;
|
|
80
|
+
}
|
package/dist/badge.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// SPDX-License-Identifier: PolyForm-Shield-1.0.0
|
|
2
|
+
// Copyright 2026 Hard Keel (https://hardkeel.com)
|
|
3
|
+
// README badge for the quantum readiness score, in the familiar flat badge style.
|
|
4
|
+
// Self-contained SVG: no fonts, scripts or outside requests.
|
|
5
|
+
export const BADGE_LABEL = "quantum readiness";
|
|
6
|
+
const LABEL_BG = "#0b1726"; // Hard Keel navy
|
|
7
|
+
export const GRADE_COLOR = {
|
|
8
|
+
"A+": "#2e9e6a",
|
|
9
|
+
A: "#44cc11",
|
|
10
|
+
B: "#97ca00",
|
|
11
|
+
C: "#dfb317",
|
|
12
|
+
D: "#fe7d37",
|
|
13
|
+
F: "#e05d44",
|
|
14
|
+
none: "#9f9f9f",
|
|
15
|
+
};
|
|
16
|
+
// Rough Verdana 11px advance widths, enough to size the badge without loading a font.
|
|
17
|
+
function textWidth(s) {
|
|
18
|
+
let w = 0;
|
|
19
|
+
for (const ch of s) {
|
|
20
|
+
if ("iljI.,:;|!'".includes(ch))
|
|
21
|
+
w += 3.5;
|
|
22
|
+
else if ("ftr( )".includes(ch))
|
|
23
|
+
w += ch === " " ? 3.9 : 4.6;
|
|
24
|
+
else if ("mwMW".includes(ch))
|
|
25
|
+
w += 10.5;
|
|
26
|
+
else if (/[A-Z+]/.test(ch))
|
|
27
|
+
w += 7.6;
|
|
28
|
+
else if (/[0-9]/.test(ch))
|
|
29
|
+
w += 7;
|
|
30
|
+
else if (ch === "·")
|
|
31
|
+
w += 4.5;
|
|
32
|
+
else
|
|
33
|
+
w += 6.6;
|
|
34
|
+
}
|
|
35
|
+
return w;
|
|
36
|
+
}
|
|
37
|
+
function esc(s) {
|
|
38
|
+
return s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
39
|
+
}
|
|
40
|
+
export function badgeMessage(s) {
|
|
41
|
+
return s ? `${s.grade} · ${s.score}` : "not scanned";
|
|
42
|
+
}
|
|
43
|
+
export function badgeSvg(s, label = BADGE_LABEL) {
|
|
44
|
+
const message = badgeMessage(s);
|
|
45
|
+
const color = s ? GRADE_COLOR[s.grade] : GRADE_COLOR.none;
|
|
46
|
+
const lw = Math.round(textWidth(label) + 12);
|
|
47
|
+
const mw = Math.round(textWidth(message) + 12);
|
|
48
|
+
const w = lw + mw;
|
|
49
|
+
const lx = lw / 2;
|
|
50
|
+
const mx = lw + mw / 2;
|
|
51
|
+
const title = `${label}: ${message}`;
|
|
52
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="20" role="img" aria-label="${esc(title)}"><title>${esc(title)}</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="${w}" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="${lw}" height="20" fill="${LABEL_BG}"/><rect x="${lw}" width="${mw}" height="20" fill="${color}"/><rect width="${w}" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="11"><text x="${lx}" y="15" fill="#010101" fill-opacity=".3">${esc(label)}</text><text x="${lx}" y="14">${esc(label)}</text><text x="${mx}" y="15" fill="#010101" fill-opacity=".3">${esc(message)}</text><text x="${mx}" y="14">${esc(message)}</text></g></svg>`;
|
|
53
|
+
}
|
|
54
|
+
/** The shields.io "endpoint" format, for people who prefer to style the badge themselves. */
|
|
55
|
+
export function shieldsEndpoint(s) {
|
|
56
|
+
return { schemaVersion: 1, label: BADGE_LABEL, message: badgeMessage(s), color: s ? GRADE_COLOR[s.grade].slice(1) : "9f9f9f" };
|
|
57
|
+
}
|
|
58
|
+
export const METHOD_URL = "https://hardkeel.com/learn/quantum-readiness-score/";
|
|
59
|
+
/** Markdown a repository owner pastes into their README. */
|
|
60
|
+
export function badgeMarkdown(badgeUrl) {
|
|
61
|
+
return `[](${METHOD_URL})`;
|
|
62
|
+
}
|