Skip to content

Recipe endpoints and /api/static follow symlinks out of the collection #698

Closed

Description

@drawmeanelephant

Suggested labels: bug, area: server


Discovery audit finding M1 (medium) — cooklang/cookcli @ 7c2f48b (v0.38.1), audited 2026-10-12. Repro verified live. Security-relevant: arbitrary read, and (with EditRecipes) write/delete outside the collection.

Summary

Recipe endpoints and /api/static follow symlinks out of the collection.

Where

Repro

$ ln -s /outside recipes/LinkDir
$ curl /api/recipes/raw/LinkDir/Secret.cook      # returns the outside file verbatim
$ curl -X PUT /api/recipes/LinkDir/Pwned.cook    # wrote into the outside dir
$ curl -X DELETE /api/recipes/LinkDir/Pwned.cook # removed it there
$ ln -s /secret.txt recipes/Linked.jpg
$ curl /api/static/Linked.jpg                     # serves the secret

Expected

Path containment is enforced after symlink resolution; reads/writes/deletes through a symlink that leaves the collection are refused.

Actual

Outside files are served verbatim; writes and deletes land outside the collection.

Acceptance criteria (red → green)

  • Red: the repro's GET /api/recipes/raw/LinkDir/Secret.cook returns the outside file and /api/static/Linked.jpg serves /secret.txt.
  • Green: both are refused (403/404) and PUT/DELETE through LinkDir change nothing outside.

Verification

Executed repro, verified live.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions