Skip to content

fix(deploy): grant the scanner serviceaccounts/pods read for CIS 5.1.6 - #119

Merged
rrskris merged 1 commit into
mainfrom
fix/scanner-rbac-automount-inputs
Jul 26, 2026
Merged

rrskris merged 1 commit into
mainfrom
fix/scanner-rbac-automount-inputs

Conversation

@rrskris

@rrskris rrskris commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #108, as promised in that review.

The gap

token_automount reads ServiceAccount automount settings and pod specs via list_service_account_for_all_namespaces() and list_pod_for_all_namespaces(). Both are wrapped in their own try/except ApiException — good defensive design, since it means a scanner lacking those permissions still returns the binding-based rules instead of failing the scan outright.

The consequence is that the rule fails quietly. The kaaval-scanner-reader ClusterRole in deploy/cronjob.yaml and the kaaval-scanner role documented in docs/ci-integration.md both grant only rbac.authorization.k8s.io resources, so anyone deploying as documented gets a logged warning and zero automount findings. --manifests mode was never affected.

This adds read-only get/list on core serviceaccounts and pods to both.

Also: a stale dogfooding claim

The docs said, next to that role:

(Yes — Kaaval's own scanner role is intentionally narrow enough that Kaaval would not flag it.)

That is not true, and wasn't before this PR either. Scanning deploy/cronjob.yaml:

total findings: 3
  HIGH     segmentation_violation -> kaaval-scanner-reader
  HIGH     segmentation_violation -> kaaval-policyreport-writer
  LOW      token_automount      -> kaaval-scanner

Identical before and after this change — so the two added grants introduce no new findings and the least-privilege claim genuinely holds. The segmentation_violation has been firing since #52: a namespaced ServiceAccount granted cluster scope through a ClusterRoleBinding is precisely what that rule detects, and it is unavoidable for a cluster-wide read.

Rather than delete the sentence, I replaced it with the real result and why it's expected. A scanner that trips its own rule by design, and says so, is a better advert for the rule than a claim that quietly went stale.

Verified with python -m app.cli scan rbac --manifests deploy/cronjob.yaml.

The token_automount rule added in #108 reads ServiceAccount automount
settings and pod specs. Both fetches are wrapped in their own try/except, so
a scanner without those permissions logs a warning and silently returns no
automount findings — meaning the rule shipped dark for anyone following the
documented in-cluster deployment.

Adds read-only get/list on core serviceaccounts and pods to both the
kaaval-scanner-reader ClusterRole in deploy/cronjob.yaml and the documented
kaaval-scanner role in docs/ci-integration.md.

Also corrects a stale claim next to that role. The docs asserted Kaaval
"would not flag it"; scanning deploy/cronjob.yaml shows it does, and has
since the segmentation_violation rule landed in #52 — a namespaced
ServiceAccount granted cluster scope via ClusterRoleBinding is exactly what
that rule looks for. Verified the two added grants introduce no new findings
(3 before, 3 after), so the least-privilege story holds; the parenthetical
was simply wrong. Replaced it with the actual result and why it is expected.

Signed-off-by: Vamshi Krishna Santhapuri <[email protected]>
@github-actions

Copy link
Copy Markdown

Invigil — kaaval

Gate G5 · Grade A+ · 34/35 (97%)

All five doors open and documented

Gate Check Effort Why Fix
G4 OpenSSF Scorecard >= 7 hours score 6.7 < 7 triage the Scorecard findings (branch protection, token perms, pinned deps) to reach >=7

30 passing · 1 failing · 4 skipped · report-only

@rrskris
rrskris merged commit d715623 into main Jul 26, 2026
7 checks passed
@rrskris
rrskris deleted the fix/scanner-rbac-automount-inputs branch July 26, 2026 14:48
rrskris added a commit that referenced this pull request Jul 26, 2026
Adds Unreleased entries for the five PRs merged today, following the existing
"Contributed by [@user](link) (#PR)" convention:

- #106 Trivy report ingestion adapter (@Diyaaa-12)
- #108 CIS 5.1.6 token_automount rule (@donkk11)
- #103 Helm chart skeleton (@girosole60)
- #100 severity_changed bucket in the RBAC scan diff (@floze-the-genius)
- #118 / #119 doc and scanner-RBAC corrections

Notes the doc corrections explicitly rather than folding them in silently: the
--output table had been missing sarif and junit since those shipped, api.md
never documented GET /rbac/scan/diff, and the claim that Kaaval would not flag
its own scanner role stopped being true when segmentation_violation landed.

Signed-off-by: Vamshi Krishna Santhapuri <[email protected]>
@rrskris rrskris mentioned this pull request Jul 26, 2026
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