Skip to content

[Security] Static uploads served without authentication any file accessible without login #334

@Midoriya-w

Description

@Midoriya-w

Summary

In apps/backend/src/app.ts, uploaded files are served as public static assets:

await app.register(fastifyStatic, {
  root: path.join(__dirname, '..', 'uploads'),
  prefix: '/uploads/',
  decorateReply: false,
});

There is no authentication middleware on the /uploads/ route. Any file uploaded by any user can be accessed directly via GET /uploads/<filename> without any login or ownership check.

Location

apps/backend/src/app.tsfastifyStatic registration

Impact

  • Private user uploads (profile pictures, avatars etc.) are publicly accessible to anyone
  • An attacker can enumerate filenames and access other users' uploaded files
  • No ownership validation exists between the requesting user and the file

Steps to Reproduce

  1. Upload any file as an authenticated user
  2. Note the returned file path
  3. Log out completely
  4. Access GET /uploads/<filename> directly in browser
  5. File is returned without any auth check

Fix

Either add authentication middleware to the /uploads/ prefix, or serve files through a route handler that validates ownership before streaming the file.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions