Skip to content

Sign an encoded slash in an S3 path as a separator - #1669

Open
jlouvel wants to merge 1 commit into
3.0from
fix/aws-sigv4-s3-encoded-slash
Open

jlouvel wants to merge 1 commit into
3.0from
fix/aws-sigv4-s3-encoded-slash

Conversation

@jlouvel

@jlouvel jlouvel commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

S3 decodes the whole request path before splitting it into segments, so an encoded slash (%2F) in an object key acts as a path separator. The S3 branch of HttpAwsSigV4Helper.getCanonicalUri split the raw path first and then decoded each segment, so /bucket/a%2Fb was signed as /bucket/a%252Fb instead of /bucket/a/b. S3 and MinIO then rejected the request with SignatureDoesNotMatch.

The S3 branch now decodes the whole path, splits it, and URI-encodes each segment once. The other services (double encoding) are unchanged.

Found while porting the helper to Ikanos (naftiko/ikanos#957).

./mvnw -B verify -P default,test -pl org.restlet.ext.crypto -am passes.

🤖 Generated with Claude Code

S3 and MinIO decode the path they receive, then sign it with each segment
URI-encoded once, slashes kept. HttpAwsSigV4Helper split the path before
decoding each segment, so an encoded slash stayed inside its segment:
`/bucket/a%2Fb` was signed as `/bucket/a%2Fb` while S3 signs `/bucket/a/b`,
and the signature didn't match. For S3 the whole path is now decoded
before it is split. The other services still sign the path normalized and
encoded once more, as sent.

Found while reviewing the copy of this helper in Ikanos (naftiko/ikanos#957).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The S3 canonical-path signing change has no active review issues.

No open issues 🎉

What changed in this PR

Fixes S3 canonical path signing in the crypto extension’s AWS Signature Version 4 helper so encoded slashes are treated as separators, avoiding signature mismatches with S3 and MinIO.

Changes:

  • Decodes the full S3 path before splitting and encoding segments, leaving non-S3 behavior unchanged.
  • Updates Javadoc and adds regression coverage for uppercase %2F, lowercase %2f, and non-S3 signing.
File Description
org.restlet.ext.crypto/​src/​test/​java/​org/​restlet/​ext/​crypto/​internal/​HttpAwsSigV4HelperTestCase.java Adds encoded-slash regression tests.
org.restlet.ext.crypto/​src/​main/​java/​org/​restlet/​ext/​crypto/​internal/​HttpAwsSigV4Helper.java Corrects S3 path canonicalization and documents the behavior.

Review effort: Balanced

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants