Skip to content

Exclude additional hop-by-hop headers from SigV4 signing - #3643

Merged
jonathan343 merged 1 commit into
developfrom
ignore-hop-by-hop-headers
Mar 4, 2026
Merged

jonathan343 merged 1 commit into
developfrom
ignore-hop-by-hop-headers

Conversation

@jonathan343

@jonathan343 jonathan343 commented Mar 3, 2026 •

Copy link
Copy Markdown
Contributor

Overview

This PR aligns SigV4 header signing behavior with IAM guidance by excluding additional hop-by-hop headers from signature calculation. This prevents signature mismatch failures when intermediaries (for example, proxies or load balancers) mutate transport headers in transit.

Background

Botocore already excluded a subset of volatile headers (expect, transfer-encoding, user-agent, x-amzn-trace-id), but it did not exclude the full IAM-documented hop-by-hop set.

Summary

  • Added the following headers to SIGNED_HEADERS_BLACKLIST in botocore/auth.py:
    • connection
    • keep-alive
    • proxy-authenticate
    • proxy-authorization
    • te
    • trailer
    • upgrade
  • Added unit tests in tests/unit/auth/test_signers.py under TestS3SigV4Auth to verify each new header is excluded from SignedHeaders.
  • Updated _test_blocklist_header to assert against parsed SignedHeaders tokens instead of raw substring matching in the full Authorization header (avoids false positives for short header names like te).
  • Added changelog entry: .changes/next-release/enhancement-auth-88913.json.

Testing

  • python -m pytest tests/unit/auth/test_signers.py
  • Live verification against STS (GetCallerIdentity):
    • Signed requests with each new hop-by-hop header present
    • Mutated those headers after signing
    • Confirmed no signature mismatch errors (received successful responses)

References


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment on lines +410 to +434
def test_blocklist_connection_header(self):
self._test_blocklist_header('connection', 'keep-alive')

def test_blocklist_keep_alive_header(self):
self._test_blocklist_header('keep-alive', 'timeout=5')

def test_blocklist_proxy_authenticate_header(self):
self._test_blocklist_header(
'proxy-authenticate', 'Basic realm="proxy.example.com"'
)

def test_blocklist_proxy_authorization_header(self):
self._test_blocklist_header(
'proxy-authorization', 'Basic YWxhZGRpbjpvcGVuc2VzYW1l'
)

def test_blocklist_te_header(self):
self._test_blocklist_header('te', 'trailers')

def test_blocklist_trailer_header(self):
self._test_blocklist_header('trailer', 'x-amz-checksum-sha256')

def test_blocklist_upgrade_header(self):
self._test_blocklist_header('upgrade', 'websocket')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Would parametrized tests work better here, or do you prefer it as is?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept individual test methods to match the existing TestS3SigV4Auth style and make failures easy to pinpoint by test name. Since this file is unittest-style (not pytest-parametrized), I preferred explicit tests here.

@ubaskota ubaskota left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexgromero alexgromero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@jonathan343
jonathan343 merged commit d94d178 into develop Mar 4, 2026
90 checks passed
@jonathan343
jonathan343 deleted the ignore-hop-by-hop-headers branch March 4, 2026 02:51
aws-sdk-python-automation added a commit that referenced this pull request Mar 4, 2026
* release-1.42.61:
  Bumping version to 1.42.61
  Update to latest models
  auth: exclude additional hop-by-hop headers from SigV4 signing (#3643)
hswong3i pushed a commit to alvistack/boto-botocore that referenced this pull request Mar 5, 2026
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.

3 participants