This vulnerability allows an attacker to accesses default accounts, unused pages, unpatched flaws, unprotected files and directories, etc. to gain unauthorized access to or knowledge of the system.
Security misconfiguration can happen at any level of an application stack, including the platform, web server, application server, database, framework, and custom code.
Developers and system administrators need to work together to ensure that the entire stack is configured properly.
urlencoded, json, multipart
) instead of using aggregate
limit
middleware. Include only required middleware. For example if application doesn't need to support file uploads, do not include multipart middleware.
The default HTTP header x-powered-by can reveal implementation details to an attacker. It can be taken out by including this code in
server.js
app.disable("x-powered-by");
The default session cookie name for express sessions can be changed by setting key attribute while creating express session.
app.use(express.session({ secret: config.cookieSecret, key: "sessionId", cookie: { httpOnly: true, secure: true } }));
The security related HTTP Headers can be added using helmet middleware as below
// Prevent opening page in frame or iframe to protect from clickjacking app.disable("x-powered-by"); // Prevent opening page in frame or iframe to protect from clickjacking app.use(helmet.xframe()); // Prevents browser from caching and storing page app.use(helmet.noCache()); // Allow loading resources only from white-listed domains app.use(helmet.csp()); // Allow communication only on HTTPS app.use(helmet.hsts()); // Forces browser to only use the Content-Type set in the response header instead of sniffing or guessing it app.use(nosniff());