-
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
Entity Alias transfer corrupts receiving entity? #5729
Comments
Consolidated repro case:
|
@vishalnayak this workflow is a bit confusing to me. If the alias is already tied to another entity, why do the entities get merged from attempting to update the alias? It seems like that shouldn't happen unless you specifically call I'm basically wondering if the issue is really when we're merging when we shouldn't. So in a normal merge triggered by |
There seem to be a few issues at work here. One is that handleAliasUpdateCommon doesn't take into account a scenario where you haven't found an alias due to given factors -- for instance if you don't provide a mount accessor. In that case you'll have an alias found by ID, but no aliasByFactors, which means This diff should (I think) fix that problem: diff --git a/vault/identity_store_aliases.go b/vault/identity_store_aliases.go
index e81851283..84c7f717f 100644
--- a/vault/identity_store_aliases.go
+++ b/vault/identity_store_aliases.go
@@ -181,6 +181,13 @@ func (i *IdentityStore) handleAliasUpdateCommon() framework.OperationFunc {
if entity == nil {
return nil, fmt.Errorf("existing alias is not associated with an entity")
}
+ } else if alias.ID != "" {
+ // This is an update, not a create; if we have an associated entity
+ // already, load it
+ entity, err = i.MemDBEntityByAliasID(alias.ID, true)
+ if err != nil {
+ return nil, err
+ }
}
resp := &logical.Response{} Second problem: in Fixing this is a bit tricker. I think what would have to happen is, if we hit the case where we found an Finally, back to merging behavior. Let's say that we in fact don't find the factors from an old index from I think fixing the first two issues will make the third less/not likely to ever occcur, but that doesn't mean we shouldn't change that behavior anyways unless there's a good reason to keep it. |
See #5729 (comment) for details Fixes #5729
When an entity-alias is updated to alias a different entity. The receiving entity now has two copies of the alias. Here is an example:
I believe this is also the root cause for #5348. Prior to 0.11.4 it was impossible to delete the transferred alias.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The receiving entity should only have one reference to the alias.
Environment:
vault status
): 0.11.4vault version
): 0.11.4Potential workaround
This problem can be avoided by instead first deleting the entity-alias and then recreating with the canonical_id field set instead of updating it. Using this approach means that the first created entity won't be deleted though, while on transfer the first created entity is deleted. I'm not sure what the implications of that are.
The text was updated successfully, but these errors were encountered: