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

+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 };
}