Skip to content

Commit

Permalink
Remove transfer-encoding from signed headers
Browse files Browse the repository at this point in the history
  • Loading branch information
nateprewitt committed Jan 23, 2025
1 parent 81fdad2 commit 0fd238c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-Signing-82847.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "Signing",
"description": "No longer sign transfer-encoding header for SigV4"
}
1 change: 1 addition & 0 deletions botocore/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
SIGV4_TIMESTAMP = '%Y%m%dT%H%M%SZ'
SIGNED_HEADERS_BLACKLIST = [
'expect',
'transfer-encoding',
'user-agent',
'x-amzn-trace-id',
]
Expand Down
17 changes: 10 additions & 7 deletions tests/unit/auth/test_signers.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def test_query_string_params_in_urls(self):
cqs = self.auth.canonical_query_string(request)
self.assertEqual('marker=%C3%A4%C3%B6%C3%BC-01.txt&prefix=', cqs)

def _test_blacklist_header(self, header, value):
def _test_blocklist_header(self, header, value):
request = AWSRequest()
request.url = 'https://s3.amazonaws.com/bucket/foo'
request.method = 'PUT'
Expand All @@ -386,16 +386,19 @@ def _test_blacklist_header(self, header, value):
auth.add_auth(request)
self.assertNotIn(header, request.headers['Authorization'])

def test_blacklist_expect_headers(self):
self._test_blacklist_header('expect', '100-continue')
def test_blocklist_expect_headers(self):
self._test_blocklist_header('expect', '100-continue')

def test_blacklist_trace_id(self):
self._test_blacklist_header(
def test_blocklist_trace_id(self):
self._test_blocklist_header(
'x-amzn-trace-id', 'Root=foo;Parent=bar;Sampleid=1'
)

def test_blacklist_headers(self):
self._test_blacklist_header('user-agent', 'botocore/1.4.11')
def test_blocklist_user_agent_header(self):
self._test_blocklist_header('user-agent', 'botocore/1.4.11')

def test_blocklist_transfer_encoding_header(self):
self._test_blocklist_header('transfer-encoding', 'chunked')

def test_uses_sha256_if_config_value_is_true(self):
self.client_config.s3['payload_signing_enabled'] = True
Expand Down

0 comments on commit 0fd238c

Please sign in to comment.