Skip to content

fix: accept repeated spaces in signed metadata - #267

Merged
ovaistariq merged 1 commit into
mainfrom
perfloop-pr-open-r1jjqea2ce
Oct 21, 2026
Merged

ovaistariq merged 1 commit into
mainfrom
perfloop-pr-open-r1jjqea2ce

Conversation

@perfloop

@perfloop perfloop Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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.go sends 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_ReinvalidatesAfterForward check 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 were make test-integration TEST=^TestAuth_, make test-integration TEST=^TestSDK_PutObject_ChunkedEncoding, and make test-integration TEST=^TestTransparentAuth_. The full make test, make test-integration, make test-race, and make test-coverage suites 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).

canonicalHeaderValue and writeCanonicalHeaderValues in auth replace in-place TrimSpace in both the signer and validator so client and upstream signatures align with SDK behavior. README and docs/s3-compatibility.md document 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.

@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no actionable issues were found.

Summary

This PR shares header normalization between signing and validation. It collapses repeated ASCII spaces for signature calculation without rewriting forwarded metadata.

  • Signing mode accepts repeated spaces in signed metadata.

Reviews (1) · Last reviewed commit: "fix: accept repeated spaces in signed me..." · Reviewed by Greptile

@ovaistariq
ovaistariq merged commit 50146c6 into main Oct 21, 2026
10 checks passed
@ovaistariq
ovaistariq deleted the perfloop-pr-open-r1jjqea2ce branch October 21, 2026 05:47
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 21, 2026
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.22.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants