Repository navigation
Conversation
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]>
|
Contributor
There was a problem hiding this comment.
🟢 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
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



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 ofHttpAwsSigV4Helper.getCanonicalUrisplit the raw path first and then decoded each segment, so/bucket/a%2Fbwas signed as/bucket/a%252Fbinstead of/bucket/a/b. S3 and MinIO then rejected the request withSignatureDoesNotMatch.The S3 branch now decodes the whole path, splits it, and URI-encodes each segment once. The other services (double encoding) are unchanged.
getCanonicalUriJavadoc.%2F, lowercase%2f, and the unchanged non-S3 case.changes.mdentry: SigV4 support (Add AWS Signature Version 4 client authentication #1663) is unreleased and its 3.0 Milestone 2 entry covers this.Found while porting the helper to Ikanos (naftiko/ikanos#957).
./mvnw -B verify -P default,test -pl org.restlet.ext.crypto -ampasses.🤖 Generated with Claude Code