Skip to content

Commit 4721701

Browse files
backport of commit 642b4f1 (#31046)
Co-authored-by: Bianca <48203644+biazmoreira@users.noreply.github.com>
1 parent 030d564 commit 4721701

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

changelog/31045.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
core: Fix string contains check in Identity APIs to be case-insensitive.
3+
```

vault/identity_store_entities.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func (i *IdentityStore) handleEntityUpdateCommon() framework.OperationFunc {
349349
entity.Policies = strutil.RemoveDuplicates(entityPoliciesRaw.([]string), false)
350350
}
351351

352-
if strutil.StrListContains(entity.Policies, "root") {
352+
if strutil.StrListContainsCaseInsensitive(entity.Policies, "root") {
353353
return logical.ErrorResponse("policies cannot contain root"), nil
354354
}
355355

vault/identity_store_groups.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func (i *IdentityStore) handleGroupUpdateCommon(ctx context.Context, req *logica
265265
group.Policies = strutil.RemoveDuplicatesStable(policiesRaw.([]string), true)
266266
}
267267

268-
if strutil.StrListContains(group.Policies, "root") {
268+
if strutil.StrListContainsCaseInsensitive(group.Policies, "root") {
269269
return logical.ErrorResponse("policies cannot contain root"), nil
270270
}
271271

vault/token_store.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2993,10 +2993,10 @@ func (ts *TokenStore) handleCreateCommon(ctx context.Context, req *logical.Reque
29932993
}
29942994
}
29952995

2996-
if strutil.StrListContains(te.Policies, "root") {
2996+
if strutil.StrListContainsCaseInsensitive(te.Policies, "root") {
29972997
// Prevent attempts to create a root token without an actual root token as parent.
29982998
// This is to thwart privilege escalation by tokens having 'sudo' privileges.
2999-
if !strutil.StrListContains(parent.Policies, "root") {
2999+
if !strutil.StrListContainsCaseInsensitive(parent.Policies, "root") {
30003000
return logical.ErrorResponse("root tokens may not be created without parent token being root"), logical.ErrInvalidRequest
30013001
}
30023002

@@ -3151,7 +3151,7 @@ func (ts *TokenStore) handleCreateCommon(ctx context.Context, req *logical.Reque
31513151
}
31523152

31533153
// Only calculate a TTL if you are A) periodic, B) have a TTL, C) do not have a TTL and are not a root token
3154-
if periodToUse > 0 || te.TTL > 0 || (te.TTL == 0 && !strutil.StrListContains(te.Policies, "root")) {
3154+
if periodToUse > 0 || te.TTL > 0 || (te.TTL == 0 && !strutil.StrListContainsCaseInsensitive(te.Policies, "root")) {
31553155
ttl, warnings, err := framework.CalculateTTL(sysView, 0, te.TTL, periodToUse, backendMaxTTL, explicitMaxTTLToUse, time.Unix(te.CreationTime, 0))
31563156
if err != nil {
31573157
return nil, err

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy