Skip to content

[ACTP] Fix PAR self_enroll Secret RBAC promoted to cluster-wide scope#2781

Open
merchristK wants to merge 3 commits intomainfrom
merchristk-fix-par-self-enroll-secret-rbac-scope
Open

[ACTP] Fix PAR self_enroll Secret RBAC promoted to cluster-wide scope#2781
merchristK wants to merge 3 commits intomainfrom
merchristk-fix-par-self-enroll-secret-rbac-scope

Conversation

@merchristK
Copy link
Contributor

@merchristK merchristK commented Mar 19, 2026

What does this PR do?

Restores the self_enroll identity-secret RBAC rules for the Private Action Runner to a namespaced Role, undoing an unintended privilege escalation introduced in #2770.

Motivation

See https://github.com/DataDog/datadog-operator/pull/2780/changes#r2959203865

Minimum Agent Versions

N/A — operator-only change.

Describe your test plan

  • Deployed the operator in a local cluster and checked the roles
# Build the operator image
make IMG=test/operator:dev docker-build
# Install CRDs
make install
# Deploy the operator
make IMG=test/operator:dev deploy

kubectx docker-desktop

kubectl apply -k ./bin/manifests
kubectl get clusterrole datadog-private-action-runner -o yaml
kubectl get role datadog-private-action-runner -o yaml

When k8s remediation was added in #2770, the self_enroll identity-secret
rules were merged into the same AddClusterPolicyRulesByComponent call as
the remediation rules. This silently promoted the Secret get/update/create
permission from a namespaced Role to a ClusterRole, letting the cluster
agent ServiceAccount access any Secret matching the identity secret name
in every namespace.

Restore the self_enroll rules to AddPolicyRulesByComponent (namespaced
Role) and keep only the k8s remediation rules in AddClusterPolicyRulesByComponent,
which legitimately requires cluster-wide workload access.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@codecov-commenter
Copy link

codecov-commenter commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.76%. Comparing base (40e907c) to head (5e94f6d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...atadogagent/feature/privateactionrunner/feature.go 70.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2781      +/-   ##
==========================================
- Coverage   38.78%   38.76%   -0.02%     
==========================================
  Files         309      309              
  Lines       26839    26844       +5     
==========================================
- Hits        10409    10406       -3     
- Misses      15650    15658       +8     
  Partials      780      780              
Flag Coverage Δ
unittests 38.76% <70.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...r/datadogagent/feature/privateactionrunner/rbac.go 25.71% <ø> (ø)
...atadogagent/feature/privateactionrunner/feature.go 72.94% <70.00%> (-4.03%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40e907c...5e94f6d. Read the comment docs.

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

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@merchristK merchristK added this to the v1.25.0 milestone Mar 19, 2026
@merchristK merchristK marked this pull request as ready for review March 19, 2026 16:37
@merchristK merchristK requested a review from a team March 19, 2026 16:37
@merchristK merchristK requested a review from a team as a code owner March 19, 2026 16:37
@merchristK merchristK requested a review from ihssane-yb March 19, 2026 16:37
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c45086c32

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@tbavelier tbavelier added bug Something isn't working and removed qa/skip-qa labels Mar 19, 2026
if len(clusterAgentPolicyRules) > 0 {
err := managers.RBACManager().AddClusterPolicyRulesByComponent(
// This creates a ClusterRole with cluster-wide access to workload resources for k8s remediation.
err := managers.RBACManager().AddClusterPolicyRules(

Choose a reason for hiding this comment

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

what is the difference between AddClusterPolicyRulesByComponent and AddClusterPolicyRules ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

First one add a ClusterRole (not namespaced) and second one adds a Role (which is namespaced)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants