Skip to content

fix(server): reject skill names that escape the skills source - #408

Merged
runkids merged 1 commit into
mainfrom
runkids/402-audit-path-escape
Oct 5, 2026
Merged

runkids merged 1 commit into
mainfrom
runkids/402-audit-path-escape

Conversation

@runkids

@runkids runkids commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor)
  • Feature

Summary

GET /api/audit/{name} joined the client-supplied name to the skills source without checking it, so a name such as ../../x scanned a directory outside the source and reported it as a normal skill (the regression test shows the old route returning 200 with scanTarget outside the source). The single-skill POST /api/update, the GET /api/update/stream?names= loop, and POST /api/uninstall/batch built paths the same way; DELETE /api/skills/repo/{name} already refused such names inline.

One helper, validSourceName, now holds the rule for all of them: non-empty, relative, not starting with .., and no Windows separators or volume prefixes on any host (the same choice sourcewalk makes for .skillfollow names). Nested names such as group/skill and _repo/skill still resolve.

Route Before After
GET /api/audit/{name} scanned the escaped path 400 invalid skill name
POST /api/update (single name) resolved the escaped path 400 invalid skill name
GET /api/update/stream?names= resolved the escaped path that item is a result with action: "error"
POST /api/uninstall/batch joined the escaped path for _-prefixed names that item fails with invalid skill name
DELETE /api/skills/repo/{name} refused inline unchanged, now via the helper

The dashboard binds to localhost, so this is a local-user boundary, but the routes should still stay inside the source. Found during the internal review of #390 (ai_docs/reports/274-review-fixes.md); the bug predates that PR.

Checks run

  • make check in a throwaway devcontainer-image container: all green.
  • TestHandleAuditSkill_RejectsNameOutsideSource fails on the unpatched handler (expected 400, got 200, scanTarget outside the source) and passes with the fix; the update, stream, and batch-uninstall tests cover the other routes; TestValidSourceName pins the rule.

Versioning

Bug fix; patch release. No Release-As footer.

Linked Issue

Closes #402.

Checklist

  • I've read CONTRIBUTING.md
  • Tests included and passing (make check) — for code changes
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

GET /api/audit/{name} joined the client-supplied name to the source
without checking it, so a name such as ../../x scanned a directory
outside the skills source and returned a clean result for it. The
single-skill update, the update stream, and the batch uninstall built
paths the same way; the tracked-repo uninstall route already refused
such names inline.

One helper, validSourceName, now holds that rule: non-empty, relative,
not starting with "..", and no Windows separators or volume prefixes on
any host, as sourcewalk does for declared names. The audit and update
routes answer 400, the update stream reports the name as an error
result, the batch uninstall fails that item, and the repo uninstall
route uses the same helper. Nested names such as group/skill still
resolve.

Closes #402
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T20:50:18.981924Z 755dabb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 755dabb9fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +22 to +25
if clean == "." || clean == ".." || filepath.IsAbs(clean) {
return false
}
return !strings.HasPrefix(clean, ".."+string(filepath.Separator))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject symlinked paths before updates

When an accepted name such as _outside or repo/link contains a symlink to a Git repository outside the skills source, this lexical check still returns true because filepath.Clean does not resolve links. Both update handlers subsequently identify the target through install.IsGitRepo (which follows the link via os.Stat) and pass it to updateTrackedRepo, so a pull—or a forced restore/reset—mutates the external repository despite this change's containment guarantee. Resolve the candidate and verify it remains under the resolved source, or reject linked path components before any update operation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope for this PR, tracked as #410.

validSourceName is deliberately lexical: #402 is about a client-supplied name escaping the source with ... Following a symlink the user placed inside their own source is existing behavior shared with the CLI (cmd/skillshare/update.go resolves the source root and detects repos with install.IsGitRepo, which follows links the same way), and the dashboard binds to localhost, so whoever can plant that link already has access to the external repo. Changing it means deciding the policy for the CLI and the web routes together, which #410 captures.

@runkids
runkids merged commit c61f488 into main Oct 5, 2026
8 checks passed
@runkids
runkids deleted the runkids/402-audit-path-escape branch October 5, 2026 03:03
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.

Dashboard: GET /api/audit/{name} does not reject .. and can scan outside the skills source

1 participant