fog icon indicating copy to clipboard operation
fog copied to clipboard

Glacier: UTF-8 descriptions break signature?

Open schmingle opened this issue 14 years ago • 2 comments

so, i think there may be an issue with having UTF-8 strings in archive descriptions. my code looks something like this:

glacier = Fog::AWS::Glacier.new(:aws_access_key_id => XXX, :aws_secret_access_key => YYY)
vault = glacier.vaults.get('some_vault_id')
file_name = "/2011/BB/@clips/Дом 14.06 расположение комнат.jpg"
vault.archives.create(:body => File.open(file_name), :description => file_name, :multipart_chunk_size => 1024 * 1024)

when it gets run, i receive this error back from AWS:

response => #<Excon::Response:0xb98c58c @body="{\"message\":\"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.\\n\\nThe Canonical String for this request should have been\\n'POST\\n/-/vaults/icebox_vault_9342004be9/multipart-uploads\\n\\ndate:Thu, 11 Oct 2012 05:05:31 +0000\\nhost:glacier.us-east-1.amazonaws.com\\nx-amz-archive-description:/2011/BB/@clips/\xC3\x90\xC2\x94\xC3\x90\xC2\xBE\xC3\x90\xC2\xBC 14.06 \xC3\x91\xC2\x80\xC3\x90\xC2\xB0\xC3\x91\xC2\x81\xC3\x90\xC2\xBF\xC3\x90\xC2\xBE\xC3\x90\xC2\xBB\xC3\x90\xC2\xBE\xC3\x90\xC2\xB6\xC3\x90\xC2\xB5\xC3\x90\xC2\xBD\xC3\x90\xC2\xB8\xC3\x90\xC2\xB5 \xC3\x90\xC2\xBA\xC3\x90\xC2\xBE\xC3\x90\xC2\xBC\xC3\x90\xC2\xBD\xC3\x90\xC2\xB0\xC3\x91\xC2\x82.jpg\\nx-amz-date:20121011T050531Z\\nx-amz-glacier-version:2012-06-01\\nx-amz-part-size:1048576\\n\\ndate;host;x-amz-archive-description;x-amz-date;x-amz-glacier-version;x-amz-part-size\\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'\\n\\nThe String-to-Sign should have been\\n'AWS4-HMAC-SHA256\\n20121011T050531Z\\n20121011/us-east-1/glacier/aws4_request\\nc13b937313e6e695dbb0760a4f5df4738ba0293fd820ab9f0d93ff0c7c127d4e'\\n\",\"code\":\"InvalidSignatureException\",\"type\":\"Client\"}", @headers={"x-amzn-RequestId"=>"6TBN5NMAhaAqQFmnAMmFj-EfbEU8rYeK2phpU1vWC0GPtC8", "Content-Type"=>"application/json", "Content-Length"=>"1008", "Date"=>"Thu, 11 Oct 2012 05:05:30 GMT"}, @status=403>

it works perfectly fine if i change description to something like "foo".

can you guys confirm this is true or untrue?

schmingle avatar Oct 11 '12 05:10 schmingle

Not at my computer at the moment but it looks like I forgot to escape header values when building string to sign.

The code that does this is at

https://github.com/fog/fog/blob/master/lib/fog/aws/signaturev4.rb

I won't be able to look at this but it should be fairly straightforward. If you take a stab at this, make sure to add a failing test first - I only implemented some of the aws signature test suite - I'm sure that would have a test case with non ASCII header values

On 11 Oct 2012, at 06:17, Khang Tran [email protected] wrote:

so, i think there may be an issue with having UTF-8 strings in archive descriptions. my code looks something like this:

glacier = Fog::AWS::Glacier.new(:aws_access_key_id => XXX, :aws_secret_access_key => YYY) vault = glacier.vaults.get('some_vault_id') file_name = "/2011/BB/@clips/Дом 14.06 расположение комнат.jpg" vault.archives.create(:body => File.open(file_name), :description => file_name, :multipart_chunk_size => 1024 * 1024) when it gets run, i receive this error back from AWS:

response => #<Excon::Response:0xb98c58c @body="{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.\n\nThe Canonical String for this request should have been\n'POST\n/-/vaults/icebox_vault_9342004be9/multipart-uploads\n\ndate:Thu, 11 Oct 2012 05:05:31 +0000\nhost:glacier.us-east-1.amazonaws.com\nx-amz-archive-description:/2011/BB/@clips/\xC3\x90\xC2\x94\xC3\x90\xC2\xBE\xC3\x90\xC2\xBC 14.06 \xC3\x91\xC2\x80\xC3\x90\xC2\xB0\xC3\x91\xC2\x81\xC3\x90\xC2\xBF\xC3\x90\xC2\xBE\xC3\x90\xC2\xBB\xC3\x90\xC2\xBE\xC3\x90\xC2\xB6\xC3\x90\xC2\xB5\xC3\x90\xC2\xBD\xC3\x90\xC2\xB8\xC3\x90\xC2\xB5 \xC3\x90\xC2\xBA\xC3\x90\xC2\xBE\xC3\x90\xC2\xBC\xC3\x90\xC2\xBD\xC3\x90\xC2\xB0\xC3\x91\xC2\x82.jpg\nx-amz-date:20121011T050531Z\nx-amz-glacier-version:2012-06-01\nx-amz-part-size:1048576\n\ndate;host;x-amz-archive-description;x-amz-date;x-amz-glacier-version;x-amz-part-size\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'\n\nThe String-to-Sign should have been\n'AWS4-HMAC-SHA256\n20121011T050531Z\n20121011/us-east-1/glacier/aws4_request\nc13b937313e6e695dbb0760a4f5df4738ba0293fd820ab9f0d93ff0c7c127d4e'\n","code":"InvalidSignatureException","type":"Client"}", @headers={"x-amzn-RequestId"=>"6TBN5NMAhaAqQFmnAMmFj-EfbEU8rYeK2phpU1vWC0GPtC8", "Content-Type"=>"application/json", "Content-Length"=>"1008", "Date"=>"Thu, 11 Oct 2012 05:05:30 GMT"}, @status=403> it works perfectly fine if i change description to something like "foo".

can you guys confirm this is true or untrue?

— Reply to this email directly or view it on GitHub.

fcheung avatar Oct 11 '12 06:10 fcheung

@schmingle - I believe this is closed by #1205 but let us know if you continue to see problems.

geemus avatar Oct 15 '12 21:10 geemus