Skip to content

Harden PATH export with sanitization to prevent empty element attacks - #12381

Merged
Mossaka merged 11 commits into
mainfrom
copilot/harden-path-setup
Jan 29, 2026
Merged

Harden PATH export with sanitization to prevent empty element attacks#12381
Mossaka merged 11 commits into
mainfrom
copilot/harden-path-setup

Conversation

CopilotAI commented Jan 28, 2026

Copy link
Copy Markdown
Contributor
  • Understand the issue: PATH export command in GetHostedToolcachePathSetup() needs sanitization
  • Create bash script actions/setup/sh/sanitize_path.sh with PATH sanitization logic
  • Create bash test script actions/setup/sh/sanitize_path_test.sh for the sanitization script
  • Refactor GetSanitizedPATHExport() to source the bash script from /opt/gh-aw/actions/sanitize_path.sh
  • Update Go tests to match new implementation
  • Run make fmt to format code
  • Run make recompile to regenerate 141 workflow lock files
  • Run make lint for validation
  • Merge main and recompile workflows

Security Summary

  • No security vulnerabilities found by CodeQL
  • The change hardens PATH handling to prevent potential attacks from malformed PATH entries (empty elements, leading/trailing colons)
Original prompt

The agent runing inside awf firewall has this command:

export PATH="$GH_AW_TOOL_BINS$(find /opt/hostedtoolcache -maxdepth 4 -type d -name bin 2>/dev/null | tr '\n' ':')$PATH"

it can be attacked.

Harden this by applying some sanitization methods like remove empty elements and trailing/leading colons etc.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Changeset

  • Type: patch
  • Description: Sanitize the AWF firewall PATH export by sourcing the new helper so empty elements and stray colons are removed before exporting.

Ahoy! This treasure was crafted by 🏴‍☠️ Changeset Generator

CopilotAIand others added 3 commits January 28, 2026 22:39
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
…ding/trailing colons
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
CopilotAI changed the title [WIP] Harden PATH variable setup in agent commandHarden PATH export with sanitization to prevent empty element attacksJan 28, 2026
CopilotAI requested a review from MossakaJanuary 28, 2026 23:12
@Mossaka

Copy link
Copy Markdown
Contributor

@copilot refactor it to a bash script and reference it

Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>

CopilotAI commented Jan 28, 2026

Copy link
Copy Markdown
ContributorAuthor

@copilot refactor it to a bash script and reference it

Refactored the PATH sanitization logic to a bash script in actions/setup/sh/sanitize_path.sh with corresponding tests in sanitize_path_test.sh. The Go code now sources the script via source /opt/gh-aw/actions/sanitize_path.sh. Commit: 85c4bb3

@Mossaka
Mossaka marked this pull request as ready for review January 28, 2026 23:41
@github-actions

Copy link
Copy Markdown
Contributor

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions

github-actionsBot commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions

github-actionsBot commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰

@github-actions

github-actionsBot commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

🎬 THE ENDSmoke ClaudeMISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results

PRs Retrieved:

Test Status:

  • ✅ GitHub MCP
  • ✅ Safe Inputs GH CLI
  • ✅ Serena MCP
  • ✅ Playwright
  • ✅ File Writing
  • ✅ Bash Tool
  • ✅ Discussion Interaction
  • ✅ Build gh-aw

Overall: ✅ PASS

cc @Mossaka

AI generated by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude - PASS ✅

PRs Reviewed:

Test Results: ✅ GitHub MCP | ✅ GH CLI | ✅ Serena | ✅ Make | ✅ Playwright | ✅ Tavily | ✅ File Ops | ✅ Bash | ✅ Discussion

Status: PASS

AI generated by Smoke Claude

@github-actions

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions

Copy link
Copy Markdown
Contributor

GitHub MCP merged PRs ✅: docs: Document agent container build/test environment from epic #11970; Add canary_go job to agent-ci.yml to detect untested Go functions
safeinputs gh PRs ✅: [WIP] Add security documentation for container mounting risks; Create smoke test workflow to validate common development tool availability
Serena activate ✅; Playwright title ✅; Tavily search ✅
File write ✅; Bash cat ✅
Discussion comment ✅; Build ✅
Overall: PASS

AI generated by Smoke Codex

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot merge main, recompile

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

CopilotAI commented Jan 29, 2026

Copy link
Copy Markdown
ContributorAuthor

@copilot merge main, recompile

Merged main and recompiled all 141 workflows. Commit: 57432ea

@Mossaka
Mossaka merged commit d3e279a into mainJan 29, 2026
49 checks passed
@Mossaka
Mossaka deleted the copilot/harden-path-setup branch January 29, 2026 01:38
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Mossaka@pelikhan