crypto-inventory 0.3.0 and the control-plane planner after the second run on a tree that is not ours (libsignal): BoringSSL, Noise hfs, libcrux Kyber, the libsignal Java/Node API; self-signed trust anchors are blocked, test code is LOW with its own scope

This commit is contained in:
Aere Network committed 2026-10-18 07:52:31 +03:00
1 parent 42b049ef04
commit e453c0c42d
35 files changed
+675 -51

No files matched your search

+12 -2
View File
@@ -25,7 +25,15 @@ Only a finding with no call context (no `api`, no language) keeps the old routin
known, so it is not guessed. The inventory's TLS configuration findings still go to the gateway.
{ ref, asset, problem, current, target, method: "auto-aere" | "manual" | "blocked", product: "gateway" | "kms" | "pki" | null,
how, cn?, primitive?, urgency: "CRITICAL" | "HIGH" | "MEDIUM" | "LOW", blocker, location, source }
how, cn?, primitive?, urgency: "CRITICAL" | "HIGH" | "MEDIUM" | "LOW", blocker, scope: "production" | "test", location, source }
Two rules added on 2026-10-18 after the run on the libsignal tree. A finding in **test code** (`tests/`, `benches/`, `fuzz/`,
`examples/`, `*Test.java`, `*.test.ts`, ...; the path rule lives in `scopulCaii`) stays in the plan but with `scope: "test"`,
urgency `LOW` and a `how` that says so, and `summary.byScope` counts it apart: on libsignal 76 of 197 actions (75 of them HIGH)
were in such files and stood in front of the production call sites. A **self-signed certificate** that is a pinned trust anchor
(valid for more than five years, or whose CN is not a host name: the AMD, Google and AWS attestation roots in libsignal) is
`blocked` with the reason written, not "auto through the PQ PKI": the PKI cannot replace a root the verifier pins, only its owner
can publish a post-quantum one. A short self-signed service certificate for a host name is still reissued by the PKI for the same CN.
Harvest-now-decrypt-later applies to key exchange and encrypted data, **not to signatures** (a signature is public; it is not
harvested), so a classical key exchange on a public endpoint is the only CRITICAL case, and a classical signature is a future
@@ -67,7 +75,9 @@ required property is measured), `UNRESOLVED`, or `UNMEASURED` (the scan failed,
applied the change: `--applied-at`, otherwise the plan's `generatedAt`; with neither, everything is `UNMEASURED`). A domain in the
plan that is not a host name gets no recipe, so no command to copy is built with it. What is measured by us is written on every
recipe (`measured`): the `node` profile end to end; for nginx, Apache and HAProxy only that OpenSSL 3.5 accepts the group list (the
directive comes from their documentation); Go from the 1.24 release notes, not measured.
directive comes from their documentation); nginx and Go measured end to end on 2026-10-18 on real servers started from exactly the recipe's
fragments (nginx 1.31.7 with OpenSSL 3.5.8/3.5.9 in a container, Go 1.26.5): hybrid-only client accepted, TLS 1.2 refused, HSTS sent
(`dovezi/retete-2026-10-18/`); Apache and HAProxy still from their documentation.
## 4. Compliance report: `raport-conformitate.mjs`
+7 -2
View File
@@ -44,9 +44,12 @@ function laPlanificator(g) {
// 2026-10-18: contextul apelului merge la planificator; fara el regula "in cod" (X25519 din aplicatie nu se repara cu un gateway TLS)
// era verde in proba functiei si moarta pe drumul real (planul Avano avea tot 65 de actiuni "auto prin gateway")
api: g.api, language: g.language, protocolType: g.protocolType,
// 2026-10-18 (libsignal): codul de test se deosebeste de productie dupa cale (regula sta in plan-migrare.mjs, intr-un singur loc)
scope: scopulCaii(g.file),
location: g.file ? `${g.file}:${g.line || '?'}` : undefined,
};
}
let scopulCaii = () => 'production';
async function main() {
const args = process.argv.slice(2);
@@ -56,7 +59,9 @@ async function main() {
if (!code) { console.error('usage: node control-plane.mjs --code <dir> [--scan scan.json] [--json]'); process.exit(2); }
const inv = await import(pathToFileURL(caleaInventarului()).href);
const { planeaza } = await import(pathToFileURL(path.join(AICI, 'plan-migrare.mjs')).href);
const plm = await import(pathToFileURL(path.join(AICI, 'plan-migrare.mjs')).href);
const { planeaza } = plm;
scopulCaii = plm.scopulCaii;
let rez; try { rez = inv.scan(code); } catch (e) { console.error('the inventory could not scan: ' + e.message); process.exit(2); }
const clasificate = (rez.findings || []).map(laPlanificator);
@@ -77,7 +82,7 @@ async function main() {
if (jsonOut) { console.log(JSON.stringify(iesire, null, 1)); process.exit(0); }
console.log(`AERE Control Plane - post-quantum migration plan for ${code}${scanFile ? ' + ' + scanFile : ''}`);
console.log(` inventory: ${iesire.inventory.findings} uses, ${iesire.inventory.quantumVulnerable} quantum-vulnerable`);
console.log(` plan: ${plan.summary.total} actions | ${JSON.stringify(plan.summary.byUrgency)} | auto=${plan.summary.autoAere} manual=${plan.summary.manual} blocked=${plan.summary.blocked}`);
console.log(` plan: ${plan.summary.total} actions | ${JSON.stringify(plan.summary.byUrgency)} | auto=${plan.summary.autoAere} manual=${plan.summary.manual} blocked=${plan.summary.blocked} | in test code=${(plan.summary.byScope && plan.summary.byScope.test) || 0}`);
for (const a of plan.actions) {
console.log(` [${a.urgency.padEnd(8)}] ${a.asset}${a.location ? ' (' + a.location + ')' : ''}`);
console.log(` ${a.problem} -> ${a.target} [${a.method}${a.product ? ' via ' + a.product : ''}]${a.blocker ? ' BLOCKED BY: ' + a.blocker : ''}`);
@@ -0,0 +1,22 @@
# Retetele de remediere `go` si `nginx`, masurate cap la cap, 2026-10-18 04:28Z-04:31Z
Pana azi `remediere.mjs` spunea despre profilul `nginx` "the server directive from the nginx documentation, not measured by us on a
real nginx" si despre `go` "from the Go 1.24 release notes; not measured by us (the Go on the test machine is 1.22)". Masurat azi, cu
EXACT fragmentele pe care le scrie reteta pentru `hndl-exposed` + `tls12-accepted` + `hsts-missing` (setarile: grupurile
`X25519MLKEM768:X25519`, versiunea minima 1.3, HSTS un an), fiecare server pornit pe 127.0.0.1 si sondat cu Node 24 (`tls-sonda.mjs`:
o strangere de mana reala cu grupurile oferite si, optional, cu versiunea maxima) si cu `curl -k` pentru antet:
| | Go (`go/main.go`, laptop) | nginx (`masoara-nginx-rpc2.sh`, container pe rpc2) |
|---|---|---|
| serverul | Go **1.26.5** windows/amd64, `&tls.Config{MinVersion: tls.VersionTLS13, CurvePreferences: []tls.CurveID{tls.X25519MLKEM768, tls.X25519}}`, `w.Header().Set("Strict-Transport-Security", "max-age=31536000")` | **nginx 1.31.7** din `nginx:alpine`, "built with OpenSSL 3.5.8 (running with OpenSSL 3.5.9)"; `ssl_ecdh_curve X25519MLKEM768:X25519; ssl_protocols TLSv1.3; add_header Strict-Transport-Security "max-age=31536000" always;`; `nginx -t` ok |
| client care ofera numai `X25519MLKEM768` | reusit (TLSv1.3, TLS_AES_128_GCM_SHA256) | reusit (TLSv1.3, grup raportat `X25519MLKEM768`) |
| client care ofera numai `X25519` (rezerva din reteta) | reusit, grup `X25519` | reusit, grup `X25519` |
| client `X25519MLKEM768:X25519` | reusit | reusit, grupul ales `X25519MLKEM768` |
| client TLS 1.2 | **refuzat** `ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION` | **refuzat** `ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION` |
| HSTS | `Strict-Transport-Security: max-age=31536000` | `Strict-Transport-Security: max-age=31536000` |
| scanerul AERE pe server (`scaneaza-local.mjs`, `scaneazaAdresa` pe 127.0.0.1) | `pqKeyExchange X25519MLKEM768, prefersPqWhenOffered true, tls12Accepted false, hsts true`; scor 70 numai din certificatul de proba (autosemnat, 2 zile: `cert-expiring`, `chain-untrusted`) | NEMASURAT cu scanerul (modulul nu e instalat pe rpc2 in forma importabila); sondele si curl-ul acopera aceleasi fapte |
| curatenie | serverul oprit, binarul sters | container si imagine sterse; RPC-ul local 11 -> 13 ms |
Ce NU s-a masurat: Apache si HAProxy (nimic pe nicio gazda a noastra; raman "din documentatie"), un nginx de productie cu configuratia
lui intreaga (aici un singur `server {}` de proba), Go sub Windows numai (Linux NEMASURAT; Go-ul din WSL e 1.22, sub 1.24), clienti
reali (browsere) spre aceste servere. Jurnalele: `masoara-go.log`, `masoara-nginx.log`.
@@ -0,0 +1,48 @@
// Serverul de proba al retetei Go din remediere.mjs (profilul `go`, pentru hndl-exposed + tls12-accepted + hsts-missing):
// &tls.Config{MinVersion: tls.VersionTLS13, CurvePreferences: []tls.CurveID{tls.X25519MLKEM768, tls.X25519}}
// w.Header().Set("Strict-Transport-Security", "max-age=31536000")
// Certificat autosemnat generat la pornire (ECDSA P-256), asculta pe 127.0.0.1:<port>, raspunde "ok" la orice cale.
package main
import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"fmt"
"log"
"math/big"
"net/http"
"os"
"runtime"
"time"
)
func main() {
port := "8445"
if len(os.Args) > 1 {
port = os.Args[1]
}
key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
log.Fatal(err)
}
tmpl := &x509.Certificate{SerialNumber: big.NewInt(1), Subject: pkix.Name{CommonName: "proba.local"}, NotBefore: time.Now().Add(-time.Hour), NotAfter: time.Now().Add(48 * time.Hour), DNSNames: []string{"proba.local", "localhost"}}
der, err := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &key.PublicKey, key)
if err != nil {
log.Fatal(err)
}
cert := tls.Certificate{Certificate: [][]byte{der}, PrivateKey: key}
// EXACT fragmentul retetei (remediere.mjs, profilul go, setarile groups + tlsMin 1.3 + hsts):
cfg := &tls.Config{MinVersion: tls.VersionTLS13, CurvePreferences: []tls.CurveID{tls.X25519MLKEM768, tls.X25519}, Certificates: []tls.Certificate{cert}}
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Strict-Transport-Security", "max-age=31536000")
fmt.Fprintln(w, "ok")
})
srv := &http.Server{Addr: "127.0.0.1:" + port, Handler: mux, TLSConfig: cfg}
fmt.Printf("listening 127.0.0.1:%s go=%s\n", port, runtime.Version())
log.Fatal(srv.ListenAndServeTLS("", ""))
}
@@ -0,0 +1,30 @@
#!/bin/bash
# masoara-go.sh: reteta Go a remedierii (profilul `go`) masurata cap la cap pe laptop: serverul din main.go (EXACT fragmentul retetei),
# construit cu Go-ul de pe Windows, pornit pe 127.0.0.1:8445; sonde Node 24 (OpenSSL 3.5.x): hibrid singur (trebuie ok), X25519 singur
# (reteta il lasa ca rezerva: trebuie ok, grup X25519), client TLS 1.2 (MinVersion 1.3: trebuie refuzat), HSTS prin curl -k, si scanerul
# AERE pe server (ce ar vedea clientul dupa reteta). Serverul e oprit la sfarsit; codul final e 0 numai cu toate cum trebuie.
set -u
D="$(cd "$(dirname "$0")" && pwd)"
cd "$D/go" || exit 2
echo "== go"; go version
go build -o proba-go-tls.exe main.go || { echo "build cazut"; exit 1; }
./proba-go-tls.exe 8445 > "$D/go-server.log" 2>&1 &
PID=$!
sleep 2
echo "server: $(head -1 "$D/go-server.log")"
rele=0
cere() { # $1 nume, $2 cod asteptat, $3... comanda
local nume="$1" ast="$2"; shift 2
out=$("$@" 2>&1); c=$?
if [ "$c" = "$ast" ]; then echo " OK $nume -> cod $c: $(printf '%s' "$out" | cut -c1-170)"; else echo " RAU $nume -> cod $c (asteptat $ast): $(printf '%s' "$out" | cut -c1-170)"; rele=$((rele + 1)); fi
}
cere "hibrid singur (X25519MLKEM768)" 0 node "$D/tls-sonda.mjs" 127.0.0.1 8445 X25519MLKEM768
cere "clasic singur (X25519, rezerva din reteta)" 0 node "$D/tls-sonda.mjs" 127.0.0.1 8445 X25519
cere "hibrid + clasic (preferinta)" 0 node "$D/tls-sonda.mjs" 127.0.0.1 8445 X25519MLKEM768:X25519
cere "client TLS 1.2 (MinVersion 1.3: refuz)" 1 node "$D/tls-sonda.mjs" 127.0.0.1 8445 X25519 TLSv1.2
echo "-- HSTS (curl -k, antetul)"; curl -sk -m 10 -D - -o /dev/null https://127.0.0.1:8445/ | grep -iE '^(strict-transport-security|HTTP)' | tr -d '\r'
echo "-- scanerul AERE pe serverul retetei"; node "$D/scaneaza-local.mjs" 8445 | cut -c1-700
kill $PID 2>/dev/null; sleep 1; ps -p $PID > /dev/null 2>&1 && { echo "serverul nu s-a oprit; taskkill"; taskkill //F //PID $PID > /dev/null 2>&1; }
rm -f proba-go-tls.exe
echo "reteta go: $((4 - rele)) din 4 sonde cum trebuie"
[ "$rele" = 0 ] && exit 0 || exit 1
@@ -0,0 +1,44 @@
#!/bin/bash
# masoara-nginx-rpc2.sh (PE rpc2, trimis cu `ssh ... 'bash -s'`): reteta nginx a remedierii (profilul `nginx`) masurata pe un nginx REAL,
# in container (nginx:alpine, cu OpenSSL-ul lui Alpine), pe 127.0.0.1:8446, cu EXACT directivele retetei pentru hndl-exposed +
# tls12-accepted + hsts-missing: `ssl_ecdh_curve X25519MLKEM768:X25519; ssl_protocols TLSv1.3; add_header Strict-Transport-Security
# "max-age=31536000" always;`. Preconditia retetei (nginx legat de OpenSSL >= 3.5) se citeste din `nginx -V`. Sonde: node 24 de pe rpc2
# (hibrid singur, clasic singur, TLS 1.2 refuzat), HSTS prin curl. Container si imagine sterse la sfarsit. RPC-ul local cronometrat.
set -u
D=/root/nginx-reteta; rm -rf "$D"; mkdir -p "$D/certs" "$D/conf"; cd "$D" || exit 2
N=/opt/node24/bin/node
rpc() { local t0=$(date +%s%N); curl -s -m 5 -H 'content-type: application/json' -d '{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}' http://127.0.0.1:8545 | grep -o '"result":"0x[0-9a-f]*"' | head -1; echo " ($(( ($(date +%s%N) - t0) / 1000000 )) ms)"; }
echo "== RPC inainte: $(rpc)"
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes -keyout certs/privkey.pem -out certs/fullchain.pem -days 2 -subj '/CN=proba.local' > /dev/null 2>&1 && chmod 644 certs/*.pem && echo "cert ok"
cat > conf/default.conf <<'EOF'
server {
listen 127.0.0.1:8446 ssl;
server_name proba.local;
ssl_certificate /etc/nginx/certs/fullchain.pem;
ssl_certificate_key /etc/nginx/certs/privkey.pem;
# EXACT fragmentul retetei (remediere.mjs, profilul nginx):
ssl_ecdh_curve X25519MLKEM768:X25519;
ssl_protocols TLSv1.3;
add_header Strict-Transport-Security "max-age=31536000" always;
location / { return 200 "ok\n"; }
}
EOF
cp tls-sonda.mjs "$D/" 2>/dev/null || true
echo "== imaginea nginx:alpine"; docker pull -q nginx:alpine > /dev/null 2>&1; docker image inspect nginx:alpine --format 'imagine: {{.Id}} {{.Size}} octeti' | cut -c1-90
echo "-- preconditia retetei: nginx -V (OpenSSL)"; docker run --rm nginx:alpine nginx -V 2>&1 | grep -iE 'nginx version|openssl' | cut -c1-160
docker rm -f nginx-reteta > /dev/null 2>&1
docker run -d --name nginx-reteta --network host -v "$D/conf/default.conf:/etc/nginx/conf.d/default.conf:ro" -v "$D/certs:/etc/nginx/certs:ro" nginx:alpine > /dev/null; sleep 2
docker ps --filter name=nginx-reteta --format 'container: {{.Status}}'
echo "-- nginx -t in container"; docker exec nginx-reteta nginx -t 2>&1 | tail -1
rele=0
cere() { local nume="$1" ast="$2"; shift 2; out=$("$@" 2>&1); c=$?; if [ "$c" = "$ast" ]; then echo " OK $nume -> cod $c: $(printf '%s' "$out" | cut -c1-170)"; else echo " RAU $nume -> cod $c (asteptat $ast): $(printf '%s' "$out" | cut -c1-170)"; rele=$((rele + 1)); fi; }
cere "hibrid singur (X25519MLKEM768)" 0 $N /root/nginx-reteta-sonda.mjs 127.0.0.1 8446 X25519MLKEM768
cere "clasic singur (X25519, rezerva din reteta)" 0 $N /root/nginx-reteta-sonda.mjs 127.0.0.1 8446 X25519
cere "hibrid + clasic (preferinta)" 0 $N /root/nginx-reteta-sonda.mjs 127.0.0.1 8446 X25519MLKEM768:X25519
cere "client TLS 1.2 (ssl_protocols TLSv1.3: refuz)" 1 $N /root/nginx-reteta-sonda.mjs 127.0.0.1 8446 X25519 TLSv1.2
echo "-- HSTS (curl -k)"; curl -sk -m 10 -D - -o /dev/null https://127.0.0.1:8446/ | grep -iE '^(strict-transport-security|HTTP)' | tr -d '\r'
docker logs nginx-reteta 2>&1 | grep -iE 'emerg|error' | head -3
echo "== curatenie"; docker rm -f nginx-reteta > /dev/null 2>&1; docker rmi nginx:alpine > /dev/null 2>&1 && echo "imaginea stearsa"; cd /root && rm -rf "$D" /root/nginx-reteta-sonda.mjs; docker ps -a --format '{{.Names}}' | grep -c nginx-reteta | sed 's/^/containere ramase: /'
echo "== RPC dupa: $(rpc)"
echo "reteta nginx: $((4 - rele)) din 4 sonde cum trebuie"
[ "$rele" = 0 ] && exit 0 || exit 1
@@ -0,0 +1,8 @@
// scaneaza-local.mjs <port>: scanerul AERE de pregatire post-cuantica (cloud-gateway/readiness-service.mjs, functia scaneazaAdresa,
// fara garda de adrese private: tinta e 127.0.0.1, aleasa de noi) pe serverul de proba al unei retete. Tipareste verdictul, rezumatul si
// constatarile, exact ce ar vedea un client al scanerului pe serverul lui dupa aplicarea retetei.
import { pathToFileURL } from 'node:url';
const port = Number(process.argv[2] || 8445);
const { scaneazaAdresa } = await import(pathToFileURL('C:/Users/Jessica/Documents/AereNetwork/aerenew/cloud-gateway/readiness-service.mjs').href);
const r = await scaneazaAdresa('proba.local', { address: '127.0.0.1', family: 4 }, { port, jurnal: false });
console.log(JSON.stringify({ score: r.score, verdict: r.verdict, summary: r.summary, findings: (r.findings || []).map((f) => f.id + ':' + f.severity), error: r.error, detail: r.detail }, null, 1).replace(/\n\s*/g, ' '));
@@ -0,0 +1,15 @@
// tls-sonda.mjs <gazda> <port> <grupuri> [maxVersion]: o strangere de mana TLS reala cu grupurile de schimb de cheie date (de ex.
// X25519MLKEM768 singur, X25519 singur) si, optional, cu versiunea maxima (TLSv1.2 = un client care nu stie TLS 1.3). Fara verificarea
// certificatului (al probei e autosemnat). JSON pe stdout; iesire 0 = handshake reusit, 1 = refuzat.
import tls from 'node:tls';
const [gazda, port, grupuri, maxV] = process.argv.slice(2);
const t0 = Date.now();
const opt = { host: gazda, port: Number(port), servername: 'proba.local', rejectUnauthorized: false, ecdhCurve: grupuri, ALPNProtocols: ['http/1.1'] };
if (maxV) { opt.maxVersion = maxV; opt.minVersion = maxV; } else { opt.minVersion = 'TLSv1.3'; opt.maxVersion = 'TLSv1.3'; }
const s = tls.connect(opt, () => {
const ek = s.getEphemeralKeyInfo();
console.log(JSON.stringify({ ok: true, grupuriOferite: grupuri, versiuneCeruta: maxV || 'TLSv1.3', protocol: s.getProtocol(), cifru: s.getCipher().name, grupRaportat: ek && ek.name, ms: Date.now() - t0, openssl: process.versions.openssl }));
s.end(); process.exitCode = 0;
});
s.setTimeout(8000, () => { console.log(JSON.stringify({ ok: false, grupuriOferite: grupuri, versiuneCeruta: maxV || 'TLSv1.3', motiv: 'timeout' })); s.destroy(); process.exitCode = 1; });
s.on('error', (e) => { console.log(JSON.stringify({ ok: false, grupuriOferite: grupuri, versiuneCeruta: maxV || 'TLSv1.3', motiv: e.code || e.message, ms: Date.now() - t0, openssl: process.versions.openssl })); process.exitCode = 1; });
+43 -3
View File
@@ -89,6 +89,36 @@ function cnDin(subjectName) {
return m ? m[1].trim() : null;
}
// 2026-10-18 (libsignal): codul de TEST (tests/, benches/, fuzz/, examples/, *Test.java, *.test.ts, ...) nu protejeaza nicio data: cheile
// lui sunt efemere si publice prin definitie. Pe libsignal 76 din 197 de actiuni (75 HIGH) erau in asemenea fisiere si ar fi stat in
// fata locurilor de productie. Constatarea ramane in plan (completitudine), dar cu urgenta LOW, scope 'test' si numarata separat.
// Scopul se deriva din CALE, aici, intr-un singur loc; adaptorul din control-plane.mjs il pune pe fiecare constatare.
const SCOP_TEST = /(^|\/)(tests?|__tests__|specs?|benches?|benchmarks?|fuzz|examples?|testdata|test-data|test-support|testing|cross-version-testing|mocks?|fixtures?)(\/|$)|(^|\/)[^/]*(_test|\.test|\.spec|Tests?|Spec|Bench|Benchmark|Fuzz)\.(rs|go|py|java|kt|ts|tsx|js|mjs|cjs|swift)$/;
export function scopulCaii(cale) {
return SCOP_TEST.test(String(cale || '').replace(/\\/g, '/')) ? 'test' : 'production';
}
const NOTA_TEST = 'test code (keys that protect no data; the production call sites come first, this one follows them or becomes the test of the hybrid path): ';
// 2026-10-18 (libsignal): un certificat AUTOSEMNAT (emitent = subiect) gasit in arbore e, de regula, o ANCORA DE INCREDERE pe care codul o
// fixeaza (radacinile AMD, Google si AWS ale atestarii in libsignal: 25, 100 si 30 de ani; sau radacina proprie a unui PKI intern). PKI-ul
// PQ nu o poate inlocui emitand un certificat: verificatorul are incredere exact in acea radacina. Si nu e WebPKI: "Amazon" in emitent nu
// face din radacina Nitro un CA public. Inainte, trei asemenea radacini ieseau "auto prin PKI" si a patra "blocata: WebPKI public", toate
// patru fals. Ce NU e ancora: un certificat de serviciu autosemnat, de scurta durata, pentru un nume de gazda (api.internal, 800 de zile,
// `openssl req -x509`): pe acela PKI-ul il inlocuieste cu unul emis pentru acelasi nume. Semnele ancorei, scrise in blocant: durata peste
// cinci ani sau un CN care nu e nume de gazda (niciun certificat de serviciu nu se emite pe decenii; radacinile numai asa se emit).
const AN_MS = 365.25 * 24 * 3600 * 1000;
function ancoraDeIncredere(f) {
const c = f.assetType === 'certificate' && f.certificate;
if (!c || !c.issuerName || !c.subjectName || String(c.issuerName).trim() !== String(c.subjectName).trim()) return null;
const cn = cnDin(c.subjectName);
const gazda = !!cn && NUME_GAZDA.test(cn.replace(/^\*\./, ''));
const ani = c.notValidBefore && c.notValidAfter ? (new Date(c.notValidAfter) - new Date(c.notValidBefore)) / AN_MS : null;
if (ani !== null && ani > 5) return { motiv: `self-signed and valid for ${Math.round(ani)} years` };
if (!gazda) return { motiv: 'self-signed and its CN is not a host name' };
return null;
}
const BLOCANT_ANCORA = 'root pinned as a trust anchor (issuer = subject): the PQ PKI cannot replace it by issuing a certificate, the verifier trusts this exact root. It changes when its owner publishes a post-quantum root: a hardware or cloud vendor root (attestation, TPM, enclaves) follows the vendor; your own root means re-rooting the internal PKI with a hybrid root. Until then keep the pin set able to carry two roots.';
function actiuneDinInventar(f) {
if (!vulnerabil(f)) return null;
const prim = primitivaDe(f);
@@ -105,11 +135,15 @@ function actiuneDinInventar(f) {
? `X.509 certificate ${f.certificate && f.certificate.subjectName ? '(' + f.certificate.subjectName + ')' : ''}`.trim()
: `${f.name || prim}${f.assetType === 'related-crypto-material' && f.material ? ' (' + f.material.type + ')' : ''}`;
// blocant onest: certificatele WebPKI publice nu se pot emite PQ azi (niciun CA public nu emite), deci manual/blocat
const webpkiPublic = f.assetType === 'certificate' && f.certificate && /\b(let's encrypt|digicert|globalsign|sectigo|google trust|amazon)\b/i.test((f.certificate.issuerName || ''));
const ancora = ancoraDeIncredere(f);
const webpkiPublic = !ancora && f.assetType === 'certificate' && f.certificate && /\b(let's encrypt|digicert|globalsign|sectigo|google trust|amazon)\b/i.test((f.certificate.issuerName || ''));
let method = t.product ? 'auto-aere' : 'manual';
let blocker = null; let cn;
let how = t.how;
if (f.assetType === 'certificate' && !webpkiPublic) {
if (ancora) {
method = 'blocked'; blocker = `${BLOCANT_ANCORA} (${ancora.motiv})`;
how = 'replace the trust anchor, not a leaf: wait for (or ask for) the issuer\'s post-quantum root, add it next to the classical one in the pin set, then retire the classical root';
} else if (f.assetType === 'certificate' && !webpkiPublic) {
const c = cnDin(f.certificate && f.certificate.subjectName);
if (c && NUME_GAZDA.test(c)) cn = c.toLowerCase();
else if (method === 'auto-aere') {
@@ -122,6 +156,9 @@ function actiuneDinInventar(f) {
how = 'replace the private key together with the certificate or protocol that uses it (its use is not visible from the file)';
}
if (webpkiPublic) { method = 'blocked'; blocker = 'public WebPKI certificate: no public CA issues post-quantum certificates yet; it stays classical until then, or the service moves behind the PQ Gateway'; }
const scope = f.scope === 'test' ? 'test' : 'production';
let urgency = urgenta(prim, false, certLunga);
if (scope === 'test') { urgency = 'LOW'; how = NOTA_TEST + how; }
return {
ref: f.ref || `${f.assetType || 'algorithm'}:${(f.name || prim)}`,
asset: numeAsset,
@@ -131,7 +168,8 @@ function actiuneDinInventar(f) {
method, product: method === 'auto-aere' ? t.product : null, how,
...(cn ? { cn } : {}),
primitive: prim,
urgency: urgenta(prim, false, certLunga), blocker,
urgency, blocker,
scope,
location: f.location || null,
source: 'inventory',
};
@@ -220,6 +258,8 @@ export function planeaza({ inventory = [], scan = null } = {}) {
manual: dedup.filter((a) => a.method === 'manual').length,
blocked: dedup.filter((a) => a.method === 'blocked').length,
byProduct: dedup.filter((a) => a.product).reduce((m, a) => (m[a.product] = (m[a.product] || 0) + 1, m), {}),
// 2026-10-18: actiunile din cod de test, numarate separat (scanarea nu are cod, deci 'production')
byScope: dedup.reduce((m, a) => (m[a.scope || 'production'] = (m[a.scope || 'production'] || 0) + 1, m), {}),
};
return { version: VERSIUNE, summary, actions: dedup };
}
+9 -4
View File
@@ -25,6 +25,9 @@ try {
// fixtura vulnerabila
const v = path.join(T, 'vuln'); fs.mkdirSync(v);
fs.writeFileSync(path.join(v, 'a.js'), "const c=require('crypto');\nc.createECDH('prime256v1');\nc.createSign('RSA-SHA256');\n");
// 2026-10-18 (libsignal): acelasi apel intr-un fisier de TEST: in plan, dar LOW si scope 'test' (scopul se deriva din cale, prin adaptor)
fs.mkdirSync(path.join(v, 'tests'));
fs.writeFileSync(path.join(v, 'tests', 'a.test.js'), "const c=require('crypto');\nc.createECDH('prime256v1');\n");
// fixtura PQ
const pq = path.join(T, 'pq'); fs.mkdirSync(pq);
fs.writeFileSync(path.join(pq, 'b.js'), "// ML-KEM-768 si ML-DSA-65, doar nume\nconst a='ML-KEM-768', s='ML-DSA-65';\n");
@@ -34,9 +37,11 @@ try {
const pv = ruleaza(v);
const byRef = Object.fromEntries(pv.actions.map((a) => [a.ref.split(':').slice(0, 3).join(':'), a]));
cer('dosar vulnerabil: 2 folosiri vulnerabile', pv.inventory.quantumVulnerable === 2);
cer('dosar vulnerabil: 2 actiuni in plan', pv.summary.total === 2);
const ecdh = pv.actions.find((a) => /ECDH/i.test(a.name || a.asset));
cer('dosar vulnerabil: 3 folosiri vulnerabile (2 in a.js, 1 in tests/)', pv.inventory.quantumVulnerable === 3);
cer('dosar vulnerabil: 3 actiuni in plan', pv.summary.total === 3);
const inTest = pv.actions.find((a) => /tests\//.test(a.location || ''));
cer('apelul din tests/ -> scope test, urgenta LOW, numarat in byScope.test', inTest && inTest.scope === 'test' && inTest.urgency === 'LOW' && pv.summary.byScope && pv.summary.byScope.test === 1 && pv.summary.byScope.production === 2);
const ecdh = pv.actions.find((a) => /ECDH/i.test(a.name || a.asset) && a.scope !== 'test');
const rsa = pv.actions.find((a) => /RSA/i.test(a.name || a.asset));
// 2026-10-18: createECDH e schimb de cheie facut de APLICATIE (api-ul si limbajul trec prin adaptor): manual, in cod, tinta hibrida, fara gateway
cer('ECDH din cod (createECDH) -> manual, in cod, tinta X25519 + ML-KEM-768, fara gateway', ecdh && ecdh.method === 'manual' && !ecdh.product && /ML-KEM-768/.test(ecdh.target) && /createECDH/.test(ecdh.how));
@@ -56,5 +61,5 @@ try {
} finally {
fs.rmSync(T, { recursive: true, force: true });
}
console.log(`\nB1 control-plane CLI: ${9 - rele}/9 cum trebuia`);
console.log(`\nB1 control-plane CLI: ${10 - rele}/10 cum trebuia`);
process.exit(rele ? 1 : 0);
+25
View File
@@ -24,6 +24,16 @@ const inventory = [
{ ref: 'cod:ed25519:rust', assetType: 'algorithm', name: 'Ed25519', primitive: 'signature', quantumVulnerable: true, language: 'rust', api: 'SigningKey::generate', location: 'src/sign.rs:5' },
{ ref: 'cod:tls:go', assetType: 'algorithm', name: 'ECDH-secp256r1', primitive: 'key-agree', quantumVulnerable: true, language: 'go', api: 'tls.Config.CurvePreferences', protocolType: undefined, location: 'main.go:30' },
{ ref: 'cod:tls-client:rust', assetType: 'algorithm', name: 'X25519', primitive: 'key-agree', quantumVulnerable: true, language: 'rust', api: 'rustls::crypto::ring::default_provider', location: 'src/http.rs:12' },
// 2026-10-18 (libsignal): radacini AUTOSEMNATE fixate in arbore (ancore de incredere ale atestarii: AMD, AWS) si o constatare din cod de TEST
{ ref: 'cert:radacina-vendor', assetType: 'certificate', primitive: 'signature', quantumVulnerable: true,
certificate: { subjectName: 'OU=Engineering, O=Advanced Micro Devices, CN=ARK-Genoa', issuerName: 'OU=Engineering, O=Advanced Micro Devices, CN=ARK-Genoa', notValidBefore: '2020-10-22T00:00:00Z', notValidAfter: '2045-10-22T00:00:00Z' } },
// CN in forma de nume de gazda, dar 30 de ani: tot radacina (asa e cea reala a AWS Nitro)
{ ref: 'cert:radacina-amazon', assetType: 'certificate', primitive: 'signature', quantumVulnerable: true,
certificate: { subjectName: 'C=US, O=Amazon, OU=AWS, CN=aws.nitro-enclaves', issuerName: 'C=US, O=Amazon, OU=AWS, CN=aws.nitro-enclaves', notValidBefore: '2019-10-28T00:00:00Z', notValidAfter: '2049-10-28T00:00:00Z' } },
// CONTROL: un certificat de serviciu autosemnat, scurt, pentru un nume de gazda, NU e ancora: PKI-ul il inlocuieste pentru acelasi CN
{ ref: 'cert:autosemnat-serviciu', assetType: 'certificate', primitive: 'signature', quantumVulnerable: true,
certificate: { subjectName: 'CN=api.autosemnat.internal', issuerName: 'CN=api.autosemnat.internal', notValidBefore: '2026-01-01T00:00:00Z', notValidAfter: '2027-01-01T00:00:00Z' } },
{ ref: 'cod:x25519:test', assetType: 'algorithm', name: 'X25519', primitive: 'key-agree', quantumVulnerable: true, language: 'rust', api: 'KeyPair::generate', scope: 'test', location: 'tests/ratchet.rs:19' },
];
// 2026-09-27: constatarile de scanare se DERIVA din sursa scanerului (readiness-service.mjs, apelurile lui add(id, severitate,
// titlu)), nu se scriu de mana. Fixtura veche folosea id-uri inventate ('tls-kex-classical', 'tls12-enabled'), deci proba era verde
@@ -63,6 +73,21 @@ cer('HNDL ramane si in cod: X25519 HIGH, Ed25519 MEDIUM', xc && ec && xc.urgency
const cl = byRef['cod:tls-client:rust'];
cer('TLS de client din cod (rustls ring provider) -> manual, furnizorul hibrid in client, fara gateway', cl && cl.method === 'manual' && !cl.product && /X25519MLKEM768/.test(cl.target) && /aws-lc-rs/.test(cl.how) && /does not change what this client offers/.test(cl.how));
// 2026-10-18 (libsignal): o radacina autosemnata e o ancora de incredere, nu un certificat pe care PKI-ul il poate emite; si nu e WebPKI
const rv = byRef['cert:radacina-vendor'], ra = byRef['cert:radacina-amazon'];
cer('radacina autosemnata a unui vendor -> BLOCATA ca ancora de incredere, fara produs, fara cn', rv && rv.method === 'blocked' && !rv.product && !rv.cn && /trust anchor/.test(rv.blocker) && /trust anchor/.test(rv.how));
cer('radacina autosemnata cu "Amazon" in emitent -> tot ancora de incredere, NU "WebPKI public"', ra && ra.method === 'blocked' && /trust anchor/.test(ra.blocker) && !/WebPKI/.test(ra.blocker));
cer('CONTROL: certificatul intern emis de alt CA (emitent != subiect) ramane auto prin PKI', byRef['cert:interna'] && byRef['cert:interna'].method === 'auto-aere');
const sa = byRef['cert:autosemnat-serviciu'];
cer('CONTROL: certificatul de serviciu autosemnat, scurt, cu nume de gazda, ramane auto prin PKI pentru acelasi CN (nu e ancora)', sa && sa.method === 'auto-aere' && sa.product === 'pki' && sa.cn === 'api.autosemnat.internal');
cer('blocantul ancorei numeste semnul (durata sau CN): vendor = durata, Amazon = durata', /valid for 25 years/.test(rv.blocker) && /valid for 30 years/.test(ra.blocker));
// 2026-10-18 (libsignal): codul de test ramane in plan, dar LOW, cu scope 'test' si numarat separat
const xt = byRef['cod:x25519:test'];
cer('X25519 din cod de test -> in plan, urgenta LOW, scope test, how spune ca e cod de test', xt && xt.urgency === 'LOW' && xt.scope === 'test' && /^test code/.test(xt.how) && /gateway in front cannot/.test(xt.how));
cer('acelasi X25519 din productie ramane HIGH si scope production', xc && xc.urgency === 'HIGH' && xc.scope === 'production');
cer('rezumatul numara scopul: byScope.test = 1', plan.summary.byScope && plan.summary.byScope.test === 1 && plan.summary.byScope.production === plan.summary.total - 1);
cer('actiunile de test stau la coada planului (sortare pe urgenta)', plan.actions[plan.actions.length - 1].scope === 'test');
// controale negative: ce NU trebuie sa fie in plan
cer('CONTROL: ML-KEM (deja PQ) NU e in plan', !byRef['algorithm:mlkem']);
cer('CONTROL: ML-DSA (deja PQ) NU e in plan', !byRef['algorithm:mldsa']);
@@ -32,6 +32,9 @@ try {
'-days', '800', '-subj', '/CN=api.intern'], { stdio: 'ignore' });
} catch (e) { nemasurat('openssl nu a putut face certificatul de proba: ' + e.message); }
fs.writeFileSync(path.join(T, 'serviciu.js'), "const crypto = require('crypto');\nconst e = crypto.createECDH('prime256v1');\nconst s = crypto.sign('RSA-SHA256', Buffer.from('x'), cheie);\n");
// 2026-10-18 (libsignal): acelasi schimb de cheie intr-un fisier de TEST nu e "expus azi" (cheia nu protejeaza nimic) si se numara separat
fs.mkdirSync(path.join(T, 'tests'));
fs.writeFileSync(path.join(T, 'tests', 'serviciu.test.js'), "const crypto = require('crypto');\nconst e = crypto.createECDH('prime256v1');\n");
const { caleaScanerului } = await import('./control-plane.mjs');
const scanerSrc = fs.readFileSync(caleaScanerului(), 'utf8');
const re = /add\('([a-z0-9-]+)',\s*'([a-z]+)',\s*[`']([^`']+)[`']/g; const reale = []; let m;
@@ -50,6 +53,12 @@ try {
// ---- raportul
const { report: raport, envelope: plic, evidenceHash } = raportConformitate({ plan, organization: 'Exemplu SRL', date: '2026-09-28' });
const dupa = (f) => raport.findings.find(f);
// 2026-10-18 (libsignal): schimbul de cheie din tests/ e in raport, dar NU expus azi, cu scope test; cel din productie ramane expus
const kexTest = dupa((c) => /tests\//.test(c.ref) && c.nature === 'key-exchange');
const kexProd = dupa((c) => /serviciu\.js/.test(c.ref) && c.nature === 'key-exchange');
cer('schimbul de cheie din cod de test: in raport, scope test, NU expus azi (false, nu null)', kexTest && kexTest.scope === 'test' && kexTest.exposedToday === false);
cer('schimbul de cheie din productie ramane expus azi, scope production', kexProd && kexProd.scope === 'production' && kexProd.exposedToday === true);
cer('rezumatul: inTestCode = 1, iar expusele de azi nu il numara; verdictul spune cate sunt in cod de test', raport.summary.inTestCode === 1 && raport.summary.exposedToday === raport.findings.filter((c) => c.exposedToday === true).length && !raport.findings.some((c) => c.exposedToday === true && c.scope === 'test') && /1 in test code/.test(raport.summary.verdict));
const kex = dupa((c) => c.ref.startsWith('tls-kex:'));
cer('schimbul de cheie clasic (scanare) e schimb-de-cheie, expus AZI, cu termenele NIST 2030 si UE 2030 (risc nedeclarat = inalt)',
kex && kex.nature === 'key-exchange' && kex.exposedToday && kex.regimes.some((x) => x.regime === 'nist-ir-8547' && x.deadline === '2030-12-31')
+6 -2
View File
@@ -116,7 +116,10 @@ export function raportConformitate({ plan, organization, risk, date, cnsa = fals
target: a.target, blocker: a.blocker || null, regimes: reg, nearestDeadline: termene[0] || null,
// HNDL: schimbul de cheie e expus AZI (datele se recolteaza acum); semnatura nu (falsificarea vine odata cu calculatorul cuantic)
// null = nu se stie: o cheie folosita la cifrare/transport e expusa azi, una folosita la semnatura nu
exposedToday: nat === 'key-exchange' ? true : nat === 'key-use-unknown' ? null : false,
// 2026-10-18 (libsignal): un schimb de cheie din COD DE TEST nu protejeaza nicio data, deci nu e expus azi; se numara separat
// (pe libsignal 150 din 194 de "expuse azi" erau chei de test, si verdictul le punea in fata clientului ca recoltabile)
exposedToday: nat === 'key-exchange' ? a.scope !== 'test' : nat === 'key-use-unknown' ? null : false,
scope: a.scope === 'test' ? 'test' : 'production',
});
}
const cuTermen = constatari.filter((c) => c.nearestDeadline);
@@ -128,6 +131,7 @@ export function raportConformitate({ plan, organization, risk, date, cnsa = fals
configuration: constatari.filter((c) => c.nature === 'configuration').length,
unclassified: constatari.filter((c) => c.nature === 'unclassified').length,
exposedToday: constatari.filter((c) => c.exposedToday === true).length,
inTestCode: constatari.filter((c) => c.scope === 'test').length,
blockedByEcosystem: constatari.filter((c) => c.method === 'blocked').length,
nearestDeadline: cuTermen.map((c) => c.nearestDeadline).sort()[0] || null,
euInventory2026: date <= U.deadlines.inventory ? 'this report is a dated inventory (the EU requirement for 31.12.2026)' : 'the EU inventory deadline (31.12.2026) has passed',
@@ -138,7 +142,7 @@ export function raportConformitate({ plan, organization, risk, date, cnsa = fals
? `no action classified as vulnerable, but ${rezumat.unclassified} UNCLASSIFIED actions (not judged); the report cannot say that there is no vulnerable algorithm`
: vulnerabile === 0
? 'no quantum-vulnerable public-key algorithm in what was measured'
: `${vulnerabile} quantum-vulnerable assets; nearest deadline ${rezumat.nearestDeadline}${rezumat.exposedToday ? `; ${rezumat.exposedToday} exposed TODAY (harvest now, decrypt later)` : ''}${rezumat.unknownUse ? `; ${rezumat.unknownUse} of unknown use (exposure today not known)` : ''}`;
: `${vulnerabile} quantum-vulnerable assets; nearest deadline ${rezumat.nearestDeadline}${rezumat.exposedToday ? `; ${rezumat.exposedToday} exposed TODAY (harvest now, decrypt later)` : ''}${rezumat.unknownUse ? `; ${rezumat.unknownUse} of unknown use (exposure today not known)` : ''}${rezumat.inTestCode ? `; ${rezumat.inTestCode} in test code (not exposed today)` : ''}`;
const raport = {
v: 2, version: VERSIUNE, organization, date, risk: risk || null, cnsa: !!cnsa,
regimes: Object.fromEntries(Object.entries(REGIMURI).filter(([k]) => cnsa || k !== 'cnsa-2.0')),
+2 -2
View File
@@ -28,10 +28,10 @@ const HSTS = 'max-age=31536000';
// ce masuratoare sustine fiecare profil (un mesaj nu afirma mai mult decat masuratoarea)
export const RETETE_MASURATE = {
node: 'measured end to end on 2026-09-28: a Node 24.14.1 / OpenSSL 3.5.5 server with the options of this recipe, scanned by the AERE scanner (proba-remediere.mjs)',
nginx: 'the group names accepted by OpenSSL 3.5.5 (measured); the server directive from the nginx documentation, not measured by us on a real nginx',
nginx: 'measured end to end on 2026-10-18: nginx 1.31.7 (nginx:alpine, OpenSSL 3.5.8/3.5.9) with exactly these directives, in a container on 127.0.0.1: a client offering only X25519MLKEM768 completes TLS 1.3, X25519 alone still works as the fallback, a TLS 1.2 client is refused, HSTS is sent (dovezi/retete-2026-10-18/)',
apache: 'the group names accepted by OpenSSL 3.5.5 (measured); the server directive from the mod_ssl documentation, not measured by us on a real Apache',
haproxy: 'the group names accepted by OpenSSL 3.5.5 (measured); the server directive from the HAProxy documentation, not measured by us on a real HAProxy',
go: 'from the Go 1.24 release notes (X25519MLKEM768 is the default when CurvePreferences is nil); not measured by us (the Go on the test machine is 1.22)',
go: 'measured end to end on 2026-10-18: a Go 1.26.5 (windows/amd64) net/http server with exactly this tls.Config and header, on 127.0.0.1: X25519MLKEM768 alone completes TLS 1.3, X25519 alone works as the fallback, a TLS 1.2 client is refused, HSTS is sent, and the AERE scanner reports pqKeyExchange X25519MLKEM768 / tls12Accepted false / hsts true (dovezi/retete-2026-10-18/); Linux not measured (the WSL Go is 1.22)',
};
// --- forma structurata: ce cere fiecare defect al scanerului --------------------------------------------------------------------