feat(builtins)!: add a Kubernetes SubjectAccessReview PDP #389
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.75) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #389"
general
weight: 0.35
guicassolato
Closes #214.
This adds
kubernetes-sar, a decision point that defers an access decision to the Kubernetes API server. Apdp(kubernetes-sar):step sends a SubjectAccessReview describing the caller and the action, and allows only when the cluster's authorizer chain (RBAC, Node, or a webhook) allows. Paired withidentity/kubernetes-token-review, an operator can grant agents access to tools with ordinary RBAC objects.No PDP could make an HTTP call before this.
PdpFactorylived inpraxis-policy-apl-core, which does not depend onpraxis-policy-coreand so cannot name the host's transport. The first commit fixes that by movingPdpFactoryto the runtime and passing it the host services; the second adds the PDP.Configuration
Both review shapes from the issue are supported:
resource_attributes("may the subjectverbthis object?") andnon_resource_attributes("may the subjectverbthis path?"). A step sets exactly one. Every field, including the subject'suser,groups,uidandextra, is a CEL expression over the attribute bag, using thecelPDP's bag mapping, so a SAR step reads the same names acel:step does. Only the values the expressions produce are sent; tool arguments stay in PPE unless an expression names one.userdefaults tosubject.idandgroupstosubject.roles; theglobal.pdpblock can change the defaults and a step can override them.The API server connection and reviewer token are the same block
identity/kubernetes-token-reviewuses. Both now live in a crate-private module that the TokenReview plugin re-exports, so its public paths are unchanged. The reviewer token's identity needscreateonsubjectaccessreviews;system:auth-delegatorgrants it withtokenreviews.Behaviour
| Situation | Decision |
|---|---|
| An authorizer allows | Allow |
| An authorizer denies, or none has an opinion | Deny, as the API server itself does |
| An expression fails, yields the wrong type, or
useris empty | Deny, without calling the API server, whateveron_errorsays || The groups include
system:masters| Deny, without calling the API server || The API server is unreachable, refuses the reviewer credential (401, 403), answers non-2xx, or answers something that is not a review |
on_error,denyby default |reasonandevaluationErrorfrom the answer go to the decision's diagnostics, not the client-facing denial. Expression failures deny unconditionally because they mean the policy could not say who or what to review;on_error: allowis for an authorizer that is down, not for a broken policy.system:mastersis the one group the API server lets skip authorization, and the review takes PPE's groups on trust. No ServiceAccount token carries it, so a review naming it has groups from somewhere else. It is a single hardcoded name, not a list: every other group's effect is visible in the cluster's own bindings.The default
groupsis right for a TokenReview identity, whose groups are the cluster's own answer. For a JWT or API key identity the roles are names an identity provider chose, and the cluster would match them against its bindings as if they were Kubernetes groups. The docs say to setgroupsexplicitly in that case, to[]or with anoidc:prefix the way the API server's--oidc-groups-prefixdoes. Making the default depend on where the identity came from needs the subject's attestor in the bag, which it is not today; that is a follow-up issue (link once filed).Host transport
PdpFactory::buildnow takes&PdpHostServices, a non-exhaustive struct whosehttpfield is the transport the host installed withset_http_transport, read through a newPolicyEngine::http_transport(). Cedar, CEL and OPA ignore it.kubernetes-sarfails the config load without one, with a message saying to callset_http_transportfirst. The transport is taken when theglobal.pdpentry is built, so the host sets it beforeload_config_yaml; Praxis already does. TLS trust for the API server is the transport's, as for TokenReview.PDPs have no
perform_httpcapability. Capabilities limit what plugin code can reach from a request; a PDP is compiled in by the host and configured only inglobal.pdp, so declaringkind: kubernetes-saris the operator's opt in, as for the Vault secret provider. The API server URL is static config, so request data cannot steer where the review goes.Differential harness
The facade test from #25 requires every builtin PDP to be in the Cedar/CEL/OPA differential harness.
kubernetes-sarholds no policy of its own to express in the other dialects, so the test now exempts it by name, and the builtins reference says so.Breaking changes
PdpFactorymoves frompraxis_policy_apl_core::steptopraxis_policy_apl_runtime, andbuildtakes a second argument,&PdpHostServices. Out-of-tree implementors update the import and add the argument. Thepraxis_policy::PdpFactoryfacade path is unchanged.cedar,celandopabuiltin features now compilepraxis-policy-apl-runtime, and so need a crypto backend selected, like every other engine-backed feature. Abuiltinsbuild with onlyceland no backend used to compile and no longer does.kind: kubernetes-sarmust callset_http_transportbeforeload_config_yaml. Nothing changes for a policy without one.Testing
evaluationErrorbeside allowed, malformed bodies, and the request JSON omitting unset fields.extra;on_errorboth ways on 503 and 403; no subject andsystem:masterseach denying without a call underon_error: allow; and load failures for both shapes set, invalid CEL, an unknown key, and a missing transport.make check,make lint,make doc, and a FIPS build withcedar,cel,opaandkubernetes-sarpass.Not tested against a live API server. The answer shapes (201 for every outcome,
allowedanddeniedomitted when false, both absent for no opinion) match what TokenReview showed on kind and the API documentation, but this PR has no SAR fixtures captured from a real cluster.Not done: a review cache keyed on the evaluated review. The generic
cache:option on aglobal.pdpentry works but keys on the whole bag, so it rarely hits; while an answer is cached, an RBAC change waits out its TTL. Thecelcrate's string extensions, such assplit(), are not available, the same as incel:steps.<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Added Kubernetes authorization checks for resource and non-resource requests, with configurable subject and attribute mapping and fallback behavior when the API server does not respond.
Added shared Kubernetes API-server and reviewer-token configuration, and support for using the host’s HTTP transport.
Decision caches now store only results marked cacheable; Kubernetes outage-fallback allows are not cached.
Added OPA-enabled builtins to applicable Makefile targets.
Breaking Changes
Custom policy decision point factories must accept host services. Cedar, CEL, and OPA builtin features require a crypto backend.
Documentation
* Added Kubernetes authorization configuration and usage guidance, including caching behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->