You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
crypto: VerifyDocument's error and legacy-unsigned handling both let forged policy.json through #113
Two related trust gaps in packages/crypto/sign.go:
:67 — when signature verification encounters a malformed signature (e.g. invalid encoding or wrong length), VerifyDocument returns a hard error rather than a result indicating signed=true, valid=false; callers that only branch on the error (rather than distinguishing "malformed" from "valid") can end up treating the error path inconsistently from a clean invalid-signature result, creating divergent handling between callers.
:63 — a document with no _sig field at all is treated as a benign "legacy unsigned document" and accepted, rather than being treated as untrusted when the system otherwise expects signed documents.
Impact
An attacker can either strip the signature field entirely (accepted as "legacy") or supply a malformed signature (handled inconsistently depending on the caller) to get a forged policy.json or other signed document accepted where a properly verified result would have been expected.
Repro
Take a signed document and remove its _sig field entirely; pass it to VerifyDocument and observe it is treated as a legacy unsigned document rather than rejected.
Take a signed document and corrupt the _sig value into an invalid encoding; pass it to VerifyDocument and observe the function returns a hard error rather than a structured signed=true, valid=false result that callers can check uniformly.
Suggested fix
Make VerifyDocument always return a structured result (signed bool, valid bool, err error) rather than conflating malformed-signature with a bare error; a malformed signature should resolve to signed=true, valid=false, not a short-circuiting error. Change the missing-_sig case to also resolve to signed=false, valid=false and require every caller that currently special-cases "legacy unsigned" to make that an explicit, audited opt-in rather than the default outcome.
If VerifyDocument's error path and legacy-unsigned fallback both pass through, any policy.json is accepted regardless of signature. I'll make both paths reject the document and log the specific failure reason. The legacy-unsigned migration window should have a hard cutoff date.
Activity
sharmis-tp commentedon Nov 18, 2026
If VerifyDocument's error path and legacy-unsigned fallback both pass through, any policy.json is accepted regardless of signature. I'll make both paths reject the document and log the specific failure reason. The legacy-unsigned migration window should have a hard cutoff date.