Skip to content

Backport #48127 and #48236 #48484

Closed
AlexandreYang wants to merge 3 commits into7.78.xfrom
alex/backport-48462-to-7.78.x-v2
Closed

Backport #48127 and #48236 #48484
AlexandreYang wants to merge 3 commits into7.78.xfrom
alex/backport-48462-to-7.78.x-v2

Conversation

@AlexandreYang
Copy link
Copy Markdown
Member

@AlexandreYang AlexandreYang commented Mar 27, 2026

Backport:

#48127
#48462

Motivation:

Need to start pentest for the Restricted Shell feature.

The backport is low risk since those PAR action are behind FF.

AlexandreYang and others added 2 commits March 27, 2026 12:54
<!-- dd-meta {"pullId":"c2960337-1304-4d38-b522-5285faa7a280","source":"chat","resourceId":"e1770736-c3aa-4752-a8c6-77212765f0c7","workflowId":"a58e22a0-26bb-4586-bcd6-bd4c67edd5e1","codeChangeId":"a58e22a0-26bb-4586-bcd6-bd4c67edd5e1","sourceType":"slack"} -->

Add restricted shell allowed path config

The rshell runner currently hardcodes allowed paths (`/var/log`) in code, which makes policy changes require code changes and deploys. This change moves path policy into configuration so operators can manage rshell filesystem access through `datadog.yaml` and environment variables.

- `go test ./pkg/privateactionrunner/bundles/remoteaction/rshell`
- `go test -tags test ./pkg/config/setup -run 'TestPrivateActionRunner|TestRestrictedShell'`
- `go test -tags test ./pkg/privateactionrunner/adapters/config -run 'TestFromDDConfig|TestFromDDConfigRestrictedShellAllowedPaths'`
- `Format` tool run (goimports/gofmt on changed Go files)
- `Lint` tool run (golangci-lint execution attempted, but failed due to local toolchain mismatch: golangci-lint built with go1.24 while repo targets go1.25.7)

This preserves existing rshell default behavior by defaulting `restricted_shell.allowed_paths` to `/var/log`.

---

PR by Bits - [View session in Datadog](https://app.datadoghq.com/code/e1770736-c3aa-4752-a8c6-77212765f0c7)

Comment @DataDog to request changes

Co-authored-by: datadog-datadog-prod-us1[bot] <88084959+datadog-datadog-prod-us1[bot]@users.noreply.github.com>
Co-authored-by: alexandre.yang <alexandre.yang@datadoghq.com>
…efixing (#48236)

## Summary
- Add `/proc` and `/etc/os-release` to the default allowed paths for the PAR restricted shell
- Automatically prepend `/host` to all default paths when running in a containerized environment (detected via `env.IsContainerized()`)
- Paths remain user-overridable via config or `DD_PRIVATE_ACTION_RUNNER_RESTRICTED_SHELL_ALLOWED_PATHS`

## Test plan
- [ ] Verify default paths are `/var/log`, `/proc`, `/etc/os-release` on bare metal
- [ ] Verify default paths are `/host/var/log`, `/host/proc`, `/host/etc/os-release` in a containerized environment
- [ ] Verify env var override still works as expected

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: matthew.deguzman <matthew.deguzman@datadoghq.com>
@AlexandreYang AlexandreYang marked this pull request as ready for review March 27, 2026 12:02
@AlexandreYang AlexandreYang requested a review from a team as a code owner March 27, 2026 12:02
@AlexandreYang AlexandreYang requested review from ihssane-yb and removed request for a team March 27, 2026 12:02
@dd-octo-sts dd-octo-sts Bot added internal Identify a non-fork PR team/action-platform labels Mar 27, 2026
@github-actions github-actions Bot added the medium review PR review might take time label Mar 27, 2026
Copy link
Copy Markdown

@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: d3757cabb7

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


// NewRshellBundle creates the rshell bundle with its registered actions.
func NewRshellBundle() types.Bundle {
func NewRshellBundle(allowedPaths []string) types.Bundle {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Update non-kubeapiserver registry for new rshell signature

Changing NewRshellBundle to require allowedPaths breaks the !kubeapiserver registry path because pkg/privateactionrunner/bundles/registry.go still calls NewRshellBundle() with no arguments. This backport updates only registry_kubeapiserver.go, so builds that compile the non-kubeapiserver registry will fail until that call site also passes configuration.RShellAllowedPaths (or another explicit argument).

Useful? React with 👍 / 👎.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you need to update registry.go as well with the new allowed paths

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@merchristK you mean this? 4ae288b

just made the fix

@AlexandreYang AlexandreYang added the changelog/no-changelog No changelog entry needed label Mar 27, 2026
Copy link
Copy Markdown

@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: 4ae288b8e2

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

Comment thread pkg/config/setup/privateactionrunner.go
@agent-platform-auto-pr
Copy link
Copy Markdown
Contributor

Files inventory check summary

File checks results against ancestor 183e910c:

Results for datadog-agent_7.78.0~rc.3.git.11.4ae288b.pipeline.104740304-1_amd64.deb:

No change detected

@AlexandreYang AlexandreYang deleted the alex/backport-48462-to-7.78.x-v2 branch March 27, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog No changelog entry needed internal Identify a non-fork PR medium review PR review might take time team/action-platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants