Skip to content

Harden setup scripts against symlink traversal - #77552

Merged
pelikhan merged 4 commits into
mainfrom
copilot/uk-ai-resilience-uk-ai-governance-harden-symlink-h
Nov 14, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/uk-ai-resilience-uk-ai-governance-harden-symlink-h

Conversation

Copilot AI commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • Guard file access: Reject symlinked path components and outputs across the affected scripts in /home/runner/work/gh-aw/gh-aw/actions/setup/sh/.
  • Stage writes safely: Write patch and copied-binary files to private temporary files, then rename into place. Append summaries through descriptor-relative, no-follow access.
  • Protect installer outputs: Validate installation and staging directories, and reject symlinked GITHUB_OUTPUT targets in /home/runner/work/gh-aw/gh-aw/install-gh-aw.sh and its synchronized action copy.
  • Review focus: Patch generation and usage-artifact collection changed and require human review.
if [ -L "$target" ]; then
  echo "Refusing to replace a symlinked patch file" >&2
  return 1
fi
staged="$(mktemp "${PATCH_DIR}/.aw-patch.XXXXXX")"
git format-patch "$revision_range" --stdout > "$staged"
mv -f -- "$staged" "$target"

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Harden symlink handling in actions/setup/sh scripts Harden setup scripts against symlink traversal Nov 13, 2026
Copilot AI requested a review from gh-aw-bot November 13, 2026 21:26
@pelikhan
pelikhan marked this pull request as ready for review November 13, 2026 22:32
Copilot AI adaptive review requested due to automatic review settings November 13, 2026 22:32
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

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.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.2K · ◷

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

❌ PR Specification Reviewer failed to deliver outputs. Please review the logs for details.

PR Specification Reviewer

Outcome: reported_action

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.

Generated by PR Specification Reviewer for #77552 · copilot · gpt56 · ~4 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ PR Code Quality Reviewer failed to deliver outputs during code quality review.

PR Code Quality Reviewer

Outcome: reported_action

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.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt56 · ~3 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.5K · ◷

@github-actions

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer is reviewing this pull request using Matt Pocock's engineering skills...

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ 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: reported_no_action

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.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: sonnet55 high · ~5 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 8.6K · ◷

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

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.

Generated by Ponytail Reviewer for #77552 · codex · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 182 · ◷

@github-actions github-actions Bot left a comment

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.

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

Comment thread install-gh-aw.sh Outdated
print_info "Installation directory: $INSTALL_DIR"

# Create the installation directory if it doesn't exist
if [ -L "$INSTALL_DIR" ]; then

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copilot AI left a comment

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.

🟡 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
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
Comment on lines +48 to +49
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
Comment thread install-gh-aw.sh
Comment on lines +95 to +99
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}"
Comment thread install-gh-aw.sh Outdated
Comment on lines +498 to +501
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);
Comment on lines +52 to +55
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"
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (install-gh-aw.sh:498): address unresolved feedback - Review comment
  3. Review (actions/setup/sh/copy_gh_aw_binary_for_mcp.sh:8): address unresolved feedback - Review comment
  4. Fix failing check conclusion (FAILURE): Check run.
  5. Fix failing check safe_outputs (FAILURE): Check run.
  6. Fix failing check safe_outputs (FAILURE): Check run.

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"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~4 AIC · ⌖ ~2 AIC · ⊞ 6.9K · ◷
Comment /souschef to run again

gh-aw-bot and others added 2 commits November 13, 2026 23:26
…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>
@pelikhan
pelikhan merged commit 36b0d8d into main Nov 14, 2026
90 checks passed
@pelikhan
pelikhan deleted the copilot/uk-ai-resilience-uk-ai-governance-harden-symlink-h branch November 14, 2026 05:54
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.3.0

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[uk-ai-resilience] [uk-ai-governance] Tier C: harden symlink handling (CWE-59) in actions/setup/sh scripts

4 participants