Best practice to codify the provisioning of new user with multi-user rotation securely #160
Unanswered
jackie-linz
asked this question in
Q&A
Replies: 1 comment
-
This is what I came up with at the end:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
We are doing as much of configuration-as-code as possible for the DB setup, so that it can be reliably reproduced across all our environments.
The setup includes:
Goal
We would like to use the combination of CDK and DB migration scripts to codify the provisioning of DB users securely, i.e. without having to commit any initial password in our repo.
Our initial design is to have DB migration script to create the users without password - which means the users cannot yet be used to login.
And then create the secret and multi-user rotation with CDK (for user
test1
) and withrotateImmediatelyOnUpdate: true
.We were thinking that upon the first execution, the rotation function would set password for
test1_clone
and from that point the credential becomes valid and client can login to the database using the credential from the secret.Problem
The multi-user rotation lambda have a security feature that verifies that the current credential can connect to the database successfully, before proceeding to set the new password, as per the following code snippets
aws-secrets-manager-rotation-lambdas/SecretsManagerRDSPostgreSQLRotationMultiUser/lambda_function.py
Lines 176 to 182 in b4b8eca
aws-secrets-manager-rotation-lambdas/SecretsManagerRDSMySQLRotationMultiUser/lambda_function.py
Lines 179 to 185 in b4b8eca
Which means the very first rotation would fail, leaving the users in the initial state where they cannot be used to login.
Potential solution considered
We thought of seeding the
test1
user with an initial password, so that the password rotation can work. However, with this approach the initial password would still be valid between the first and the second rotation (since first rotation actually only updates the password fortest1_clone
). This would leave the DB compromised.Question
What's the best practice to codify the provision of username/password credentials?
Beta Was this translation helpful? Give feedback.
All reactions