Skip to content
WarHound AI

Application Security

Session cookies: rotation, expiry and browser boundaries

Managing application state securely over HTTP demands careful use of browser boundaries, appropriate session lifecycle management, and high-entropy identifiers. This guide covers cookie attributes, server-side design considerations, and lifecycle events that affect session persistence and isolation.

Observe. Explain. Retest.MAKE EVIDENCE USEFULWARHOUND / FIELD NOTESCONCEPTREVIEW NOTE / ILLUSTRATIVEOBSERVATIONEVIDENCERETESTObserve. Explain. Retest.MAKE EVIDENCE USEFULOBSERVATIONEVIDENCERETESTWARHOUND / CONCEPTUAL ILLUSTRATION
Useful security reviews connect an observation to evidence and a deliberate retest. Conceptual illustration.

Stateless HTTP and Session Identifiers

HTTP remains stateless by design. Maintaining state across requests relies on session identifiers issued after authentication or during anonymous tracking. These identifiers bind subsequent requests to server-side objects storing context, such as user IDs, roles, or cart contents.

The security of the entire application state relies on the unpredictability and confidentiality of these identifiers. If an attacker predicts, steals, or fixes a session identifier, they assume the privileges bound to that session. Therefore, session IDs act as temporary credentials equivalent in power to the authentication methods that originally established them.

To mitigate guessing, session identifiers must offer at least 64 bits of entropy. Common encodings like hex or base64 require lengths greater than the raw entropy bits; for example, 16 characters of pure hexadecimal encoding provide 64 bits of entropy, provided no parts of the identifier are static or predictable.

Server-Side Session Storage

Application logic associated with a session must remain on the server. Including raw sensitive data like access rights or personal information directly in client-side cookies exposes data unnecessarily and complicates integrity enforcement.

When storing session identifiers on the server, raw verbatim storage presents a risk if the session store is exposed to unauthorized reads. A split token design mitigates this. In this approach, the cookie carries a public identifier and a secret verifier. The server stores the identifier and a fast cryptographic hash (like SHA-256) of the verifier. The application looks up the session using the identifier, hashes the submitted verifier, and performs a constant-time comparison.

This split design prevents an attacker with read-only database access from immediately hijacking active sessions. However, it does not defend against active compromise or cookie theft on the client side. A CSPRNG must generate both the identifier and the verifier independently, ensuring at least 128 bits of entropy.

Session Lifecycle and Renewal

A session identifier must not persist indefinitely. Explicit expiry boundaries limit the window of opportunity for an attacker holding a compromised token. Applications should enforce both an absolute timeout (maximum total duration) and an idle timeout (maximum time without activity).

Crucially, session identifiers must be regenerated upon authentication or significant privilege changes. When transitioning from an anonymous to an authenticated state, or when elevating privileges (e.g., sudo mode), the application must invalidate the old session and issue a newly generated identifier. This defends against session fixation attacks, where an attacker pre-seeds a session identifier and waits for the victim to authenticate into it.

Transitions between HTTP and HTTPS should not reuse the same session identifier, as the initial HTTP transmission compromises the token. Enforcing HTTPS entirely via HSTS is the preferred mitigation.

Sources

Factual claims regarding cookie attributes, session entropy, storage strategies, and lifecycle events are drawn from the OWASP Session Management Cheat Sheet.

Drafted with Gemini and checked for source links, advisory identifiers, structure and unsupported product claims. Examples are synthetic and are not scan results.

Drafted with Gemini and checked for source links, advisory identifiers, structure and unsupported product claims. Examples are synthetic and are not scan results.

Prepared with AI assistance and published by WarHound AI. Check the references and evidence limits in each article.

The WarHoundAI journal

Questions or a factual correction? Get in touch with the article URL and supporting evidence.

Continue reading.

All articles
Application Security

Archive extraction: traversal, symlinks and resource exhaustion

Processing ZIP archives introduces significant risks including path traversal, arbitrary file writes via symlinks, and resource exhaustion. This guide covers safe extraction techniques, testing matrices, and implementation tradeoffs based on OWASP standards.

Read article 6 min read
Application Security

WebSocket authentication and message authorization

Unlike standard HTTP requests, WebSocket connections remain open for persistent bidirectional data exchange, rendering traditional request-based security filters ineffective. Application engineers must implement custom authentication during the initial handshake, continuously manage session validity over long-lived connections, and authorize individual messages independently to prevent hijacking and unauthorized data access.

Read article 6 min read
Database Security

Tenant isolation with PostgreSQL row security

PostgreSQL Row-Level Security (RLS) provides a robust mechanism for enforcing tenant isolation directly at the database layer. By defining permissive and restrictive policies, application engineers can ensure that data access is restricted on a per-user or per-tenant basis prior to application-level filtering. This article details the implementation of these policies, addresses critical race conditions in policy subqueries, and outlines a comprehensive testing matrix to verify isolation boundaries.

Read article 5 min read