Skip to content

Generative image, dataset and component image endpoints read files outside their folders #1067

Backlog

Description

@Irozuku

Summary

Several endpoints build file paths from request input without checking that the result stays inside the folder they serve. #1063 fixes this pattern in the static frontend route (front_api.py); the endpoints below still have it.

Where

Found at 44d4e5a, still present on develop (f5b2c3e).

  • GET /api/v1/generative-process/file/{filename} (generative_process.py#L421-L427) joins filename onto IMAGES_PATH and serves the result. The path converter blocks /, but on Windows an encoded backslash stays inside one segment, so .. escapes the images folder. Confirmed by reading a file placed outside IMAGES_PATH.
  • Dataset endpoints take a raw filesystem path query parameter and read <path>/dataset/... without consulting the database: GET /dataset/sample/file (datasets.py#L642-L678), GET /dataset/file/info (L701-L729), GET /dataset/types/file (L886-L912), GET /dataset/file/ (L1555) and GET /dataset/export/csv (L1787-L1836). Any DashAI dataset folder on the machine can be read or exported. Confirmed with a folder outside the data root.
  • GET /api/v1/component/image/{component_name}/ (components.py#L565-L583) opens image_preview from component metadata relative to the images folder without containment, and fetches it with requests.get when it is a URL. This needs a malicious plugin, so it is low risk.

Impact

File read outside the data folders, with no authentication. These are GET requests, so they also matter for the DNS rebinding gap in the API (#1070).

Suggested fix

  • One shared helper that resolves the candidate path and refuses anything not inside the allowed root (resolve() then is_relative_to), handling .., backslashes, absolute paths and drive letters. The fix in Harden API request handling and access boundaries #1063 for front_api.py already does this and could be reused.
  • Look datasets up by id on the server instead of taking a filesystem path from the client; update the frontend callers.
  • For component images, confine local paths to the images folder and drop or allowlist remote fetching.

Activity

  1. added
    bug
    back
    priority: high
    on Dec 2, 2026
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

    backbugpriority: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions