fix(translate-skills): reject deeper-path traversal in sibling-skill regex#2
Merged
vladolaru merged 1 commit intoMay 13, 2026
Conversation
…regex Skill content that documents paths like `../../scripts/` was causing reconcile to fail with a path-traversal error. The sibling-reference regex `(?<!\.)\.\./(?P<skill>[A-Za-z0-9._-]+)/` allowed the captured name to consist solely of dots, so `re.findall` on `../../scripts/` matched `../../` with `skill=".."`. The bridge then resolved two levels up from the skill directory and tried to vendor the entire plugin (including `.claude-plugin/marketplace.json`) into the generated skill. The resulting `relative_path` entries started with `..`, which tripped the registry's `_normalize_skill_relative_path` guard. The regex is now tightened on both sides of the `../`: - Lookbehind extended from `(?<!\.)` to `(?<![./])` so a `../` preceded by `/` (i.e. part of a deeper path like `/../`) does not match. - The captured name must start with `[A-Za-z0-9_-]`, which rejects `.` and `..` outright. Real-world trigger: `claude-session-driver/driving-claude-code-sessions` documents that scripts live at `../../scripts/` relative to the skill base directory.
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
../../path/documentation in skill content no longer derails reconcile.claude-session-driverdocuments that scripts live at../../scripts/relative to the skill base directory).Problem
The regex
(?<!\.)\.\./(?P<skill>[A-Za-z0-9._-]+)/allowed the captured name to consist solely of dots. On input like../../scripts/,re.findallmatched../../withskill="..". The bridge then resolved two levels up from the skill directory and tried to vendor the entire plugin — including.claude-plugin/marketplace.json— into the generated skill. The resultingrelative_pathentries started with.., which tripped_normalize_skill_relative_path's traversal guard inregistry.py, aborting reconcile with:Fix
Both sides of the
../are tightened:(?<!\.)→(?<![./])so/../(part of a deeper path) no longer matches.[A-Za-z0-9_-], rejecting.and..outright.Existing tests still pass; one new regression test confirms
../../scripts/no longer produces files with leading..in their relative paths.Test plan
pytest tests -q— 1014 passed (was 1013, +1 new test).mainand passes after the fix.