How to block weak RSA and ECC regressions in CI and PR review

Block P-256, Ed25519 and RSA-2048 regressions with four layers: AST rules in CI, Capy Review on PRs, config lints on certs, JWKS and proxies, and a TLS 1.3 X25519MLKEM768 smoke test. Start in warning mode, clear existing hits, allowlist legacy verification with expiry dates, then flip to error.
How to block weak RSA and ECC across four layers
Copied TLS configs and defaults reintroduce P-256, Ed25519 and RSA-2048 soon after a post-quantum cryptography (PQC) migration. To hold the floor in the NSA December 2026 PQC checklist, enforce four layers.
| Layer | Tooling | Blocks | Misses |
|---|---|---|---|
| AST rules | ast-grep, Semgrep | P-256, X25519, Ed25519, RSA under 3072 | Variables, wrappers |
| PR review | Capy Review | Variables, wrappers, ALB defaults | Code outside diff |
| Config lint | openssl x509, grep | Weak certs, JWKS, proxy curves | Multi-line YAML |
| TLS smoke | OpenSSL 3.5+, Go | OpenSSL 3.0, failed X25519MLKEM768 | Offline signing |
How to block P-256, Ed25519 and RSA-2048 with AST rules
Point sgconfig.yml at ruleDirs: [rules/pqc] using ast-grep and run ast-grep scan on pull_request. Use kind: selector_expression with a regex in rules/pqc/go-weak-ecc.yml because plain patterns like tls.CurveP256 miss composite literals in ast-grep's Go grammar; tls.X25519MLKEM768 does not match:
id: go-weak-ecc
language: go
severity: error
message: 256-bit curve. Use X25519MLKEM768, P-384 or ML-DSA.
rule:
kind: selector_expression
any:
- regex: '^(elliptic|ecdh)\.P256$'
- regex: '^(ecdh|tls)\.X25519$'
- regex: '^tls\.CurveP256$'
- regex: '^ed25519\.GenerateKey$'
In rules/pqc/go-rsa-size.yml, the regex matches every integer literal 0 to 3071, so 2560 fails as well as 2048; a size in a variable needs the review layer:
id: go-rsa-under-3072
language: go
severity: error
message: RSA keys under 3072 bits are below the NSA interim size.
rule:
pattern: rsa.GenerateKey($R, $BITS)
constraints:
BITS:
regex: '^([0-9]{1,3}|[12][0-9]{3}|30[0-6][0-9]|307[01])$'
Add rules in rules/pqc for TypeScript JWT alg pairs and Node.js or Python cryptography. With Semgrep, metavariable-comparison enforces $BITS < 3072, since use-of-weak-rsa-key only flags RSA keys under 2048 bits.
How to enforce post-quantum rules on every PR with Capy
Syntax rules miss variables, wrappers and defaults like an AWS ALB HTTPS listener falling back to ELBSecurityPolicy-2016-08. Add these bullets under a ## Reviews heading in AGENTS.md so Capy Review flags regressions on every PR:
- Flag new 256-bit elliptic curves (P-256, secp256r1, prime256v1,
standalone X25519) for key exchange or signing. X25519MLKEM768
is allowed.
- Flag new Ed25519 or EdDSA key generation and EdDSA JWT signing.
- Flag RSA keys or certificate requests under 3072 bits. Accept
RSA-3072 or P-384 as interim sizes and ML-DSA as the target.
- Flag TLS listeners or clients that omit X25519MLKEM768, TLS
1.2-only listeners, and AWS ALB HTTPS listeners without an
explicit PQ security policy.
- Flag new ES256 or RS256 JWT signing. Require ES384, PS384 or
ML-DSA-65.
- Ignore test fixtures under testdata/ and code that only verifies
legacy signatures during a dual-key rotation window.
- PR and org rules. Capy Review enforces
AGENTS.mdand org-wide rules in Settings → Review or the review rules API, posting inline comments with incremental re-reviews. - Multi-repo cleanup. Captains split work into one thread per repo, each opening and following its own PR as in the multi-repo guide.
- Isolated cloud microVMs. Each thread clones the repo on its own cloud machine, runs real tests and TLS checks before opening the PR, and wakes to fix findings.
- Scheduled re-scans. Automations run a weekly prompt that opens a PR on weak crypto. Capy never merges unless asked.
How to lint certificates, JWKS files and proxy configs in CI
Audit existing keys with the JWT, SSH and certificate audit guide, then run three heuristic greps:
- Certs. Fail
openssl x509 -noout -texton*.crt/*.pemmatchingprime256v1or 1024/2048-bit RSA. - JWKS. Fail when
jq -e '.keys[] | select(.crv == "P-256" or .kty == "OKP")'finds a key in any*jwks*.json, minified or not. - Proxies. Fail
*.conf,*.yamland*.ymlfiles setting nginxssl_ecdh_curveor Envoyecdh_curveswithoutX25519MLKEM768.
These miss multi-line YAML, templates and runtime libraries, which handshake tests and Capy Review catch.
How to verify X25519MLKEM768 handshakes in CI
Config strings fail on OpenSSL 3.0, which lacks ML-KEM. Boot the service, run a bounded 60-second wait on localhost port 8443, and run openssl s_client restricted to X25519MLKEM768. The client needs OpenSSL 3.5+ and exits non-zero on failure:
openssl version
./bin/my-service &
SERVER_PID=$!
trap 'kill "$SERVER_PID"' EXIT
for i in $(seq 60); do
(exec 3<>/dev/tcp/localhost/8443) 2>/dev/null && break
sleep 1
done
openssl s_client -connect localhost:8443 \
-groups X25519MLKEM768 -tls1_3 < /dev/null
On Go 1.25+, assert ConnectionState.CurveID in go test. Keep the test in the same package as HybridTLSConfig() so editing that config fails the test (imports: crypto/tls, net/http, net/http/httptest, testing):
func TestPQHandshake(t *testing.T) {
h := http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})
srv := httptest.NewUnstartedServer(h)
srv.TLS = HybridTLSConfig()
srv.StartTLS()
defer srv.Close()
resp, err := srv.Client().Get(srv.URL)
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()
if got := resp.TLS.CurveID; got != tls.X25519MLKEM768 {
t.Fatalf("got curve %v, want X25519MLKEM768", got)
}
}
Node.js 24.22.3 ships OpenSSL 3.5.9, where socket.getEphemeralKeyInfo() returns { type: 'TLSGroup', name: 'X25519MLKEM768' }, and Python 3.15 on OpenSSL 3.5.9 returns 'X25519MLKEM768' from SSLSocket.group(). See the post-quantum TLS 1.3 guide.
How to roll out PQC CI gates without stalling PRs
- Warn first. Set
severity: warninginast-grepand keep config lints non-blocking to count hits onmain. - Burn down hits. Group repos in one Capy project, mark quiet repos lazy, and let a Captain open one PR per repo.
- Allowlist dual-key paths. Put
ES256orEd25519verification in dedicated files with an expiry comment, and mirror that inAGENTS.md. - Flip to error. Restore
severity: erroronce clear, require the TLS smoke test, and schedule a weekly Capy automation.
Frequently Asked Questions
Why should CI allow X25519MLKEM768 while blocking standalone X25519?+
Why does Semgrep's default Go RSA rule miss RSA-2048 keys?+
Can a default Linux CI runner execute the OpenSSL TLS 1.3 smoke test?+
How do we allow legacy signature verification during a dual-key window?+
Sources
- NSA: Immediate Actions to Push Toward Post-Quantum (PP-26-4956)
- ast-grep docs: Rule configuration
- Semgrep docs: Rule syntax
- Capy docs: Reviews
Spotted something out of date? Tell us at support@capy.ai.
Block weak crypto on every pull request
Add plain-English post-quantum rules in AGENTS.md or Settings → Review so Capy flags regressions on the changed lines.
- How to block weak RSA and ECC across four layers
- How to block P-256, Ed25519 and RSA-2048 with AST rules
- How to enforce post-quantum rules on every PR with Capy
- How to lint certificates, JWKS files and proxy configs in CI
- How to verify X25519MLKEM768 handshakes in CI
- How to roll out PQC CI gates without stalling PRs
- FAQ
- Sources





