Repository navigation
Harden setup scripts against symlink traversal - #77552
Conversation
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
❌ PR Specification Reviewer failed to deliver outputs. Please review the logs for details. PR Specification ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
PR Code Quality ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer is reviewing this pull request using Matt Pocock's engineering skills... |
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
There was a problem hiding this comment.
Found two blocking path-validation gaps in the new symlink hardening: both the MCP output path and installer path validate only the final directory component, so symlinked ancestors can still redirect writes. See inline comments. Static review only; the delegated specialist pass was unavailable because its diff-read tool invocation was denied.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.5K
Comment /review to run again
| print_info "Installation directory: $INSTALL_DIR" | ||
|
|
||
| # Create the installation directory if it doesn't exist | ||
| if [ -L "$INSTALL_DIR" ]; then |
There was a problem hiding this comment.
This validation only checks whether the final INSTALL_DIR component is a symlink. A symlink in $HOME, .local, or share is still followed by mkdir -p, mktemp, and subsequent writes, so a controlled installation path can redirect the installer outside the intended tree. Please validate all path components (and the staged output path) consistently with the other hardened paths.
There was a problem hiding this comment.
Addressed in 0c09c8a: the installer now validates and creates each installation path component below $HOME individually, rejects symlinked ancestors, and the fixture covers a linked extensions parent.
| # Copy the gh-aw binary to ${RUNNER_TEMP}/gh-aw for MCP Server containerization | ||
| mkdir -p "${RUNNER_TEMP}/gh-aw" | ||
| OUTPUT_DIR="${RUNNER_TEMP}/gh-aw" | ||
| if [ -L "$OUTPUT_DIR" ]; then |
There was a problem hiding this comment.
The new check only rejects OUTPUT_DIR itself when it is a symlink, but it does not validate any parent component such as RUNNER_TEMP. If RUNNER_TEMP (or an ancestor) is a symlink, mkdir, mktemp, and the final mv still write through that link into an external directory. This leaves the output-path traversal the change is intended to prevent; validate every component (or use descriptor-relative no-follow access) before creating/staging the binary.
There was a problem hiding this comment.
Addressed in 0c09c8a: output directory setup now walks and validates every path component before creating it, and the binary test covers a symlinked RUNNER_TEMP parent.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical symlink and race-condition flaws can expose data outside the collection tree and redirect writes to unintended files.
12 open issues
Output checks miss symlinked parents and leave a replacement window · New Rejected usage symlinks remain available to downstream consumers · New Source symlinks can be swapped before usage files are copied · New safe_copy breaks workflow tests and failure injection · New Agent metadata can overwrite trusted runtime attribution · New Cache path guard rejects compiler-created symlink aliases · New Reopening temporary paths permits symlink-based truncation · New Symlinked parent directories bypass output-path checks · New Symlinked installation parents can redirect binary replacement · New Blocking open can hang if destination is replaced with a FIFO · New Path guard rejects the supported Windows WSL alias · New Directory destination lets audit publication succeed incorrectly · New
What changed in this PR
This PR adds symlink defenses to gh-aw’s setup scripts and installers, covering workflow artifacts, summaries, binaries, audit files, and cache metadata.
Changes:
- Add path checks and temporary-file staging around setup-script reads and writes.
- Introduce descriptor-relative guarded summary appends.
- Expand regression coverage and register additional shell tests.
| File | Description |
|---|---|
scripts/test-install-script.sh |
Tests symlinked installer output rejection. |
Makefile |
Registers additional setup-script tests. |
install-gh-aw.sh |
Adds installer directory and output guards. |
actions/setup/sh/generate_git_patch.sh |
Adds patch-path checks and staged writes. |
actions/setup/sh/generate_git_patch_test.sh |
Tests patch and summary symlink rejection. |
actions/setup/sh/copy_gh_aw_binary_for_mcp.sh |
Guards binary destinations and stages copies. |
actions/setup/sh/copy_gh_aw_binary_for_mcp_test.sh |
Tests symlinked binary outputs and directories. |
actions/setup/sh/commit_cache_memory_git.sh |
Checks cache-root components before git operations. |
actions/setup/sh/commit_cache_memory_git_test.sh |
Tests symlinked cache-root rejection. |
actions/setup/sh/collect_usage_artifact_files.sh |
Guards usage copies and adds agent metadata collection. |
actions/setup/sh/collect_usage_artifact_files_test.sh |
Tests symlinked usage sources and destinations. |
actions/setup/sh/audit_pre_agent_workspace.sh |
Guards audit outputs and stages audit publication. |
actions/setup/sh/audit_pre_agent_workspace_test.sh |
Tests symlinked GitHub output rejection. |
actions/setup/sh/append_agent_step_summary.sh |
Checks the deployed summary script before execution. |
actions/setup/js/symlink_guard.test.cjs |
Tests guarded appends and symlink rejection. |
actions/setup/js/symlink_guard.cjs |
Adds descriptor-relative guarded file appends. |
actions/setup/js/append_agent_step_summary.test.cjs |
Tests destination and deployed-script symlinks. |
actions/setup/js/append_agent_step_summary.cjs |
Publishes summaries through guarded append access. |
actions/setup-cli/install.sh |
Mirrors the standalone installer hardening. |
Review effort: Max (dynamic)
| echo "::error::gh-aw temporary path is not a real directory" >&2 | ||
| exit 1 | ||
| fi | ||
| if [ -L "$AUDIT_FILE" ] || [ -L "${GITHUB_OUTPUT}" ] || { [ -n "${GITHUB_STEP_SUMMARY:-}" ] && [ -L "${GITHUB_STEP_SUMMARY}" ]; }; then |
| if [ ! -d "$destination_dir" ] || path_has_symlink_component "$destination_dir" || [ -L "$destination" ]; then | ||
| return 1 |
| return 1 | ||
| fi | ||
| staged_file="$(mktemp "${destination_dir}/.usage-copy.XXXXXX")" || return 1 | ||
| if ! cp -- "$source" "$staged_file"; then |
| if [ -f /tmp/gh-aw/aw-info.jsonl ]; then cp /tmp/gh-aw/aw-info.jsonl /tmp/gh-aw/usage/aw-info.jsonl || true; fi | ||
| if [ -f /tmp/gh-aw/agent_usage.json ]; then cp /tmp/gh-aw/agent_usage.json /tmp/gh-aw/usage/agent_usage.json || true; fi | ||
| if [ -f /tmp/gh-aw/agent_usage.jsonl ]; then cp /tmp/gh-aw/agent_usage.jsonl /tmp/gh-aw/usage/agent_usage.jsonl || true; fi | ||
| if [ -f /tmp/gh-aw/aw_info.json ]; then safe_copy /tmp/gh-aw/aw_info.json /tmp/gh-aw/usage/aw_info.json || true; fi |
| if [ -f /tmp/gh-aw/agent_usage.jsonl ]; then cp /tmp/gh-aw/agent_usage.jsonl /tmp/gh-aw/usage/agent_usage.jsonl || true; fi | ||
| if [ -f /tmp/gh-aw/aw_info.json ]; then safe_copy /tmp/gh-aw/aw_info.json /tmp/gh-aw/usage/aw_info.json || true; fi | ||
| if [ -f /tmp/gh-aw/runtime/aw_info.json ]; then safe_copy /tmp/gh-aw/runtime/aw_info.json /tmp/gh-aw/usage/aw_info.json || true; fi | ||
| if [ -f /tmp/gh-aw/agent/aw_info.json ]; then safe_copy /tmp/gh-aw/agent/aw_info.json /tmp/gh-aw/usage/aw_info.json || true; fi |
| if [ -L "${GITHUB_OUTPUT:-}" ]; then | ||
| print_error "Refusing to append to a symlinked GITHUB_OUTPUT file." | ||
| return 1 | ||
| fi | ||
| printf '%s\n' "$value" >> "${GITHUB_OUTPUT}" |
| if [ -L "$INSTALL_DIR" ]; then | ||
| print_error "Cannot install gh-aw: '$INSTALL_DIR' is a symlink." | ||
| exit 1 | ||
| fi |
| expected = null; | ||
| } | ||
| if (expected && (!expected.isFile() || expected.nlink !== 1)) throw assetValidationError("Asset must be an isolated regular file"); | ||
| const fd = fs.openSync(target, fs.constants.O_WRONLY | fs.constants.O_APPEND | fs.constants.O_CREAT | fs.constants.O_NOFOLLOW, 0o600); |
| if [ -L /tmp/gh-aw ]; then | ||
| echo "::error::Refusing to use a symlinked gh-aw temporary directory" >&2 | ||
| exit 1 | ||
| fi |
| echo "::error::Refusing to replace a symlinked audit file" >&2 | ||
| exit 1 | ||
| fi | ||
| mv -f -- "$AUDIT_TMP" "$AUDIT_FILE" |
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "f98be3df5ff9645a226421b4ebcff596daeb497b",
"kind": "requested",
"schema_version": "1",
"state": "9a4a98d75357467236403e638be37a7c62d5e5566d4a756a6f2a504c70b6c7e5",
"work": [
"51e2287c3d1ee41b7e13769862add61dcd292a623cf943abc5968c984e246bcf",
"9f81802f5ea4a907e1c414d3d7af16f91f94a494a01ba0add58f2ecf7532eb3a",
"c7cf93e497befdd5e698d00101b0703e4101fe4133d86d433f7c170d07402b7e",
"da0db659c770c7f98c0452086b5397ff2ab0601c1df4855e1f30139aa05ef7b3"
],
"workflow": "pr-sous-chef"
}
|
…nce-uk-ai-governance-harden-symlink-h Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
|
🎉 This pull request is included in a new release. Release: |


Setup scripts could follow symlinks when reading inputs or writing patches, usage artifacts, summaries, binaries, audit files, and cache metadata. Harden these paths and the related installer, while preserving existing behavior for regular files.
/home/runner/work/gh-aw/gh-aw/actions/setup/sh/.GITHUB_OUTPUTtargets in/home/runner/work/gh-aw/gh-aw/install-gh-aw.shand its synchronized action copy.