-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add Confused Deputy Prevention #449
Open
dricross
wants to merge
21
commits into
main
Choose a base branch
from
dricross/confused-deputy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The existing assume role test doesn't test the agent assuming a role. The test does assume a role, but only to populate a credentials file which the agent will use to obtain credentials. The real test is the agent using a credentials file so using a more appropriate name.
We renamed the old assume_role test to credentials_file so we can rename agent_assume_role to assume_role to make it more concise
This was referenced Jan 15, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the issue
To support confused deputy prevention, the CloudWatch Agent needs to be able to pass confused deputy context keys in the request headers of STS AssumeRole calls so that dependent service teams can allow their customers to use confused deputy context keys in their role policies.
For background on the confused deputy problem, see: https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html
Description of changes
assume_role
test tocredentials_file
aws sts assume-role
call to grab credentials for a specific role and creates a credentials file which the agent will use. It does not actually test the agent's ability to assume a role via the agent configuration. The new tests do so a rename of the existing test is warranted to avoid confusion.assume_role
test suite with several subtests, including positive and negative confused deputy prevention tests. This test runs on EC2 linux host onlycwa-integ-assume-role-<test id>
: Standard CloudWatch Agent permissions role with no confused deputy context keyscwa-integ-assume-role-<test id>-source_arn_key
: Standard CloudWatch Agent permissions role and uses theaws:SourceArn
context keycwa-integ-assume-role-<test id>-source_account_key
: Standard CloudWatch Agent permissions role and uses theaws:SourceAccount
context keycwa-integ-assume-role-<test id>-all_context_keys
: Standard CloudWatch Agent permissions role and uses the both theaws:SourceAccount
andaws:SourceArn
context keysAMZ_SOURCE_ACCOUNT
andAMZ_SOURCE_ARN
environment variables which configures the agent to populate confused deputy request headers and verify that the agent can assume an IAM role which uses a matchingaws:SourceArn
context key.AMZ_SOURCE_ACCOUNT
andAMZ_SOURCE_ARN
environment variables which configures the agent to populate confused deputy request headers and verify that the agent can assume an IAM role which uses a matchingaws:SourceAccount
context key.AMZ_SOURCE_ACCOUNT
andAMZ_SOURCE_ARN
environment variables which configuresthe agent to populate confused deputy request headers and verify that the agent can assume an IAM role which uses matchingaws:SourceArn
and theaws:SourceAccount
context keys.AMZ_SOURCE_ACCOUNT
environment variable and verify that the agent cannot assume an IAM role which uses theaws:SourceArn
context keys.AMZ_SOURCE_ARN
environment variable and verify that the agent cannot assume an IAM role which uses theaws:SourceArn
context keys.AMZ_SOURCE_ACCOUNT
andAMZ_SOURCE_ARN
environment variables which configures the agent to populate confused deputy request headers which do not match theaws:SourceAccount
context key of the IAM role it is configured to assume, and verify the agent is not able to assume the roleAMZ_SOURCE_ACCOUNT
andAMZ_SOURCE_ARN
environment variables which configures the agent to populate confused deputy request headers which do not match theaws:SourceArn
context key of the IAM role it is configured to assume, and verify the agent is not able to assume the roleLicense
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Tests
Example run: https://github.com/aws/amazon-cloudwatch-agent/actions/runs/12778135116/job/35673452648
Note: the tests are currently failing as the test accounts needs to be specially onboarded with the STS service in order for STS to accept confused deputy keys in the request headers.