Skip to content

fix(backoffice): comprobar las subidas por su contenido y limitar las descargas - #22

Merged
bpstack merged 1 commit into
claude/compassionate-planck-gh6aoffrom
opencode/fix-backoffice-files
Oct 12, 2026
Merged

bpstack merged 1 commit into
claude/compassionate-planck-gh6aoffrom
opencode/fix-backoffice-files

Conversation

@bpstack

@bpstack bpstack commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Cambios

  • Los PDF e imágenes subidos se comprueban por sus bytes, no por el tipo declarado.
  • Las descargas de ficheros guardados y el ZIP tienen tope de tamaño; un PDF de más de 10 MB responde con su error, no con 500.

Por qué

Se podía subir como PDF un fichero que no lo era, y el ZIP no tenía límite.

…nloads

- Invoice PDFs and stamp or signature images go through
  middlewares/backofficeUpload.ts: the declared type and the first bytes must
  match (PDF; PNG or WebP), and a file over 10 MB answers 413 with
  BACKOFFICE_FILE_TOO_LARGE instead of 500.
- The controller drops its own type and size checks, now unreachable.
- fetchStoredFile stops at 20 MB (maxContentLength); redirects were already
  refused.
- isPdfBuffer moves from the F&B parser to services/uploads/pdf-signature.ts
  so both modules share it.
- Tests: real multipart requests for both uploads, and the axios options of
  fetchStoredFile.

Why: any file declared as application/pdf reached Cloudinary, the multer
size error reached the global handler as a 500, and the ZIP of up to 100
validated invoices downloaded each one without a size limit (TODO "subidas
y descargas sin comprobar contenido ni tamaño").
@bpstack
bpstack merged commit bdf1932 into claude/compassionate-planck-gh6aof Oct 12, 2026
4 checks passed
@vercel

vercel Bot commented Oct 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
four-points Ready Ready Preview Oct 12, 2026 6:54pm UTC

@bpstack
bpstack deleted the opencode/fix-backoffice-files branch October 12, 2026 19:01

This branch was successfully deployed

1 active deployment
Preview — bb77dd6f Deployed Oct 12, 2026 by vercel[bot]
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