Skip to content

Send paths on the wire in the form they were signed - #47

Open
toots wants to merge 2 commits into
andersfugmann:mainfrom
toots:fix-path-encoding
Open

Send paths on the wire in the form they were signed#47
toots wants to merge 2 commits into
andersfugmann:mainfrom
toots:fix-path-encoding

Conversation

@toots

@toots toots commented Aug 10, 2026

Copy link
Copy Markdown

The request target was rebuilt with Uri.make, which decodes reserved characters, so a key containing + was signed as %2B but sent as a literal + and S3 answered 403; the path and query are now encoded in Http the same way the signer canonises them.

Util.encode_string had the mirror-image bug: it let a % through whenever two hex digits followed, on the assumption that the caller had already escaped the string, but every caller builds its path as /bucket/key from a raw key, so %2F went on the wire where the signature covered a literal % -- and since that branch had no else, a % among the last two characters was dropped from the path outright.

Inline tests cover both, including the %X format that rendered a byte below 0x10 as a single hex digit.

toots added 2 commits August 10, 2026 07:43
The path and query were rebuilt through Uri, which decodes reserved characters and so put a literal '+' on the wire where the signature covered "%2B", making S3 answer 403 for every key containing one.

Encode both in http instead, the same way the signer canonises them.
encode_string let a '%' through whenever two hex digits followed, assuming an escape somebody had already applied, but callers build their path from a raw key, so a key holding one was signed as a literal and sent as an escape; the branch had no else either, so a '%' among the last two characters was dropped outright.

Pad every escape to two digits while here, since "%X" renders a byte below 0x10 as a single digit.
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.

1 participant