Skip to content
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

Backport sys/internal/ui consistent error change to 1.6.x #10672

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/10650.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:bug
core: Make the response to an unauthenticated request to sys/internal endpoints consistent regardless of mount existence.
```

28 changes: 14 additions & 14 deletions vault/logical_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -3344,6 +3344,20 @@ func (b *SystemBackend) pathInternalUIMountRead(ctx context.Context, req *logica
}
path = sanitizePath(path)

// Load the ACL policies so we can walk the prefix for this mount
acl, te, entity, _, err := b.Core.fetchACLTokenEntryAndEntity(ctx, req)
if err != nil {
return nil, err
}
if entity != nil && entity.Disabled {
b.logger.Warn("permission denied as the entity on the token is disabled")
return nil, logical.ErrPermissionDenied
}
if te != nil && te.EntityID != "" && entity == nil {
b.logger.Warn("permission denied as the entity on the token is invalid")
return nil, logical.ErrPermissionDenied
}

errResp := logical.ErrorResponse(fmt.Sprintf("preflight capability check returned 403, please ensure client's policies grant access to path %q", path))

ns, err := namespace.FromContext(ctx)
Expand Down Expand Up @@ -3376,20 +3390,6 @@ func (b *SystemBackend) pathInternalUIMountRead(ctx context.Context, req *logica
fullMountPath = ns.Path + me.Namespace().Path + me.Path
}

// Load the ACL policies so we can walk the prefix for this mount
acl, te, entity, _, err := b.Core.fetchACLTokenEntryAndEntity(ctx, req)
if err != nil {
return nil, err
}
if entity != nil && entity.Disabled {
b.logger.Warn("permission denied as the entity on the token is disabled")
return errResp, logical.ErrPermissionDenied
}
if te != nil && te.EntityID != "" && entity == nil {
b.logger.Warn("permission denied as the entity on the token is invalid")
return nil, logical.ErrPermissionDenied
}

if !hasMountAccess(ctx, acl, fullMountPath) {
return errResp, logical.ErrPermissionDenied
}
Expand Down