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

Reduce scope of Secret Manager policy for EC2 instance profile #30

Open
abbashus opened this issue Oct 27, 2021 · 0 comments
Open

Reduce scope of Secret Manager policy for EC2 instance profile #30

abbashus opened this issue Oct 27, 2021 · 0 comments

Comments

@abbashus
Copy link
Contributor

When the CDK code creates the EC2 instance for elastic search, it provides a policy that allows the EC2 instance to gain access to the username and password stored inside of secret manager. This username and password is used to configure a plugin on the elastic search instance so that basic auth can be used to authenticate to the service.

read_secrets_policy = iam.PolicyStatement(
      effect=iam.Effect.ALLOW,
      actions=["secretsmanager:GetResourcePolicy",
               "secretsmanager:GetSecretValue",
               "secretsmanager:DescribeSecret",
               "secretsmanager:ListSecretVersionIds",
               "secretsmanager:GetRandomPassword",
               "secretsmanager:ListSecrets"
               ],
      resources=["arn:aws:secretsmanager:*:*:secret:*"],
    )

The problem is that this policy does not restrict access to only the username and password secret, instead it gives access to all secrets within the secrets manager by specifying wildcards in the resources field. This would allow an attacker to gain access to all secrets if they happened to compromise any host that uses this policy.

Possible fixes

Scope the secret resources only to the secrets needed for the OpenSearch search functionality instead of using wildcards.

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

No branches or pull requests

1 participant