Skip to content

Refactor: Remove explicit AWS credentials from MessageQueueConfiguration #2

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sashimikun
Copy link

Refactor: Enhance Security by Removing Explicit AWS Credentials

Addresses a critical security vulnerability (CWE-798: Use of Hard-coded Credentials / CWE-287: Improper Authentication) by eliminating the direct inclusion of accessKey and secretKey in MessageQueueConfiguration.java.

Security Risk Addressed:
Directly mapping AWS credentials in configuration classes, even if intended to be loaded from environment variables, poses a significant security risk. This configuration pattern could lead to:

  • Accidental exposure of credentials if hardcoded during development.
  • Compromise if committed to version control.
  • Exposure in environments where environment variables are not securely managed.

Such exposure could grant unauthorized access to sensitive AWS resources, leading to potential data breaches or service disruptions.

Solution Implemented:
The application now leverages the AWS SDK's default credential provider chain. This is achieved by:

  1. Removing accessKey and secretKey fields from MessageQueueConfiguration.java.
  2. Enabling the DefaultCredentialsProvider by setting aws.default-credentials-provider-chain-enabled=true in application.yaml.
  3. Removing the corresponding accessKey and secretKey entries from the status.messageQueue configuration in application.yaml.

Benefits of this Approach:

  • Enhanced Security: Conforms to AWS best practices by not storing or passing credentials directly in application code or configuration files.
  • Improved Manageability: Simplifies credential management by relying on standard AWS mechanisms like IAM roles for EC2 instances, Fargate tasks, or environment variables, which are designed for secure credential handling.
  • Reduced Risk: Significantly lowers the risk of credential leakage.

This change ensures that AWS credentials are automatically and securely discovered from recommended sources, strengthening the overall security posture of the application.

sps-irs and others added 2 commits May 29, 2025 13:12
Removes the accessKey and secretKey fields from MessageQueueConfiguration.java and updates application.yaml to enable the use of the AWS SDK's default credential provider chain.

This change enhances security by preventing the direct mapping or hardcoding of sensitive AWS credentials within the application's configuration classes. The application will now rely on more secure methods for credential discovery, such as IAM roles or environment variables, as managed by the DefaultCredentialsProvider.

Key changes:
- Removed `accessKey` and `secretKey` from `MessageQueueConfiguration.java`.
- Set `aws.default-credentials-provider-chain-enabled=true` in `application.yaml`.
- Removed redundant `accessKey` and `secretKey` from `status.messageQueue` in `application.yaml`.
@Lvl4Sword
Copy link

This is just AI slop that should be disregarded.

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.

4 participants