-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
RFC on Refactor of AWS Secret Backend #4229
Comments
Hi Joel, This is looking great! A few questions: For For Overall I think this looks like it will make it much easier to use and bring some much needed order to things! |
Thanks Jeff! :)
I agree it shouldn't open any security vulnerabilities, but I reserve the right to change my mind when I start writing the code :) The question is, what happens when the user attempts to retrieve credentials? I think the behavior when a
That's an interesting proposal. I like it and think it'll make it much easier for users. I'll try to take a crack at it. |
Yeah, I think if on cred fetch they don't actually provide an arn and there are multiple, then deny the fetch with an appropriate error. Or, another parameter to specify a default. (Or, codify a default via documentation.) |
I started working through the backwards compatibility/upgrade story, and I realized there's an ambiguity in the role definition as implemented today. If the role data has a policy document, it can be either attached to an IAM user or used as the Policy parameter when calling GetFederationToken. I don't believe there's any way to disambiguate this a prior, though I'd love to have somebody correct me on this (though I'd certainly love to have somebody correct my thoughts here). I think the options are:
My inclination is to pick option 2, and if option 3 is easy, then also implement that. (Of course, there's also option 5: abandon this refactor because it's harder than I originally anticipated and might not be worth it given some of these tradeoffs. I'm not advocating it but do want to explicitly mention it.) |
Hi Joel, I with you on 2 and ideally 3 as well. With 3, do you mean, enforce in the role that it's one of those types, or in the request data? People use AWS quite a lot and I am concerned about backwards compat, but at the same time I think that making it more explicit and clear and non-ambiguous is more important in the long run. It's never a good time to rip off the band-aid... |
I'm a little confused by your question. My thought is that Vault should refuse to hand out
Totally with you on this. I have some ideas and am writing code. I think I can make this work, but I need a couple more days before the code is ready for public consumption, and I think it'll be more productive to have that discussion once I've gotten some real code out there. |
The AWS secret engine had a lot of confusing overloading with role paramemters and how they mapped to each of the three credential types supported. This now adds parameters to remove the overloading while maintaining backwards compatibility. With the change, it also becomes easier to add other feature requests. Attaching multiple managed policies to IAM users and adding a policy document to STS AssumedRole credentials is now also supported. Fixes hashicorp#4229 Fixes hashicorp#3751 Fixes hashicorp#2817
Unless I'm misunderstanding the proposal, I don't like the idea of multiple Otherwise, this all jives with how I'd like to see Vault's AWS secrets provider function. Also, I agree with @jefferai that backwards compatibility is unfortunately a requirement. |
@flyinbutrs Actually I was suggesting that we break it :-) |
I don't have a strong opinion about {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": ["arn:aws:iam::123456789012:role/Role1", "arn:aws:iam::123456789012:role/Role2"],
}]
} so I think it makes sense to have Vault semantics more closely mirror those of AWS. Similarly with policy ARNs, if you specify more than one policy, you get the permissions of all of the policies combined, so if you specify multiple role ARNs, it also feels natural to be able to select which of the roles you want to get access to. Otherwise, I think everything should be backwards compatible EXCEPT the reading of the role data. The main concern I have around that is, as I have it now, you write in a |
* Make AWS credential types more explicit The AWS secret engine had a lot of confusing overloading with role paramemters and how they mapped to each of the three credential types supported. This now adds parameters to remove the overloading while maintaining backwards compatibility. With the change, it also becomes easier to add other feature requests. Attaching multiple managed policies to IAM users and adding a policy document to STS AssumedRole credentials is now also supported. Fixes #4229 Fixes #3751 Fixes #2817 * Add missing write action to STS endpoint * Allow unsetting policy_document with empty string This allows unsetting the policy_document by passing in an empty string. Previously, it would fail because the empty string isn't a valid JSON document. * Respond to some PR feedback * Refactor and simplify role reading/upgrading This gets rid of the duplicated role upgrade code between both role reading and role writing by handling the upgrade all in the role reading. * Eliminate duplicated AWS secret test code The testAccStepReadUser and testAccStepReadSTS were virtually identical, so they are consolidated into a single method with the path passed in. * Switch to use AWS ARN parser
I've started to do the (long-delayed) refactor I mentioned in #2817 (comment) and I'd like to open up an RFC on my proposed changes before writing too much code.
The existing behavior is as follows (as best I understand the code):
policy
orarn
parameter, but not both.arn
parameters (beyond ensuring that apolicy
parameter is not also supplied)policy
parameter (beyond that anarn
is not also supplied) is that it is valid JSONarn:
the returned data structure hasarn
as a key, and otherwise, it haspolicy
as a key. This can lead to such weird behavior asvault write aws/roles/foo arn=bar
succeeding but a subsequentvault read aws/roles/foo
has apolicy
variable in the output.aws/creds
endpoint, it always creates an IAM user.arn:
Vault assumes it's the ARN of a manged policy and attempts to attach it to the user.aws/sts
endpoint:arn:
, then it assumes it's a role ARN to assume and attempts to assume it, but only if the string also contains:role
; otherwise, it errors out.sts:GetFederationToken
with the policy data as thePolicy
paramemterWhat I am proposing is:
credential_type
: One ofiam_user
,assumed_role
, orfederation_token
, to be explicit about the credential type being requested, rather than relying on some hard-to-discern behavior based on the specific data of the role.policy_arns
: Aframework.TypeCommaStringSlice
of managed policy ARNs to be attached to a created IAM user. This would only be valid whencredential_type
isiam_user
. I believe this would solve the request in multiple arn options for aws backend over vault client (cli) #2817role_arns
: The ARNs of the AWS role allowed to be assumed when calling AssumeRole. This would only be valid whencredential_type
isassumed_role
.policy_document
: The JSON encoding of an AWS policy document. This would be valid for all policy types.credential_type
isassumed_role
then the behavior requested in Feature Request - AWS Secret Backend: Policy support to STS #3751 would apply, with the following notes:role_arns
for the role, then fail the login. Otherwise, succeed.role_arns
then assume that (current behavior).role_arns
then fail the login. (In the future, we might consider the ability to specify a default or to codify a default, e.g., the first entry in the list.)credential_type
isiam_user
then the policy would be attached to the IAM user created. This would be in addition to any managed policy ARNs attached.credential_type
isfederation_token
then this would maintain the current behavior.aws/sts
becomes an alias foraws/creds
because the separation is already encoded in the roles.aws/sts
oraws/creds
endpoint will honor thecredential_type
in the role regardless of which endpoint is specified, and the parameters of the role will behave as described above.I realize my proposal is a bit verbose in terms of asking clients to be more explicit about what they're asking for, but I personally think it's better than what is there now, and I'd welcome feedback about how to improve it! :)
I don't (yet) have a backwards compatibility story completely ironed out yet. I'd like to get feedback about my proposal first, and then I can figure out how to handle backwards compatibility.
Thoughts?
EDIT: Updated in response to feedback to reflect current thinking.
The text was updated successfully, but these errors were encountered: