fix: encode + as %2B (not %20) in S3 canonical path#114
Open
Ortes wants to merge 1 commit into
Open
Conversation
encodePath treated '+' the same as space, writing '%20' for both. AWS SigV4 requires '+' in a URI path to be percent-encoded as '%2B'; '%20' is correct only for space. This mismatch caused signature verification failures (403) for any S3 object key containing a literal '+' (e.g. 'HDR10+ BluRay'), since the canonical request path used for signing diverged from what S3 computed on its side. Fix: remove '+' from the space special-case so it falls through to the generic percent-encoding block, which correctly emits '%2B'.
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.
Problem
encodePathtreats+the same as space, writing%20for both:AWS SigV4 requires
+in a URI path to be percent-encoded as%2B;%20is correct only for space. This mismatch causes a signature verification failure (HTTP 403) for any S3 object whose key contains a literal+— for exampleMovie Title HDR10+ BluRay.mkv. The canonical request path used for signing diverges from what S3 computes on its side, so the signatures never match.Both
statObject(existence checks) and presigned GET URLs are affected because both go throughgetCanonicalRequest→encodePath.Fix
Remove
+from the space special-case so it falls through to the generic percent-encoding block, which correctly emits%2B:References
%20(and not as+)"+is a sub-delimiter and must be percent-encoded when it appears literally in a path component.