Skip to content

Commit 7236d94

Browse files
committed
fix(push-gateway): report empty App Attest proofs as malformed
An empty proof decodes to zero bytes and was logged as a resource-limit rejection. Report it as an invalid CBOR structure instead, and cover it in the rejection-log test. Signed-off-by: Tom Brow <[email protected]>
1 parent bf00fca commit 7236d94

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎crates/buzz-push-gateway/src/app_attest.rs‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@ impl AppAttestVerifier {
9393
let cbor = STANDARD
9494
.decode(attestation_b64)
9595
.map_err(|_| verification_error("attestation", error::AppAttestError::InvalidBase64))?;
96-
if cbor.is_empty() || cbor.len() > crate::model::MAX_APP_ATTESTATION_BYTES {
96+
if cbor.is_empty() {
97+
return Err(verification_error(
98+
"attestation",
99+
error::AppAttestError::InvalidCbor,
100+
));
101+
}
102+
if cbor.len() > crate::model::MAX_APP_ATTESTATION_BYTES {
97103
return Err(verification_error(
98104
"attestation",
99105
error::AppAttestError::ResourceLimit,
@@ -132,7 +138,13 @@ impl AppAttestVerifier {
132138
let cbor = STANDARD
133139
.decode(assertion_b64)
134140
.map_err(|_| verification_error("assertion", error::AppAttestError::InvalidBase64))?;
135-
if cbor.is_empty() || cbor.len() > MAX_ASSERTION_BYTES {
141+
if cbor.is_empty() {
142+
return Err(verification_error(
143+
"assertion",
144+
error::AppAttestError::InvalidCbor,
145+
));
146+
}
147+
if cbor.len() > MAX_ASSERTION_BYTES {
136148
return Err(verification_error(
137149
"assertion",
138150
error::AppAttestError::ResourceLimit,

‎crates/buzz-push-gateway/tests/app_attest_rejection_logs.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ fn attestation_rejections_log_operation_reason_and_failed_check() {
2828
let key_id = STANDARD.encode([7; 32]);
2929
let cases = [
3030
("not base64!", "encoding", "invalid base64 encoding"),
31+
("", "structure", "invalid CBOR structure"),
3132
(
3233
&*STANDARD.encode(b"not cbor"),
3334
"structure",

0 commit comments

Comments
 (0)