Skip to content

Harden API request handling and access boundaries - #1063

Open
Creylay wants to merge 5 commits into
developfrom
fix/api-upload-path-hardening
Open

Creylay wants to merge 5 commits into
developfrom
fix/api-upload-path-hardening

Conversation

@Creylay

@Creylay Creylay commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Hardens request handling and access boundaries on the backend API. The API is local-first and unauthenticated, so these changes tighten what the browser and callers are allowed to do.

Four related changes:

  • Uploaded file name handling (jobs.py): the upload target is now derived from the file's basename and confined to the server-created temp dir, instead of trusting a client-supplied path.
  • Credential responses (credentials.py): the stored key is no longer returned by the API. is_authenticated already tells the UI whether a key is saved; the dialog starts with an empty field.
  • Static file serving (front_api.py): requested paths are resolved and refused unless they stay inside the frontend build directory.
  • CORS (app.py, config.py): allowed origins are now an explicit list (new CORS_ALLOWED_ORIGINS setting, default is the dev frontend) instead of *. Production is served from the same origin, so it is unaffected.

Tests

  • New focused tests for each change, each confirmed to fail before the fix and pass after.
  • Full backend API suite green (1397 passed, 4 skipped).

Notes

  • CORS_ALLOWED_ORIGINS is configurable for setups that serve the frontend
    from another origin (e.g. a remote host). It should never be set to *.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant