Skip to content

Let Cedar grant tool visibility with read_tool - #7358

Merged
ChrisJBurns merged 16 commits into
stacklok:mainfrom
rkb32:feat/6924-cedar-read-tool
Nov 28, 2026
Merged

ChrisJBurns merged 16 commits into
stacklok:mainfrom
rkb32:feat/6924-cedar-read-tool

Conversation

@rkb32

@rkb32 rkb32 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #6924.
Part of #4048. Builds on #6903 (tool:call implies tool:read), now on main.

Summary

Why: Cedar lists a tool on tools/list only when a call_tool policy allows it, so a policy cannot grant visibility without also allowing invocation (#6924).

What: A read_tool action. A tool is listed when a permit scoped to read_tool allows it and no call or read forbid matches, or when a call_tool permit allows it and no read_tool forbid matches. Cedar answers tool:read itself, so the tool:call fallback does not apply to Cedar. The read decision uses only the policies whose action scope names read_tool.

Does this introduce a user-facing change?

  • Policy sets with no read_tool policy: no change. They list the same tools as before.
  • Policy sets with a read_tool permit: a tool can be listed without being callable.
  • A call_tool forbid still hides its tool from tools/list. This is unchanged.
  • A forbid that names read_tool in its scope hides the tool even when call_tool allows it.
  • A forbid that mentions read_tool only in its conditions does not hide tools. The server logs a warning at load.
  • A Cedar error from a forbid, or one not tied to a policy, hides the tool from tools/list. Before, the same error also hid it.
  • A Cedar error from a call_tool permit only means that permit did not match. A read_tool permit can still list the tool.
  • A Cedar error from a read_tool permit fails the tool read with an error and hides the tool. A broken read_tool policy shows up in the logs.
  • Missing identity: tool read now returns an error with a WARN log. Before, it returned false silently. The tool is hidden either way.

Special notes for reviewers

  • Unscoped forbids that only trigger on a read request (for example when { resource.operation == "read" }) and action-group scopes do not hide tools. The docs say so.
  • The HTTP PDP is unchanged; it stays on tool:call for visibility unless forward_tool_read is set.
  • Prompts, resources and skills are out of scope; this is tools only.

Test plan

  • go test ./pkg/authz/... ./pkg/vmcp/core/ (run locally)
  • New guard tests (existing behavior) and distinguishing tests (read_tool rules)
  • golangci-lint (upstream CI, green on 2e0566f)
  • E2E (upstream CI, green on 2e0566f)

🤖 Generated with Claude Code

Uncovered lines are defensive returns that can't be reached because IDs are built with fixed :: prefixes.

rkb32 added 3 commits November 27, 2026 10:58
A tool is listed when a call_tool permit allows it and no read_tool
forbid matches, or when a read_tool-scoped permit allows it and no
call or read forbid matches. Policy sets with no read_tool policy list
the same tools as before. Cedar answers tool:read itself, so the
tool:call fallback no longer applies to Cedar.
The warning matched the unquoted action name, so it never fired. Match
the quoted form cedar-go writes, add a test for it, and update the
ToolReadNative comment that still said Cedar does not implement it.
Name the unused receiver, and iterate policies with All() instead of the
deprecated Map().
@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.52632% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.64%. Comparing base (4d83959) to head (2819a33).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
pkg/authz/authorizers/cedar/read_tool.go 91.93% 5 Missing ⚠️
pkg/authz/authorizers/cedar/core.go 87.87% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7358      +/-   ##
==========================================
- Coverage   82.69%   82.64%   -0.05%     
==========================================
  Files         947      934      -13     
  Lines       97369    97023     -346     
==========================================
- Hits        80519    80186     -333     
+ Misses      16845    16832      -13     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rkb32
rkb32 force-pushed the feat/6924-cedar-read-tool branch from ad8f74a to 9e0b20e Compare November 27, 2026 19:07
@rkb32
rkb32 marked this pull request as ready for review November 27, 2026 19:29
@rkb32
rkb32 requested a review from ChrisJBurns as a code owner November 27, 2026 19:29
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-27T19:29:59.969120Z
We couldn’t complete this review. Comment @codex review to try again.
9e0b20e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@ChrisJBurns ChrisJBurns left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Nit · correctness · tests — ToolCallImpliesRead contract docs and callers still describe Cedar as using the decorator fallback (pkg/authz/authorizers/tool_read.go:10)

    Cedar now implements ToolReadNative and answers true, so neither in-tree authorizer takes the read-then-call path described in the type doc (tool_read.go:10-15) or in tool_filter.go:17-18. Cedar's own visibility rule also breaks "tool:call implies tool:read" when a read_tool forbid exists. pkg/vmcp/core/admission_test.go:614-617 says "Cedar denies every tool:read check ... Keeping weather proves the fallback". That is no longer true: the test would pass even if the vMCP factory stopped wrapping the decorator, so it no longer guards the wrapping it was written for.

    Recommendation: Update the ToolCallImpliesRead and ToolReadNative docs to name Cedar as a native answerer and describe the fallback as applying only to authorizers that do not implement ToolReadNative. Update the tool_filter.go comment. Rewrite the admission test to check that the decorator is wrapped, for example with a non-native mock authorizer, rather than relying on Cedar.

Comment thread docs/authz.md Resolved
Comment thread pkg/authz/authorizers/cedar/core.go Resolved
@rkb32

rkb32 commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Re @ChrisJBurns review (ToolCallImpliesRead contract docs): fixed in c7fcc15. The doc now says Cedar decides tool:read itself (ToolReadNative), so the fallback does not apply to it.

@ChrisJBurns

Copy link
Copy Markdown
Collaborator

@rkb32 Thanks bud, got some lint failures in CI that we'd need to get fixed before we merge

@rkb32

rkb32 commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in c7fcc1559..2819a33ee, including 003326077, a51f0e1da, and 81cc4b24c:

  • Call-check error (1): a call_tool permit error counts as a non-match, so a read_tool permit can list the tool. A call_tool forbid error still fails closed. Tested with an argument-conditioned call permit plus a read_tool permit.
  • Conflict between items 1 and 5b: they disagree when the erroring call_tool policy is a permit. I kept item 1, because the docs example depends on it. Forbid errors still fail closed, which is the case 5b protects. Does this resolution work for you?
  • Permit-error warning: each erroring call_tool permit logs one warning per policy, with the policy ID, tool name, and error. It won't log again until the policies are reloaded.
  • Read-side error (5a): an error from a read_tool permit returns an error and hides the tool, even when a call_tool permit grants it. Intentional, so a broken read_tool policy shows up in the logs.
  • Docs (2): authz.md says a tool:call grant satisfies the read check unless a read-specific forbid applies.
  • Constant (3): authorizeToolCall uses callToolActionEntity.
  • Identity test (4): renamed, comment corrected, asserts ErrMissingPrincipal.
  • Tests (5): fail-closed cases for erroring forbids and permits; reload test covers dropping a read_tool permit and adding a read_tool forbid.
  • Native answerer (6): ToolReadNative, tool_filter.go, and ToolCallImpliesRead name Cedar as native. The admission test uses a non-native stub.
  • Tests and CI: go test passes locally for ./pkg/authz/... and ./pkg/vmcp/core/. CI on 2819a33ee is running.

@ChrisJBurns
ChrisJBurns merged commit ccca33f into stacklok:main Nov 28, 2026
43 checks passed
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.

Add a read_tool action so Cedar can grant tools/list visibility without invocation

2 participants