Skip to content

fix(policy): resource-scoped Cedar policies never enforced + release-prep runtime fixes#414

Merged
imran-siddique merged 2 commits into
mainfrom
fix/cedar-resource-enforcement
Jul 23, 2026
Merged

fix(policy): resource-scoped Cedar policies never enforced + release-prep runtime fixes#414
imran-siddique merged 2 commits into
mainfrom
fix/cedar-resource-enforcement

Conversation

@imran-siddique

Copy link
Copy Markdown
Contributor

Why

While validating the quickstart ahead of Tuesday's release party, the shipped example policies turned out not to enforce at all.

The runtime evaluates policy through AGT's CedarBackend, which builds the request resource from a resource key in the evaluation context. Neither the ingress proxy (_build_cedar_context) nor the egress evaluator (authorize_egress) set it, so the resource defaulted to Resource::"default". Any policy written as resource == Resource::"<tool>" therefore never matched:

  • enforcing mode: no permit matches, so Cedar default-denies every call (403)
  • advisory mode: the deny is ignored and every call is forwarded regardless of policy (this is the 502-on-first-call the QA pass hit, because the call was forwarded to an upstream that was not running)

What

  • Set the Cedar resource to the tool name at ingress and egress, so resource == Resource::"<tool>" policies match. Verified end to end: sensitive tool returns 403 at the gateway with no upstream, permitted tool forwards and returns 200, and the signed claim records allowed: 1, denied: 1.
  • New regression tests (test_resource_scoped_policy.py) pin the context shape and the allow/deny decision at ingress and egress.

Smaller release-prep fixes in the second commit:

  • __version__ 0.1.0 -> 0.3.0 (matched pyproject.toml, so cmcp --version is honest)
  • default policy_bundle_path policy/ -> policies/ to match the shipped examples
  • corrected the auto-detect probe-order docstring to azure-cvm -> tpm -> sev-snp -> tdx
  • clearer session-close error (message + hint) instead of a bare string

Full unit suite: 820 passed, 6 skipped.

Docs and example/quickstart fixes (mock upstream, docker-compose, catalog rotation_mode, CLI table, autodetect wording) follow in separate PRs per surface. This PR must merge first: the rewritten example policies depend on this resource fix to enforce.

🤖 Generated with Claude Code

imran-siddique and others added 2 commits July 23, 2026 13:52
The AGT CedarBackend builds the request resource from the `resource` key in the
evaluation context. The ingress proxy and the egress evaluator never set it, so
resource defaulted to Resource::"default" and any policy of the form

    forbid(principal, action, resource == Resource::"<tool>");

silently never matched. In enforcing mode that default-denies every call; in
advisory mode it forwards every call regardless of policy. Set the resource to
the tool name at both ingress and egress.

Adds regression tests covering the context shape and end-to-end allow/deny.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…, session-close error

- __version__ 0.1.0 -> 0.3.0 so `cmcp --version` matches the package
- default policy_bundle_path policy/ -> policies/ to match the shipped examples
- correct the auto-detect probe-order docstring to azure-cvm -> tpm -> sev-snp -> tdx
- return a clear, actionable session-close error instead of a bare string

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@imran-siddique
imran-siddique merged commit eada739 into main Jul 23, 2026
12 checks passed
@imran-siddique
imran-siddique deleted the fix/cedar-resource-enforcement branch July 23, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant