Skip to content

fix(security): restrict !exec YAML function with command allowlist and env sanitization#2276

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/fix-yaml-exec-command-injection
Draft

fix(security): restrict !exec YAML function with command allowlist and env sanitization#2276
Copilot wants to merge 6 commits intomainfrom
copilot/fix-yaml-exec-command-injection

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

  • Investigate failing PR checks (pre-commit/go-fumpt, Acceptance Tests linux/macos)
  • Fix go-fumpt alignment issue in yaml_func_exec_test.go (line 407 comment spacing: nil, //nil, //)
  • Update golden snapshot TestCLICommands_atmos_describe_config.stdout.golden to include new "exec": {} field
  • Update golden snapshot TestCLICommands_secrets-masking_describe_config.stdout.golden to include new "exec": {} field
  • Verified all security tests still pass after formatting fix
  • gofumpt passes cleanly on the test file

Copilot AI and others added 4 commits April 1, 2026 13:24
…nitization

- Add ExecConfig struct to AtmosConfiguration with AllowedCommands allowlist
- Strip credential-bearing env vars (tokens, secrets, passwords, API keys) from !exec environment
- Validate all shell command names against allowlist when exec.allowed_commands is configured
- Thread AtmosConfiguration into ProcessTagExec; config-load path passes nil (no allowlist)
- Stack-processing path (yaml_func_utils.go) passes full atmosConfig for enforcement
- Add tests for allowlist enforcement, pipe blocking, env sanitization

Agent-Logs-Url: https://github.com/cloudposse/atmos/sessions/4b8b3a24-2205-4fcf-9cf5-a281dfbe5523

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
…nsitiveEnvVar

Agent-Logs-Url: https://github.com/cloudposse/atmos/sessions/4b8b3a24-2205-4fcf-9cf5-a281dfbe5523

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Copilot AI requested a review from nitrocode April 1, 2026 15:49
@mergify mergify bot added the triage Needs triage label Apr 1, 2026
@nitrocode nitrocode added patch A minor, backward compatible change and removed triage Needs triage labels Apr 1, 2026
@github-actions github-actions bot added the size/m Medium size PR label Apr 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Dependency Review

✅ No vulnerabilities or license issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 3fd6926.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

…r exec field

Agent-Logs-Url: https://github.com/cloudposse/atmos/sessions/ac5477dd-98e8-428e-9818-be96ba3affcf

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.18%. Comparing base (39a9be1) to head (3fd6926).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2276      +/-   ##
==========================================
+ Coverage   77.16%   77.18%   +0.02%     
==========================================
  Files        1034     1034              
  Lines       97576    97623      +47     
==========================================
+ Hits        75296    75355      +59     
+ Misses      18073    18061      -12     
  Partials     4207     4207              
Flag Coverage Δ
unittests 77.18% <100.00%> (+0.02%) ⬆️

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

Files with missing lines Coverage Δ
internal/exec/yaml_func_utils.go 94.23% <100.00%> (ø)
pkg/config/process_yaml.go 70.04% <100.00%> (ø)
pkg/schema/schema.go 87.70% <ø> (ø)
pkg/utils/shell_utils.go 87.14% <100.00%> (+4.12%) ⬆️
pkg/utils/yaml_func_exec.go 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

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

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

Labels

patch A minor, backward compatible change size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants