-
Notifications
You must be signed in to change notification settings - Fork 870
feat(S3): Add transparency logging for signature version downgrades #3965
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
base: development
Are you sure you want to change the base?
feat(S3): Add transparency logging for signature version downgrades #3965
Conversation
feat(S3): Add logging for SigV4 to SigV2 downgrade in presigned URLs When generating presigned URLs with expiration times exceeding the SigV4 maximum (7 days), the SDK automatically downgrades to SigV2 in supported regions. This change adds transparent logging to inform developers when this downgrade occurs. **Changes:** - Add informative log message in AmazonS3Client.Extensions.cs when SigV4 downgrades to SigV2 due to expiration time limits - Log includes specific details: requested expiration time, SigV4 maximum limit, bucket name, and region - Encourages security best practices by suggesting shorter expiration times - Uses existing SDK logging patterns with Logger.GetLogger() and InfoFormat() **Testing:** - Added comprehensive unit tests in SignatureVersionTests.cs - Test 1: Verifies downgrade behavior in SigV2-supported regions (us-east-1) - Test 2: Verifies exception handling in unsupported regions (eu-north-1) - Tests validate signature version changes and URL format correctness **Benefits:** - Improves developer experience with transparent security decisions - Helps developers understand when and why signature version changes occur - Promotes security best practices through actionable guidance - Maintains backward compatibility with existing functionality **Files Modified:** - sdk/src/Services/S3/Custom/AmazonS3Client.Extensions.cs - sdk/test/Services/S3/UnitTests/Custom/SignatureVersionTests.cs Fixes: Lack of visibility into automatic SigV4 to SigV2 downgrades
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds transparency logging to the Amazon S3 client when presigned URLs are automatically downgraded from SigV4 to SigV2 due to expiration time limits exceeding 7 days. The change provides visibility into this automatic security downgrade that was previously silent.
Key Changes:
- Added informative logging in the signature version determination logic
- Added comprehensive unit tests to verify downgrade behavior in both supported and unsupported regions
- Added manual test projects to validate logging functionality
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
AmazonS3Client.Extensions.cs |
Adds logging when SigV4 downgrades to SigV2 due to expiration limits |
SignatureVersionTests.cs |
Adds unit tests for downgrade scenarios in supported/unsupported regions |
TestS3Logging.csproj |
Test project configuration for manual logging validation |
TestS3Logging.cs |
Comprehensive manual test with output capture and verification |
TestLogging.cs |
Simple manual test for basic logging functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@@ -0,0 +1,181 @@ | |||
using System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be a standalone test file that should not be included in a production SDK pull request. Test files for manual verification should be excluded from the main codebase and handled separately.
Copilot uses AI. Check for mistakes.
Console.WriteLine("\nTest completed. Check the log output above for the downgrade message."); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be a standalone test file that should not be included in a production SDK pull request. Test files for manual verification should be excluded from the main codebase and handled separately.
} |
Copilot uses AI. Check for mistakes.
</Reference> | ||
</ItemGroup> | ||
|
||
</Project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This project file appears to be for manual testing and should not be included in the main SDK repository. Consider moving this to a separate testing directory or excluding it from the pull request.
</Project> |
Copilot uses AI. Check for mistakes.
are you able to add a dev config file similar to https://github.com/aws/aws-sdk-net/blob/50e5ddd9f27a7ce50fd0aa44e9735398ae9a3f50/generator/.DevConfigs/f2b3d288-839a-4d44-8124-efa681fa4b41.json something like
|
using Amazon; | ||
using Amazon.S3; | ||
using Amazon.S3.Model; | ||
using Amazon.Runtime.Internal.Util; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove these extra files (testlogging, tests3logging, tests3loggin.csproj)? the rest of the PR seems fine
Add logging for SigV4 to SigV2 downgrade in presigned URLs
Description
This pull request adds transparent logging to the Amazon S3 client when presigned URLs are automatically downgraded from SigV4 to SigV2 due to expiration time limits. When developers request presigned URLs with expiration times exceeding the SigV4 maximum (7 days / 604,800 seconds), the SDK silently downgrades to SigV2 in supported regions. This change provides visibility into this automatic decision through informative logging.
Key Changes:
AmazonS3Client.Extensions.cs
within theDetermineSignatureVersionToUse
methodLogger.GetLogger()
andInfoFormat()
Log Message Format:
Presigned URL expiration (691200 seconds) exceeds SigV4 maximum (604800 seconds). Automatically using SigV2 for bucket 'example-bucket' in region 'us-east-1'. Consider reducing expiration time to use SigV4 for better security.
Motivation and Context
Currently, when developers request presigned URLs with long expiration times (> 7 days), the AWS SDK for .NET automatically downgrades from SigV4 to SigV2 without any notification. This silent behavior can lead to:
This change addresses these issues by providing transparent, actionable logging that:
This enhancement improves developer experience and security awareness without introducing any breaking changes.
Testing
Unit Tests Added:
TestSigV4ToSigV2DowngradeLogging
: Verifies downgrade behavior in SigV2-supported regionsus-east-1
regionSignature=
parameter present)X-Amz-Signature
not present)TestSigV4ToSigV2DowngradeInUnsupportedRegion
: Verifies exception handling in unsupported regionseu-north-1
region (no SigV2 support)ArgumentException
is thrownTesting Environment:
Manual Verification:
Screenshots (if appropriate)
N/A - This change involves logging functionality without UI components.
Types of changes
Checklist
License