Skip to content

Formidable detects MIME-type according to the file extension and not by the real content #749

@pubmikeb

Description

@pubmikeb

Support plan

  • which support plan is this issue covered by? (e.g. Community, Sponsor, or
    Enterprise): Community
  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): yes

Context

  • node version: 16.4.2
  • module (formidable) version: 3.0.0-canary.20210428
  • environment (e.g. node, browser, native, OS): Node.js
  • used with (i.e. popular names of modules):
  • any other relevant information:
    Formidable detects MIME-type according to the file extension and not by the real content. Which means that user can fake the file MIME by changing file's extension and as a result to upload to the server not allowed file types.

BTW, multer detects file's MIME not by the extension only.

What are you trying to achieve or the steps to reproduce?

  1. Given JPG file tst.jpg
  2. Rename it to tst.pdf
  3. Set a break point inside of uploader.parse(req, async (err, fields, files) => {…}
  4. Try to upload tst.pdf
uploader.parse(req, async (err, fields, files) => {
	if (err) {
		reject(err);
	} else {}
});

What was the result you got?

mimetype = application/pdf

11_010801

What result did you expect?

mimetype = image/jpeg
Since this file is actually JPG file but with a from extension.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: filesThings related to handling files, names, etc.Priority: HighAfter critical issues are fixed, these should be dealt with before any further issues.Status: AcceptedIt's clear what the subject of the issue is about, and what the resolution should be.Status: In ProgressThis issue is being worked on, and has someone assigned.Type: EnhancementMost issues will probably be for additions or changes. Expected that this will result in a PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions