Repository navigation
fix: accept repeated spaces in signed metadata - #267
Merged
Merged
Conversation
Signed-off-by: Perfloop Agent <[email protected]>
[Medium impact] This PR appears safe to merge; no actionable issues were found. SummaryThis PR shares header normalization between signing and validation. It collapses repeated ASCII spaces for signature calculation without rewriting forwarded metadata.
Reviews (1) · Last reviewed commit: "fix: accept repeated spaces in signed me..." · Reviewed by Greptile |
ovaistariq
approved these changes
Oct 21, 2026
|
🎉 This PR is included in version 1.22.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signing mode validates client AWS Signature Version 4 requests and re-signs them for the configured upstream. The shared canonicalization now trims surrounding whitespace and collapses runs of ASCII spaces in signed header values without rewriting the values sent upstream. This lets SDK-signed PutObject metadata pass both checks while preserving interior spacing and tabs.
The handler regression test at
handlers/signing_metadata_test.gosends SDK-signed PUTs through the HTTP router, checks the forwarded signature with an independent AWS SDK signer, and reads metadata back with a signed HEAD. It covers ordinary values, repeated spaces in one and multiple values, tabs, payload hashes, and tampered metadata and signatures. On the previous revision, the repeated-space cases fail before forwarding while the controls pass. On this change, the positive cases pass with exact metadata readback.This condition holds with this change and does not hold at
628616fd9e19fac473837eb45eb46115e3d33313:TAG in signing mode accepts a non-copy PUT with a valid SDK SigV4 signature, known credentials, a valid payload hash, and repeated ASCII spaces in one or multiple metadata values, re-signs it for an independently checked upstream, and returns the original metadata values unchanged on a signed HEAD..The separate runner used to compare source revisions is not included in this pull request; the native handler test is. The existing
TestHandlePutObject_ReinvalidatesAfterForwardcheck passes on both revisions; it injects a stale refill during forwarding and verifies post-success cleanup. The auth, handler, and proxy package tests, SDK chunked PUT tests, transparent-auth controls, build, and lint passed. The selected gateway-auth, chunked-upload, and transparent-auth integration tests weremake test-integration TEST=^TestAuth_,make test-integration TEST=^TestSDK_PutObject_ChunkedEncoding, andmake test-integration TEST=^TestTransparentAuth_. The fullmake test,make test-integration,make test-race, andmake test-coveragesuites remain target-CI work.Generated by Perfloop.
Note
Medium Risk
Changes SigV4 canonical header handling in signing mode, but behavior is narrowly scoped to AWS-spec normalization with new end-to-end tests; tampering cases still reject.
Overview
Fixes signing mode rejecting valid AWS SDK SigV4 PUTs when object metadata (
x-amz-meta-*) contains repeated ASCII spaces. Shared canonicalization now trims surrounding whitespace and collapses runs of spaces only when building the canonical request for validate/re-sign; forwarded headers are unchanged (tabs and interior spacing preserved).canonicalHeaderValueandwriteCanonicalHeaderValuesinauthreplace in-placeTrimSpacein both the signer and validator so client and upstream signatures align with SDK behavior. README anddocs/s3-compatibility.mddocument this distinction.Adds
handlers/signing_metadata_test.go: SDK-signed PUT through the gateway, independent upstream signature check, HEAD readback for metadata spacing cases, plus tampered metadata/signature rejection.Reviewed by Cursor Bugbot for commit 53b1314. Bugbot is set up for automated code reviews on this repo. Configure here.