Rejecting requests with significant content length is a good practice to control the network traffic intensity and thus resource consumption in order to prevents DoS attacks.
There is a risk if you answered yes to any of those questions.
It is recommended to customize the rule with the limit values that correspond to the web application.
formidable file upload module:
const form = new Formidable(); form.maxFileSize = 10000000; // Sensitive: 10MB is more than the recommended limit of 8MB const formDefault = new Formidable(); // Sensitive, the default value is 200MB
multer (Express.js middleware) file upload module:
let diskUpload = multer({
storage: diskStorage,
limits: {
fileSize: 10000000; // Sensitive: 10MB is more than the recommended limit of 8MB
}
});
let diskUploadUnlimited = multer({ // Sensitive: the default value is no limit
storage: diskStorage,
});
body-parser module:
// 4MB is more than the recommended limit of 2MB for non-file-upload requests
let jsonParser = bodyParser.json({ limit: "4mb" }); // Sensitive
let urlencodedParser = bodyParser.urlencoded({ extended: false, limit: "4mb" }); // Sensitive
formidable file upload module:
const form = new Formidable(); form.maxFileSize = 8000000; // Compliant: 8MB
multer (Express.js middleware) file upload module:
let diskUpload = multer({
storage: diskStorage,
limits: {
fileSize: 8000000 // Compliant: 8MB
}
});
body-parser module:
let jsonParser = bodyParser.json(); // Compliant, when the limit is not defined, the default value is set to 100kb
let urlencodedParser = bodyParser.urlencoded({ extended: false, limit: "2mb" }); // Compliant