Looking for the vulnerability index of Invicti's legacy products?
Weak Session ID in cookie Detected - Vulnerability Database

Weak Session ID in cookie Detected

Description

The application generates session identifiers that lack sufficient randomness or length, making them predictable or susceptible to brute-force attacks. Session IDs are critical security tokens used to maintain authenticated user sessions, and weak generation methods can allow attackers to guess or enumerate valid session tokens.

Remediation

Implement cryptographically secure session ID generation using the following guidelines:

1. Generate session IDs using a cryptographically secure random number generator (CSRNG) with a minimum entropy of 128 bits
2. Ensure session IDs are at least 128 bits (16 bytes) in length when encoded
3. Use established session management frameworks rather than custom implementations

Example for secure session ID generation:

// Java example
String sessionId = new BigInteger(130, new SecureRandom()).toString(32);

// Python example
import secrets
session_id = secrets.token_urlsafe(32)  # 32 bytes = 256 bits

// Node.js example
const crypto = require('crypto');
const sessionId = crypto.randomBytes(32).toString('hex');

// PHP example
$sessionId = bin2hex(random_bytes(32));

Additionally, implement session security best practices including secure cookie flags (HttpOnly, Secure, SameSite), session timeout mechanisms, and session regeneration after authentication or privilege changes.