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

VAULT-30877: Repopulate AWS static creds queue in initialize #28775

Merged

Conversation

miagilepner
Copy link
Contributor

Description

Closes #21935

Use the initialize function to re-populate the rotation queue on an active node. Store the credential's expiration value in storage and update it when it changes.

TODO only if you're a HashiCorp employee

  • Backport Labels: If this PR is in the ENT repo and needs to be backported, backport
    to N, N-1, and N-2, using the backport/ent/x.x.x+ent labels. If this PR is in the CE repo, you should only backport to N, using the backport/x.x.x label, not the enterprise labels.
    • If this fixes a critical security vulnerability or severity 1 bug, it will also need to be backported to the current LTS versions of Vault. To ensure this, use all available enterprise labels.
  • ENT Breakage: If this PR either 1) removes a public function OR 2) changes the signature
    of a public function, even if that change is in a CE file, double check that
    applying the patch for this PR to the ENT repo and running tests doesn't
    break any tests. Sometimes ENT only tests rely on public functions in CE
    files.
  • Jira: If this change has an associated Jira, it's referenced either
    in the PR description, commit message, or branch name.
  • RFC: If this change has an associated RFC, please link it in the description.
  • ENT PR: If this change has an associated ENT PR, please link it in the
    description. Also, make sure the changelog is in this PR, not in your ENT PR.

@miagilepner miagilepner added backport/ent/1.16.x+ent Changes are backported to 1.16.x+ent backport/1.18.x backport/ent/1.17.x+ent Changes are backported to 1.17.x+ent labels Oct 25, 2024
@miagilepner miagilepner requested a review from kpcraig October 25, 2024 13:03
@miagilepner miagilepner requested a review from a team as a code owner October 25, 2024 13:03
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Oct 25, 2024
@miagilepner miagilepner requested a review from a team as a code owner October 25, 2024 13:05
Copy link

github-actions bot commented Oct 25, 2024

CI Results:
All Go tests succeeded! ✅

Copy link

github-actions bot commented Oct 25, 2024

Build Results:
All builds succeeded! ✅

@miagilepner miagilepner changed the title populate rotation queue in initialize VAULT-30877: Repopulate AWS static creds queue in initialize Oct 25, 2024
@miagilepner miagilepner added this to the 1.18.1 milestone Oct 25, 2024
Copy link
Contributor

@fairclothjm fairclothjm left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @miagilepner for picking this up!

updatedRole2Secret = getSecret(c, "role2")

if originalRole1Secret == updatedRole1Secret && originalRole2Secret == updatedRole2Secret {
return fmt.Errorf("secrets haven't been rotated")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Is there a way to make this error point to the test file? Instead of the testhelpers.go file:

    testhelpers.go:726: did not complete before deadline, err: secrets haven't been rotated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good idea! I added a t.Helper() to the testhelpers function, so now we see:

    rotation_test.go:554: did not complete before deadline, err: secrets haven't been rotated

@ldilalla-HC ldilalla-HC modified the milestones: 1.18.1, 1.18.2 Oct 29, 2024
@fairclothjm
Copy link
Contributor

I was testing this today and after stopping and restarting Vault (with vcm) I am getting an error:

2024-10-30T16:38:50.504-0500 [ERROR] secrets.aws.aws_25fb669c: failed to create credential, re-queueing:
  error=
  | iam user didn't exist, or username/userid didn't match: unable to validate username "[email protected]": NoCredentialProviders: no valid providers in chain. Deprecated.
  | \tFor verbose messaging see aws.Config.CredentialsChainVerboseErrors

2024-10-30T16:38:50.504-0500 [ERROR] rollback: error rolling back: path=aws/
  error=
  | 1 error occurred:
  | \t* error(s) occurred while rotating expired static credentials: 1 error occurred:
  | \t* iam user didn't exist, or username/userid didn't match: unable to validate username "[email protected]": NoCredentialProviders: no valid providers in chain. Deprecated.
  | \tFor verbose messaging see aws.Config.CredentialsChainVerboseErrors

I am not sure if this is just my setup though.

@miagilepner
Copy link
Contributor Author

@fairclothjm interesting, how are you setting this up? I tested it now with vcm using:

$ vault write aws/config/root \
  access_key=<redacted> \
  secret_key=<redacted>     # this is an IAM user with username [email protected] 

$ vault write aws/static-roles/test-role \
  [email protected] \
  rotation_period=1m        # this is a separate IAM user 

I didn't see any errors in the server logs from the rollbacks.

@miagilepner miagilepner force-pushed the miagilepner/VAULT-30877-aws-static-rotation-repopulate branch from 0b6f9b7 to 9bea0ed Compare October 31, 2024 15:04
@fairclothjm
Copy link
Contributor

@miagilepner Thanks, I was using the same user for the vault admin and static user. 😅 Now I am working through a policy issue with my vault admin user.

@fairclothjm
Copy link
Contributor

@miagilepner I got it working. Apparently the permission boundary I am using requires a certain naming convention to function properly.

@fairclothjm fairclothjm merged commit 10bd15f into main Nov 4, 2024
92 checks passed
@fairclothjm fairclothjm deleted the miagilepner/VAULT-30877-aws-static-rotation-repopulate branch November 4, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/ent/1.16.x+ent Changes are backported to 1.16.x+ent backport/ent/1.17.x+ent Changes are backported to 1.17.x+ent backport/1.18.x hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: HA cluster failover breaks AWS static role rotation
3 participants