Home » Vulnerabilities Knowledge Base » Authenticity of the session token is not being checked and validated at the server-side
In a secure web application, once a user logs in, the server usually issues a session token. This token is often stored in a cookie, localStorage, or passed as a bearer token. It is used to verify the user’s identity on future requests.
This vulnerability happens when the server fails to check if the session token is legitimate. This means:
Real-world Example: If an attacker creates or changes a session token and the server does not verify it against a trusted session store or signature, the attacker can bypass authentication and gain unauthorized access. This is a typical case of Broken Authentication and is a serious issue according to the OWASP Top 10.
To fix this issue effectively, developers need to use strict session token validation methods:
Always Validate Tokens Server-Side
On each request, check the session token against the server-side session store for opaque tokens. For JWTs or signed tokens, verify:
Signature
Expiry (exp)
Issuer (iss)
Audience (aud)
Use Secure Token Standards
Use signed JWT tokens with strong algorithms and never accept unsigned tokens. Store sensitive sessions in HTTP-only, Secure cookies with the right flags, such as SameSite=Strict.
Token Expiry & Rotation
Use short-lived tokens and refresh token methods. Invalidate sessions after logout or after a period of inactivity.
Avoid Common Pitfalls
Do not trust tokens from the client without validation. Avoid custom or outdated token methods that do not have cryptographic protection.
Vulnerable Libraries or Practices
Do not use older versions of token libraries like:
Content Sniffing
Certain browsers, try to determine the content type and encoding of the response even when these properties are defined correctly...
Content Sniffing
Certain browsers, try to determine the content type and encoding of the response even when these properties are defined correctly...
Content Sniffing
Certain browsers, try to determine the content type and encoding of the response even when these properties are defined correctly...
Content Sniffing
Certain browsers, try to determine the content type and encoding of the response even when these properties are defined correctly...