Javascript Session Cookie Secure False
Description
Detects insecure session cookie configurations in Express.js applications where cookies are not set with the 'secure' flag. When session cookies lack the secure flag, they can be transmitted over unencrypted HTTP connections, potentially exposing session data to interception attacks.
Detection Strategy
• Identifies usage of 'express-session' module in the code
• Checks the configuration object passed to express-session middleware
• Reports a vulnerability when either:
• - No configuration object is provided to express-session
• - The configuration object sets cookie.secure to false or omits it
Vulnerable code example
const express = require('express');
const session = require('express-session');
const app = express();
// Vulnerable: Missing httpOnly:true and using secure:false allows cookie theft
app.use(session({
resave: false,
saveUninitialized: true,...✅ Secure code example
const express = require('express');
const session = require('express-session');
const app = express();
// Secure: httpOnly prevents XSS access, secure ensures HTTPS-only transmission
app.use(session({
resave: false,
saveUninitialized: true,...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.