Skip to content

Security: validate skill slug on all skill routes to prevent path traversal attempts #31

@rishabhpoddar

Description

@rishabhpoddar

Summary

assertSkillSlug is enforced during skill creation, but most read/edit/delete skill routes accept raw :slug and use it to build filesystem paths. This leaves a path traversal attack surface (via crafted slugs) before canonical slug validation.

Affected code

  • src/utils/skill.ts
    • assertSkillSlug exists and is only used in createSkill(...)
    • getSkillPath(slug) + getSkillManifestPath(slug) join directly with provided slug
  • src/skills/index.ts
    • routes like GET /:slug, file routes, permissions update, delete, approve/reject use req.params.slug directly

Why this matters

Even if downstream code often fails safely, accepting unvalidated slugs in path construction creates avoidable filesystem traversal risk and makes security posture dependent on incidental checks.

Proposed fix

  1. Add a single helper to canonicalize/validate skill slug (reuse assertSkillSlug).
  2. Apply it at the start of every /:slug skill route (or in shared route middleware).
  3. Add tests for traversal payloads (e.g. .., encoded separators, absolute-like inputs).

Acceptance criteria

  • All skill routes reject invalid slugs with 400.
  • Traversal/encoded traversal attempts cannot influence resolved filesystem path.
  • Existing valid slugs continue to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions