fix(orchestrator): refuse RS256 passkeys under 2048 bits

passkey.py accepted an RS256 public key of any modulus size. It now refuses a modulus under 2048 bits at registration and at every verification, before either signature backend, with a fixed error asking for a new passkey; the library backend checks key_size again and the openssl backend's key_type requires the same size. The SubjectPublicKeyInfo is read as strict DER (no negative or padded INTEGERs, minimal lengths, no unused bits, no trailing data) and the rsaEncryption identifier must match exactly. ES256 and EdDSA are unchanged. An already pinned weak key is refused on every use until a new passkey is pinned. Accepted MEDUSA findings: AIC-EXFIL-005 and PRIV-SCAN-762 at tests/hub_support.py:151 (public half of a throwaway test key) and PQC001 at passkey.py:236 (WebAuthn offers no post-quantum algorithm yet).

🎯 Fix: 95 %
💥 Break: 3 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: 100 %
🏆 Score: 92
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-13 18:48:04 +00:00
1 parent 5b65fb5284
commit 0e569323fb
3 files changed
+140 -10

No files matched your search

+16 -5
View File
@@ -103,10 +103,16 @@ ORIGIN = "http://localhost:8737"
PRESENT = 0x05
REGISTERED = 0x45
ZERO_LED_TRIES = 4096
def rsa_spec(bits: int) -> list[str]:
return ["-algorithm", "RSA", "-pkeyopt", f"rsa_keygen_bits:{bits}"]
KEY_SPECS = {
-7: ["-algorithm", "EC", "-pkeyopt", "ec_paramgen_curve:P-256"],
-8: ["-algorithm", "ED25519"],
-257: ["-algorithm", "RSA", "-pkeyopt", "rsa_keygen_bits:2048"],
-257: rsa_spec(2048),
}
@@ -139,10 +145,10 @@ def cbor_encode(value: object) -> bytes:
class Key:
def __init__(self, alg: int, name: str) -> None:
def __init__(self, alg: int, name: str, spec: list[str]) -> None:
self.alg = alg
self.pem = Path(KEYS.name) / f"{name}{alg}.pem"
openssl(["genpkey", *KEY_SPECS[alg], "-out", str(self.pem)], b"")
openssl(["genpkey", *spec, "-out", str(self.pem)], b"")
self.spki = openssl(["pkey", "-in", str(self.pem), "-pubout", "-outform", "DER"], b"")
self.raw_id = os.urandom(16)
self.id = b64(self.raw_id)
@@ -188,7 +194,12 @@ class Key:
@functools.cache
def key(alg: int, name: str) -> Key:
return Key(alg, name)
return Key(alg, name, KEY_SPECS[alg])
@functools.cache
def rsa_key(bits: int) -> Key:
return Key(-257, f"rsa{bits}", rsa_spec(bits))
@functools.cache
@@ -202,7 +213,7 @@ def zero_led(label: int) -> Key:
"""
with concurrent.futures.ThreadPoolExecutor() as pool:
for start in range(0, ZERO_LED_TRIES, 64):
for signer in pool.map(lambda attempt: Key(-7, f"zero{label}-{attempt}"), range(start, start + 64)):
for signer in pool.map(lambda attempt: Key(-7, f"zero{label}-{attempt}", KEY_SPECS[-7]), range(start, start + 64)):
if signer.cose()[label][0] == 0:
return signer
raise AssertionError(f"no P-256 key with a zero-led coordinate {label} in {ZERO_LED_TRIES} tries")