Skip to content

Commit 77eccdc

Browse files
sgmillermladlow
andauthored
Make the error response to the sys/internal/ui/mounts with no client token consistent (#10650) (#10674)
* Make the error response to the sys/internal/ui/mounts with no client token consistent * changelog * Don't test against an empty mount path * One other spot * Instead, do all token checks first and early out before even looking for the mount Co-authored-by: Meggie <[email protected]>
1 parent 506265d commit 77eccdc

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

changelog/10650.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
```release-note:bug
2+
core: Make the response to an unauthenticated request to sys/internal endpoints consistent regardless of mount existence.
3+
```
4+

vault/logical_system.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,6 +3312,20 @@ func (b *SystemBackend) pathInternalUIMountRead(ctx context.Context, req *logica
33123312
}
33133313
path = sanitizePath(path)
33143314

3315+
// Load the ACL policies so we can walk the prefix for this mount
3316+
acl, te, entity, _, err := b.Core.fetchACLTokenEntryAndEntity(ctx, req)
3317+
if err != nil {
3318+
return nil, err
3319+
}
3320+
if entity != nil && entity.Disabled {
3321+
b.logger.Warn("permission denied as the entity on the token is disabled")
3322+
return nil, logical.ErrPermissionDenied
3323+
}
3324+
if te != nil && te.EntityID != "" && entity == nil {
3325+
b.logger.Warn("permission denied as the entity on the token is invalid")
3326+
return nil, logical.ErrPermissionDenied
3327+
}
3328+
33153329
errResp := logical.ErrorResponse(fmt.Sprintf("preflight capability check returned 403, please ensure client's policies grant access to path %q", path))
33163330

33173331
ns, err := namespace.FromContext(ctx)
@@ -3344,20 +3358,6 @@ func (b *SystemBackend) pathInternalUIMountRead(ctx context.Context, req *logica
33443358
fullMountPath = ns.Path + me.Namespace().Path + me.Path
33453359
}
33463360

3347-
// Load the ACL policies so we can walk the prefix for this mount
3348-
acl, te, entity, _, err := b.Core.fetchACLTokenEntryAndEntity(ctx, req)
3349-
if err != nil {
3350-
return nil, err
3351-
}
3352-
if entity != nil && entity.Disabled {
3353-
b.logger.Warn("permission denied as the entity on the token is disabled")
3354-
return errResp, logical.ErrPermissionDenied
3355-
}
3356-
if te != nil && te.EntityID != "" && entity == nil {
3357-
b.logger.Warn("permission denied as the entity on the token is invalid")
3358-
return nil, logical.ErrPermissionDenied
3359-
}
3360-
33613361
if !hasMountAccess(ctx, acl, fullMountPath) {
33623362
return errResp, logical.ErrPermissionDenied
33633363
}

0 commit comments

Comments
 (0)