Compare commits

...
Author SHA1 Message Date
beardthelion d7a70d757e Merge remote-tracking branch 'origin/main' into fix/360-attest-didkey-bound 2026-11-06 11:22:38 -06:00
beardthelion 68edeb40ed Merge remote-tracking branch 'origin/main' into tmp-456-merge
# Conflicts:
#	crates/gitlawb-attest/src/attestation.rs
2026-11-04 23:26:28 -06:00
beardthelion 0e0495606f fix(attest): bound did:key method-id length before base58 decode (#360)
gitlawb-core added the same guard in 73bf132c; the second copy of the
parser in gitlawb-attest never got it, so an untrusted signer string of
arbitrary length reaches a decoder whose cost is quadratic in input.
2026-09-15 10:03:54 -05:00
+17
View File
@@ -504,6 +504,23 @@ mod tests {
assert!(matches!(err, Error::Did(_)));
}
#[test]
fn verify_rejects_oversized_method_id_before_decoding() {
let sk = fresh();
let mut att = dummy_attestation(&sk, sample_cert_hash());
// A well-formed prefix on an absurdly long id must fail the length
// bound, not the decoder: base58 decode cost is quadratic in input
// length, so reaching it at all is the defect.
att.signer = format!("did:key:z{}", "1".repeat(256));
let err = att.verify_signature(sample_cert_hash()).unwrap_err();
// Match the bound's own message: any other Did error (a decode or
// length mismatch downstream) means the oversized input was decoded.
match err {
Error::Did(m) => assert!(m.contains("too long"), "unexpected: {m}"),
e => panic!("expected Error::Did, got {e:?}"),
}
}
#[test]
fn verify_rejects_bad_signature_base64() {
let sk = fresh();