Fix: prevent prompt/command injection in fix-broken-links hooks#2083
Merged
Conversation
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>
Contributor
🔒 PR Risk Scan ResultsScanned 2 changed file(s).
✅ No matching risk patterns were detected in changed files.
|
Contributor
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hooks/fix-broken-links/link-fix.shhooks/fix-broken-links/link-fix.ps1Context
This PR replaces #2069 with the same security intent on the correct branch history.
Replaces #2069.