feat(interventions): add cedar vended intervention handler#2365
feat(interventions): add cedar vended intervention handler#2365lizradway wants to merge 14 commits into
Conversation
|
Assessment: Comment Well-structured Cedar authorization handler that follows existing vended-intervention patterns. The fail-closed security design, real Cedar evaluation in tests, and comprehensive coverage of authorization scenarios are strong. Review Themes
Good first vended intervention — the core authorization logic is clean and the test suite covers the important authorization scenarios thoroughly. |
|
Assessment: Comment The Cedar authorization handler is well-implemented with a fail-closed security design and thorough test coverage using real Cedar policy evaluation. Review Themes
Solid implementation overall — the core authorization logic, TSDoc, and test scenarios are comprehensive. |
| const invocationState = event.invocationState as Record<string, CedarValueJson> | ||
| const principal = this._principalResolver(invocationState) | ||
| if (!principal) { | ||
| return deny('No principal identity found in invocation state') |
There was a problem hiding this comment.
do I have to pass it in invocation state, can't i pass it in original config? Is this something we expect to change with each invocation?
There was a problem hiding this comment.
similarly should the principal resolver be required?
There was a problem hiding this comment.
do I have to pass it in invocation state, can't i pass it in original config? Is this something we expect to change with each invocation?
this is expected to change for any multi-tenant deployed solution. but i think it makes sense to be able to pass this into the config for the cli case, can add a fall through to config if user is not in invocation state.
similarly should the principal resolver be required?
added static principal identity override option to config, so the resolver is no longer required.
🔴 Two security findings in the rate-limit / environment handlingGreat PR overall — the core Cedar evaluation is solid (default-deny, forbid-wins, fail-closed on missing principal, atomic The root cause of #1 is also a correctness/accuracy problem with 🔴 #1 — Rate-limit bypass via session-map eviction (HIGH)
private _incrementCallCount(sessionId: string, toolName: string): number {
let session = this._callCounts.get(sessionId)
if (!session) {
if (this._callCounts.size >= this._maxSessions) {
const oldest = this._callCounts.keys().next().value! // evict oldest-inserted
this._callCounts.delete(oldest)
}
session = new Map()
this._callCounts.set(sessionId, session)
}
const next = (session.get(toolName) ?? 0) + 1
session.set(toolName, next)
return next
}The const sessionId = (invocationState.session_id as string | undefined) ?? '_default'Attack: against a policy like Observed (real cedar-wasm eval): Control (no flood) stays denied on the 4th call, confirming eviction is the cause. Fix options: evict on a key that isn't attacker-controllable, or use a real LRU keyed on identity, or a persistent/shared store — or, if 🔴 #7 —
|
Description
Adds a
CedarAuthorizationintervention handler that evaluates Cedar authorization policies at the tool-call boundary, providing identity-aware access control for agent tool invocations.The handler integrates with
@cedar-policy/cedar-wasm(optional peer dependency) to evaluate Cedar policies before each tool call, returningdeny()orproceed()based on the policy decision.Follows the cedar-for-agents schema generator conventions:
Action::"search")resourceResolverfor domain-specific entities){ input: <tool args>, session: { hour_utc, call_count, environment } }Cedar-to-tool mapping
invocationState(viaprincipalResolver)User::"alice@acme.com"Action::"search"resourceResolverResource::"agent"orRecord::"42"{ query: "report" }{ hour_utc: 14, call_count: 3 }Key features
.cedarfilehour_utc,call_count,environmentin session context, plus custom enricher callbackonError: 'throw' | 'deny' | 'proceed'Usage
Related Issues
Documentation PR
N/A
Type of Change
New feature
Testing
How have you tested the change?
npm run checkfor TypeScript (type-check, tests, lint)examples/cedar/) tested end-to-end with 5 scenariosChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.