Skip to content

bug(permissionPolicy): denied permission reason can hide scope mismatch when a grant exists for capability #188

Closed

Description

@morluto

Summary

evaluatePermission can return grant_revoked_or_consumed even when the actual failure is a scope mismatch (or other missing_* constraint), not a revoked/consumed grant.

Reproduction

  • Given a policy with at least one grant for the requested capability that is revoked/consumed (or otherwise excluded from candidates).
  • Use a request that does not satisfy that grant's scope (e.g. different root/origin/target details).
  • Call evaluatePermission.

The function currently:

  1. builds candidates by excluding revoked/consumed/expired/identity-mismatch grants,
  2. computes missing from candidates,
  3. sets reason to grant_revoked_or_consumed whenever candidates.length === 0 and there is any grant with the same capability, regardless of whether that grant covers the request.

Expected

If request constraints are not met by non-revoked grants, reason should be grant_required with actionable missing_* details.

Actual

reason can be grant_revoked_or_consumed even when no grant (including the revoked one) grants the requested capability under current constraints.

Impact

Users may be guided to revoke/consumption debugging paths while the permission is actually missing required scope roots/origins.

Reference

See src/domain/permissionPolicy.ts in evaluatePermission, around:

  • candidates filter (line ~138)
  • coveringGrant lookup (line ~156)
  • reason branch selecting grant_revoked_or_consumed (line ~172).

Activity

  1. added
    bug
    area: runtime
    on Oct 12, 2026
  2. added
    area: providers
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: providersarea: runtimebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions