Skip to content

fix: require auth for templates API routes - #486

Merged
tristan-mouchet merged 1 commit into
developfrom
fix/require-auth-templates-api
Aug 4, 2026
Merged

fix: require auth for templates API routes#486
tristan-mouchet merged 1 commit into
developfrom
fix/require-auth-templates-api

Conversation

@tristan-mouchet

Copy link
Copy Markdown
Collaborator

Summary

The /api/templates routes sit outside the /ycode tree, so the middleware auth gate never covered them. This left destructive, builder-only operations reachable without any authentication — most notably POST /api/templates/:id/apply, which clears the current site content and replaces it with a template. An unauthenticated attacker could repeatedly apply a template to keep a site in a reset state, an effective denial-of-service (and defacement) against published sites.

Changes

  • Gate the entire /api/templates prefix in the middleware auth check, alongside the existing /ycode/api and /ycode/preview protection.

Test plan

  • Unauthenticated GET /api/templates returns 401
  • Unauthenticated POST /api/templates/:id/apply returns 401 and does not modify content
  • Unauthenticated POST /api/templates/export and POST /api/templates/export-and-upload return 401
  • Authenticated builder requests to list and apply templates still succeed

The /api/templates routes sit outside the /ycode tree and were not
covered by the middleware auth gate, leaving destructive builder-only
operations (apply, export) reachable without authentication. An
unauthenticated request to apply a template could wipe and replace site
content, an effective denial-of-service. Gate the whole /api/templates
prefix in middleware.
@tristan-mouchet tristan-mouchet added the Bug Something isn't working label Aug 4, 2026
@tristan-mouchet tristan-mouchet added the Bug Something isn't working label Aug 4, 2026
@tristan-mouchet tristan-mouchet self-assigned this Aug 4, 2026
@tristan-mouchet
tristan-mouchet merged commit e6023ce into develop Aug 4, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant