Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not sign Transfer-Encoding Header if present on the request #5895

Merged
merged 3 commits into from
Feb 20, 2025

Conversation

joviegas
Copy link
Contributor

@joviegas joviegas commented Feb 20, 2025

Motivation and Context

Currently, AWS SDKs sign the Transfer-Encoding chunked header during SigV4 authentication, causing signature validation failures in specific scenarios.

The issue occurs because Transfer-Encoding is a hop-by-hop header that intermediate proxies can modify.

This change proposes to stop signing the Transfer-Encoding header in SigV4(a).

Note : for Sigv4a signers using CRT it is done in crt side with awslabs/aws-c-auth#261

Modifications

  • Added Transfer-Encoding in list of LIST_OF_HEADERS_TO_IGNORE_IN_LOWER_CASE which already skips some of predefined headers

Testing

  • Added Junits
  • Added codegen-tst and checked Authorization doesnot have Transfer-Encoding

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

License

  • I confirm that this pull request can be released under the Apache 2 license

@joviegas joviegas requested a review from a team as a code owner February 20, 2025 00:45
@@ -68,7 +68,7 @@ public abstract class AbstractAws4Signer<T extends Aws4SignerParams, U extends A
private static final FifoCache<SignerKey> SIGNER_CACHE =
new FifoCache<>(SIGNER_CACHE_MAX_SIZE);
private static final List<String> LIST_OF_HEADERS_TO_IGNORE_IN_LOWER_CASE =
Arrays.asList("connection", "x-amzn-trace-id", "user-agent", "expect");
Arrays.asList("connection", "x-amzn-trace-id", "user-agent", "expect", "transfer-encoding");
Copy link
Contributor

Choose a reason for hiding this comment

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

We have the same list in HeaderTransformsHelper used by AwsS3V4ChunkSigner, do we need to add TE there also?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope , it is not required here because SDK add only one Header(singletonMap) via this function , that is checksum header and its always "x-amz-checksum-XYZ"

Map<String, List<String>> canonicalizeSigningHeaders = canonicalizeSigningHeaders(
Collections.singletonMap(checksumHeaderForTrailer, Arrays.asList(BinaryUtils.toBase64(calculatedChecksum))));
String canonicalizedHeaderString = getCanonicalizedHeaderString(canonicalizeSigningHeaders);

Copy link
Contributor Author

@joviegas joviegas Feb 20, 2025

Choose a reason for hiding this comment

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

I can add it just to make it consistent , I think its better to add this just to be consistent and avoid further confusion , will add test directly on HeaderTransformsHelper

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@joviegas joviegas force-pushed the joviegas/remove-transfer-encoding-from-signed branch from 982a946 to ef305db Compare February 20, 2025 18:22
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
22.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@joviegas joviegas added this pull request to the merge queue Feb 20, 2025
Merged via the queue into master with commit f461838 Feb 20, 2025
16 of 17 checks passed
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.

2 participants