Skip to content

Commit

Permalink
don't sign transfer-encoding header (#2991)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucix-aws authored Jan 30, 2025
1 parent b820c57 commit 0b4f636
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
9 changes: 9 additions & 0 deletions .changelog/39bec3d624bb499baf58012de54829f1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "39bec3d6-24bb-499b-af58-012de54829f1",
"type": "bugfix",
"description": "Do not sign Transfer-Encoding header in Sigv4[a]. Fixes a signer mismatch issue with S3 Accelerate.",
"modules": [
".",
"internal/v4a"
]
}
9 changes: 5 additions & 4 deletions aws/signer/internal/v4/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ package v4
var IgnoredHeaders = Rules{
ExcludeList{
MapRule{
"Authorization": struct{}{},
"User-Agent": struct{}{},
"X-Amzn-Trace-Id": struct{}{},
"Expect": struct{}{},
"Authorization": struct{}{},
"User-Agent": struct{}{},
"X-Amzn-Trace-Id": struct{}{},
"Expect": struct{}{},
"Transfer-Encoding": struct{}{},
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions aws/signer/v4/v4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ func TestPresignBodyWithArrayRequest(t *testing.T) {

func TestSignRequest(t *testing.T) {
req, body := buildRequest("dynamodb", "us-east-1", "{}")
// test ignored headers
req.Header.Set("User-Agent", "foo")
req.Header.Set("X-Amzn-Trace-Id", "bar")
req.Header.Set("Expect", "baz")
req.Header.Set("Transfer-Encoding", "qux")
signer := NewSigner()
err := signer.SignHTTP(context.Background(), testCredentials, req, body, "dynamodb", "us-east-1", time.Unix(0, 0))
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions internal/v4a/internal/v4/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ package v4
var IgnoredHeaders = Rules{
DenyList{
MapRule{
"Authorization": struct{}{},
"User-Agent": struct{}{},
"X-Amzn-Trace-Id": struct{}{},
"Authorization": struct{}{},
"User-Agent": struct{}{},
"X-Amzn-Trace-Id": struct{}{},
"Transfer-Encoding": struct{}{},
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions internal/v4a/v4a_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ func TestDeriveECDSAKeyPairFromSecret(t *testing.T) {
func TestSignHTTP(t *testing.T) {
req := buildRequest("dynamodb", "us-east-1")

// test ignored headers
req.Header.Set("User-Agent", "foo")
req.Header.Set("X-Amzn-Trace-Id", "bar")
req.Header.Set("Transfer-Encoding", "qux")

signer, credProvider := buildSigner(t, true)

key, err := credProvider.RetrievePrivateKey(context.Background())
Expand Down

0 comments on commit 0b4f636

Please sign in to comment.