Giter Site home page Giter Site logo

Upload security about multer HOT 6 CLOSED

expressjs avatar expressjs commented on April 26, 2024 1
Upload security

from multer.

Comments (6)

jpfluger avatar jpfluger commented on April 26, 2024

This was a thoughtful post. If multer is used globally, multer is exposed to these vulnerabilities. But if the middleware is placed directly on the route, the security concerns are mitigated. I just wrote a doc explaining how to do this.

from multer.

mdaffin avatar mdaffin commented on April 26, 2024

Not entirely, you still have to check all the files in req.files and delete any you are not expecting. I have seen quite a few examples that only check for req.files.images, for example, with no limit set (I have not seen any set a limit) which means an attacker could upload a file to req.files.bad to bypass any check made. Even with a limit set you could just upload to req.files.bad and watch the code return an error as you did not set req.files.images... but by this point your file is already on the server. Unless you check all files in req.files.images and set multer middle ware on only the expect routes you are vulnerable.

from multer.

jpfluger avatar jpfluger commented on April 26, 2024

Yes, I see now. I've setup some tests and verified this. As a side-effect, one of the tests showed that surpassing the file limit creates a condition where multer never "finishes" the current process of parsing files: so the server hangs. I'm gonna try to fix this now and then add in support for "explicitFields." I already have a pull request to add in-memory parsing (no automatic write-to-disk). So hopefully these can get merged in or else I may clutter up the code. When I get my tests done, I'll drop a message on this thread to get your thoughts if what I'm looking at is right/wrong/needs nudging.

from multer.

jpfluger avatar jpfluger commented on April 26, 2024

I added support for fieldNameSize limitations in busboy and initiated a pull request. Once that lib gets updated, we can work through hardening multer and will report back here.

from multer.

hacksparrow avatar hacksparrow commented on April 26, 2024

👍

from multer.

LinusU avatar LinusU commented on April 26, 2024

@James147 I believe this to be solved by the newly released version 1.0.0. Please reopen if you have any further comments on how we could improve the security.

from multer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.