Skip to content

Fix: prevent prompt/command injection in fix-broken-links hooks#2083

Merged
aaronpowell merged 1 commit into
stagedfrom
aaronpowell-fix-hook-command-injection
Jun 22, 2026
Merged

Fix: prevent prompt/command injection in fix-broken-links hooks#2083
aaronpowell merged 1 commit into
stagedfrom
aaronpowell-fix-hook-command-injection

Conversation

@aaronpowell

Copy link
Copy Markdown
Contributor

Summary

  • sanitize URL text before embedding it into Copilot prompt strings in hooks/fix-broken-links/link-fix.sh
  • sanitize URL text before embedding it into Copilot prompt strings in hooks/fix-broken-links/link-fix.ps1
  • preserve existing link-check and suggestion behavior while hardening prompt construction

Context

This PR replaces #2069 with the same security intent on the correct branch history.

Replaces #2069.

Sanitize URL input before embedding it in Copilot handoff prompts in both bash and PowerShell hook scripts to prevent command/prompt injection from untrusted link text.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 22, 2026 01:31
@github-actions github-actions Bot added the hooks PR touches hooks label Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔒 PR Risk Scan Results

Scanned 2 changed file(s).

Severity Count
🔴 High 0
🟠 Medium 0
ℹ️ Info 0

✅ No matching risk patterns were detected in changed files.

This is an automated soft-gate report. Findings indicate review targets and do not block merge by themselves.

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.

Pull request overview

Hardens the fix-broken-links hook scripts by sanitizing URL text before embedding it into Copilot CLI prompt strings, reducing the risk of prompt-string manipulation from document-sourced URLs while keeping the existing link-alternative workflow intact.

Changes:

  • Sanitizes the broken URL before interpolating it into the Copilot prompt in link-fix.sh.
  • Adds a URL sanitization helper and uses it when constructing the Copilot prompt in link-fix.ps1.
Show a summary per file
File Description
hooks/fix-broken-links/link-fix.sh Adds sanitize_prompt_url and uses it to pre-sanitize the URL before building the Copilot prompt.
hooks/fix-broken-links/link-fix.ps1 Adds Get-PromptSafeUrl and uses it to pre-sanitize the URL before building the Copilot prompt.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@aaronpowell aaronpowell merged commit 8febac4 into staged Jun 22, 2026
13 checks passed
@aaronpowell aaronpowell deleted the aaronpowell-fix-hook-command-injection branch June 22, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hooks PR touches hooks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants