MINOR: Use constant-time comparison for signed footer GCM tag #3655
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 361 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.352
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3655"
general
weight: 0.35
ggershinsky
Rationale for this change
When an encrypted file is written with a plaintext (signed) footer, the footer
carries an AES-GCM authentication tag. On read,
ParquetMetadataConverter.verifyFooterIntegrityrecomputes the tag and comparesit against the stored one to detect tampering.
That comparison used
java.util.Arrays.equals, which returns as soon as it hitsa mismatching byte, so its running time depends on how many leading bytes match.
Comparing a secret authentication tag this way is a timing side channel
(CWE-208): an attacker who can measure verification time over many crafted files
could, in principle, recover the correct tag byte by byte. Constant-time
comparison is the standard practice for MAC/authentication-tag checks.
What changes are included in this PR?
ParquetMetadataConverter.verifyFooterIntegrity, replaceArrays.equals(gcmTag, calculatedTag)withMessageDigest.isEqual(gcmTag, calculatedTag)and addimport java.security.MessageDigest;. A short comment notes the CWE-208rationale.
MessageDigest.isEqualhas the same boolean contract (true iff botharrays are non-null, of equal length, and byte-for-byte equal) but is
implemented to run in time independent of the number of matching bytes, so the
change is behavior-preserving: tampered footers are still rejected with a
TagVerificationException. (TheArraysimport stays; it is used elsewhere inthe file.)
TestFooterIntegrityinparquet-hadoopcovering the signedplaintext-footer path end to end: a valid signature is accepted, and a footer
whose GCM tag has one byte flipped is rejected with
TagVerificationException.The other
Arrays.equalscalls in the crypto module compare non-secretidentifiers (AAD prefix, key-metadata reuse checks), not a secret MAC, so they
are intentionally left unchanged.
Are these changes tested?
Yes.
mvn -pl parquet-hadoop -Dtest=TestFooterIntegrity test-> both cases pass.mvn -pl parquet-hadoop -Dtest='ColumnEncryptorTest,TestPropertiesDrivenEncryption,TestFooterIntegrity' test-> 43 tests, 0 failures, 0 errors.
tag check makes
tamperedFooterSignatureIsRejectedfail (nothing thrown),which shows the tampered bytes actually reach the reader and the tag check is
what rejects them.
A true timing measurement is impractical to assert deterministically in a unit
test, so this PR verifies functional equivalence (accept valid, reject tampered)
rather than the timing property itself.
Are there any user-facing changes?
No. This is an internal hardening of the footer-signature check with identical
observable behavior (same acceptance and rejection outcomes, same exception on
mismatch). No API, format, or configuration changes.