Skip to content

Harden: reject file uploads over 25 MiB on the client - #214

Merged
Baskarayelu merged 1 commit into
QuickLendX:mainfrom
greatest0fallt1me:fix/109-reject-file-uploads-over-25mib
Aug 28, 2026
Merged

Baskarayelu merged 1 commit into
QuickLendX:mainfrom
greatest0fallt1me:fix/109-reject-file-uploads-over-25mib

Conversation

@greatest0fallt1me

@greatest0fallt1me greatest0fallt1me commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

No file-size guard existed anywhere in the codebase -- an oversized upload (a multi-gigabyte accidental drag-drop, for example) had no client-side rejection before being read into memory or sent to the server.

Change

`lib/validation/fileUpload.ts`: `validateFileUpload(file)` returns `{ ok, error }` (never throws), rejecting anything over `MAX_UPLOAD_BYTES` (25 MiB) with a human-readable size in the message. This is a client-side UX/DoS-prevention guard, not a substitute for the server enforcing its own limit on the actual request.

Tests

`lib/validation/fileUpload.test.ts`: accepts at the exact limit, accepts a small file, rejects one byte over, and rejects a much larger file with the expected message text.

`npx vitest run lib/validation/fileUpload.test.ts`: 4 passed. `npx tsc --noEmit` / `npx eslint` on changed files: clean.

Related to #109

No file-size guard existed anywhere in this app. Add
validateFileUpload(file), rejecting anything over 25 MiB before it's
read into memory or sent to the server -- a client-side UX/DoS guard,
not a substitute for the server enforcing its own limit on the actual
request.
@Baskarayelu
Baskarayelu merged commit ff4e9e0 into QuickLendX:main Aug 28, 2026
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.

2 participants