Skip to content

fix: confine event hook script paths to the project tree - #4133

Open
SebTardif wants to merge 1 commit into
github:mainfrom
SebTardif:fix/4131-event-script-path-confine
Open

fix: confine event hook script paths to the project tree#4133
SebTardif wants to merge 1 commit into
github:mainfrom
SebTardif:fix/4131-event-script-path-confine

Conversation

@SebTardif

Copy link
Copy Markdown

Description

Event hook script resolution joined the first scripts: token onto the .specify or extension base with Path. An absolute token discarded that base and ran a host binary.

This rejects anchored tokens (absolute, drive, UNC) and requires the resolved path to stay inside the project root. Relative .. walks that remain in the project still work, including documented extension ../../scripts/... references to core scripts. The same check is in the CLI resolver and the generated stdlib dispatcher.

Introduced in #3704 (f8e474d, 2026-07-29).

Same-repo path confinement: #3088, #2296, #3869.

Closes #4131

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest (tests/integrations/test_events.py, 121 passed)
  • Tested with a sample project (if applicable) (not applicable; no slash-command change)

Added resolver tests for absolute tokens, a walk out of the project, Windows-anchored tokens, extension ../../scripts/..., symlink escape, and an inline-dispatcher run that refuses an absolute host script.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (describe below)

Code and tests written with Grok (model: grok-4.6) under direct supervision. Reviewed and tested locally before opening this PR.

Posted on behalf of @SebTardif by Grok (model: grok-4.6).

Event dispatch joined the first scripts: token onto the .specify or
extension base with Path. An absolute token discarded the base and ran
a host binary. Reject anchored tokens and require the resolved path to
stay inside the project root.

Assisted-by: Grok (model: grok-4.6, supervised)
Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@SebTardif
SebTardif requested a review from mnriem as a code owner August 15, 2026 09:56
Copilot AI balanced review requested due to automatic review settings August 15, 2026 09:56

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

[Bug]: Event hook scripts: paths are not confined to the extension or project base

2 participants