Skip to content

/api/recipe_image/{*path} accepts any file, not just .cook/.menu recipes #697

Closed

Description

@drawmeanelephant

Suggested labels: bug, area: server


Discovery audit finding H4 (high) — cooklang/cookcli @ 7c2f48b (v0.38.1), audited 2026-10-12. Repro verified live. Security-relevant: arbitrary file read (and write/delete) of non-recipe files under the recipe directory. Same bug class as #658, on an endpoint that was missed.

Summary

GET/PUT/DELETE /api/recipe_image/{*path} accepts any file, not just .cook/.menu recipes.

Where

src/server/handlers/recipe_image.rs:351-359 — find_recipe uses check_path but never is_recipe_request (the .cook/.menu extension allowlist that handlers/recipes.rs has).

Repro

$ curl /api/recipe_image/config/pantry.conf
200 — the entire pantry.conf contents as step text: [dairy] milk = "1%l" eggs = { quantity = "12", ... }
$ curl /api/recipes/config/pantry.conf
404

PUT wrote config/notes.jpg beside a text file; DELETE removes {stem}.{jpg,png,...} beside any file.

Expected

The endpoint only accepts paths to .cook/.menu recipes; anything else 404s, exactly like /api/recipes/.

Actual

Any path under the recipe directory is accepted; non-recipe files are read out in full, and PUT/DELETE create/remove files beside them.

Acceptance criteria (red → green)

  • Red: GET /api/recipe_image/config/pantry.conf returns 200 with the file's contents.
  • Green: it returns 404, and PUT/DELETE refuse non-recipe paths.

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