pplu / aws-sdk-perl

A community AWS SDK for Perl Programmers
Other
171 stars 94 forks source link

"Forbidden" when accessing S3 keys with encoded characters. #323

Open galenhuntington opened 5 years ago

galenhuntington commented 5 years ago

I see a few past/pending issues about encoding problems (#111, #221), but none seem to be hitting the problem I am, which is that these operations are being rejected by AWS entirely, not even encoded or double-encoded.

E.g., Paws->service('S3', region => 'us-east-1')->PutObject(Key => 'test@test', Bucket => 'TestBucket', Body => 'test')) fails with Forbidden.

The problem appears to be that the V4 signature does not match the headers, because they are signed with the uri field URI-encoded. As evidence, when just before signing the request here https://github.com/pplu/aws-sdk-perl/blob/4c81b41298dbd5fd94c14fc9a1a4f3d7271003a0/lib/Paws/Net/S3Signature.pm#L44 I alter the request object by decoding its uri field in-place, then the operations succeed.

I haven't dug much deeper, but perhaps that field should never have been encoded in the first place. I tried a change similar to that in #220 (closed for some reason), and that seems to consistently succeed for my use cases, although maybe for more exotic characters there would be problems.

castaway commented 4 years ago

Hi, have you checked your Net::Amazon::Signature::V4 version? see #359, it seems something changed (havent looked at what, yet)

galenhuntington commented 4 years ago

My V4 version is 0.19, so it looks like the same issue as #359.

castaway commented 4 years ago

This can be fixed by upgrading Net::Amazon::Signature::V4 to the new 0.20 release