Repository navigation
fix(server): reject skill names that escape the skills source - #408
Conversation
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
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| if clean == "." || clean == ".." || filepath.IsAbs(clean) { | ||
| return false | ||
| } | ||
| return !strings.HasPrefix(clean, ".."+string(filepath.Separator)) |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
Type
Summary
GET /api/audit/{name}joined the client-supplied name to the skills source without checking it, so a name such as../../xscanned a directory outside the source and reported it as a normal skill (the regression test shows the old route returning200withscanTargetoutside the source). The single-skillPOST /api/update, theGET /api/update/stream?names=loop, andPOST /api/uninstall/batchbuilt 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 choicesourcewalkmakes for.skillfollownames). Nested names such asgroup/skilland_repo/skillstill resolve.GET /api/audit/{name}400 invalid skill namePOST /api/update(single name)400 invalid skill nameGET /api/update/stream?names=resultwithaction: "error"POST /api/uninstall/batch_-prefixed namesinvalid skill nameDELETE /api/skills/repo/{name}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 checkin a throwaway devcontainer-image container: all green.TestHandleAuditSkill_RejectsNameOutsideSourcefails on the unpatched handler (expected 400, got 200,scanTargetoutside the source) and passes with the fix; the update, stream, and batch-uninstall tests cover the other routes;TestValidSourceNamepins the rule.Versioning
Bug fix; patch release. No
Release-Asfooter.Linked Issue
Closes #402.
Checklist
make check) — for code changes