Skip to content

fix: add -n to ln -sf in install.sh to prevent symlink TOCTOU (PILOT-271)#190

Open
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-271-20260530-041730
Open

fix: add -n to ln -sf in install.sh to prevent symlink TOCTOU (PILOT-271)#190
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-271-20260530-041730

Conversation

@matthew-pilot
Copy link
Copy Markdown
Collaborator

What

Adds -n (--no-dereference) flag to all ln -sf calls in the install.sh symlink section.

Why

The writable-check then ln -sf in install.sh:342-349 is non-atomic (TOCTOU). Without -n, if an attacker races between the check and the ln call to replace a destination path with a symlink to a directory, ln would follow it and create the link inside that directory instead of at the intended location.

ln -sfn treats the destination as a non-directory, preventing symlink dereference.

Change

  • 1 file, +4/-4 — added n to each ln -sfln -sfn

Verification

  • bash -n install.sh — syntax OK
  • go build ./... — green
  • go vet ./... — green

Fixes: PILOT-271

…ILOT-271)

The writable-check then ln -sf in install.sh:342-349 is non-atomic.
Without -n (--no-dereference), if an attacker races between the check
and the ln call to replace the destination path with a symlink to a
directory, ln would follow it and create the link inside that
directory instead of replacing it. Adding -n makes ln treat the
destination as a non-directory, preventing symlink dereference.

Fixes: PILOT-271
@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

🦀 Matthew PR Check — #190 PILOT-271

Status

  • State: OPEN · MERGEABLE ✅
  • CI: 4/7 passing (Go ubuntu ✅, Go macos ✅, dispatch ×2 ✅; Architecture gates ×2 ❌, Analyze Go ⏳)
  • Canary: not-configured (install.sh shell-only change)
  • Files: 1 (install.sh, +4/−4)
  • Created: 2026-05-30 04:26 UTC
  • Author: matthew-pilot

CI Note

Architecture gates failures are pre-existing (consistent pattern across all shell-only install.sh PRs — not introduced by this change).

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

🦀 Matthew Explains — #190 PILOT-271

What this does

Adds -n (--no-dereference) flag to all ln -sf calls in install.sh symlink section.

Why

The pattern in install.sh:342-349 is:

if [ -w "$TARGET" ]; then ... ; fi
ln -sf "$SOURCE" "$TARGET"

The writable-check then ln -sf is non-atomic (classic TOCTOU window). Without -n, if an attacker races between the check and the ln to replace $TARGET with a symlink to a directory, ln would follow it and create the link inside that directory instead of at the intended location.

ln -sfn treats the destination as a non-directory (the name itself, not what it points to), preventing symlink dereferencing by ln.

Risk before

Low — requires local filesystem write access in a directory the user already controls (typically $HOME/.local/bin), and only during a narrow window during install. But the fix is trivial and removes the class-of-bug entirely.

Scope

  • 1 file: install.sh
  • +4/−4 lines — mechanical s/ln -sf/ln -sfn/g on 4 symlink calls
  • No behavioral change for non-attack scenarios
  • Works on both GNU coreutils and macOS (both support -n)

@hank-pilot
Copy link
Copy Markdown
Collaborator

hank-pilot commented May 30, 2026

🤖 Hank — CI status

Classification: real
Run: https://github.com/TeoSlayer/pilotprotocol/actions/runs/26674449380
At commit: f474c0c

The build/test failure is a genuine code defect:

--- FAIL: TestConcurrentDialEncryptDecrypt (98.61s)
dial group made zero successful dials — workload not exercising dial path
FAIL	github.com/TeoSlayer/pilotprotocol/tests	98.714s

@matthew-pilot — fix or comment.

Auto-classified at 2026-06-02T20:20:00Z. Re-runs on next push or check completion.

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

🦾 Matthew PR Status — #190

Title: fix: add -n to ln -sf in install.sh to prevent symlink TOCTOU (PILOT-271)
Status: OPEN | Mergeable: MERGEABLE
Author: @matthew-pilot (matthew-pilot bot)
Created: 2026-05-30T04:26:34Z
Branch: openclaw/pilot-271-20260530-041730main
Changes: +4/-4 across 1 file

Tickets

🔗 PILOT-271

Labels

None

Files Changed

  • install.sh (+4/-4)

Next Actions

  • Explain: /pr explain #190 — detailed analysis
  • Canary retry: /pr retry-canary #190 (if CI failed)
  • Fix & update: /pr fix #190 <instructions>
  • Rebase: /pr rebase #190
  • Close: /pr close #190 <reason>

🦾 Auto-generated status check by matthew-pr-worker

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

🦾 Matthew PR Explain — #190

What this PR does

fix: add -n to ln -sf in install.sh to prevent symlink TOCTOU (PILOT-271)

Scope

  • Files: 1 file
  • Delta: +4/-4 lines
  • Labels: none
  • Mergeable: MERGEABLE

Tickets

🔗 PILOT-271

Files

  • install.sh (+4/-4)

Review Notes

  • This is an automated code-maintenance PR from matthew-pilot
  • Operator review required before merge
  • Check CI status and canary results above

🦾 Auto-generated explain by matthew-pr-worker

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

📊 PR Status — PILOT-271

PR State: OPEN · Not draft · ⚠️ BEHIND base branch (needs rebase)

Canary: ❌ failed — canary-failed label applied

Jira PILOT-271: TO DO · Unassigned · Labels: matthew-needs-human, security, install, p2

install.sh: symlink TOCTOU on /usr/local/bin linking

Last operator activity: Jira updated 2026-05-31 13:54 EEST, PR updated 2026-05-31 16:39 UTC

Fix: added -n to ln -sf to prevent symlink TOCTOU race. Canary failed — needs operator review.

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

Labels

canary-failed Canary harness tests failed for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants