fix(uploads): normalize submitted images - #9
Conversation
|
@greptileai review |
Independent security reviewCurrent state/checks: OPEN but currently CONFLICTING/DIRTY against Actionable (blocking): Residual/informational: Single-page enforcement, decoded-pixel limiting, orientation, and re-encoding are sound defenses for accepted images; the test should also cover animation/pixel-limit rejection. PDF proofs remain signature-only and require the separately acknowledged scanning/CDR control. Reconcile #2 plus the shared route changes in #3/#4/#11, then rerun install/build/security checks on the production Linux target. |
|
Addressed the blocking upload-size finding in commit
Validation passed locally after a clean install and current migrations: |
…ation-images # Conflicts: # scripts/check-security.ts # src/app/api/registrations/route.ts
Summary
claimKeyhandling from currentmainProblem
Magic-byte checks identify a file format but preserve embedded metadata and arbitrary trailing content. Re-encoding accepted images produces a clean canonical output before storage, but canonicalization can expand a valid sub-10-MiB input above the storage/resource limit unless the result is bounded too.
Validation
npm cinpm run db:generatenpm run db:migratenpm run checknpx prisma validatenpm audit(0 vulnerabilities)npm run buildFocused coverage proves arbitrary trailing bytes are removed, a sub-10-MiB noisy JPEG that expands above 10 MiB is rejected, animated WebP is rejected, and input above 25 million decoded pixels is rejected.
Scope
PDF payment proofs remain byte-validated but are not antivirus/CDR scanned; that requires an external scanning service or deployment component.