The Default Timeout That Let 12,000 Sessions Live Forever: A Pen Test Log

Archi4 min read

securitytestingsessionscookies

Contents
  1. Field notes: a session that would not die
  2. How we noticed
  3. Tracing the calls
  4. The root cause in one sentence
  5. Why the idle timeout did not save anyone
  6. What we recommend checking
  7. What the vendor changed
  8. The general lesson

Field notes: a session that would not die#

We were three days into a gray-box test of a customer portal when a tester left a browser tab logged in on Friday and came back Monday to a live session. No reauthentication prompt. No MFA challenge. Just the dashboard, still open. That is the kind of finding that looks like a bug in the login form. It was not. The login form was fine. The root cause sat two layers down, in how the reverse proxy handled cookie expiry and logout calls.

This is a write-up of how we got there, what we measured, and the one configuration check that would have caught it before the test started.

How we noticed#

The portal used a bearer token stored in an HttpOnly cookie. The vendor's documentation promised a 30-minute idle timeout. We logged in with a test account at 09:00, closed the browser, and did not touch the session again. At 17:40 the same cookie still returned a valid API response with a 200 status. We repeated this with 20 accounts. All 20 behaved the same way. The idle timeout existed in the application layer, but something in front of it was refreshing the token on every request, including background calls from an open tab.

Tracing the calls#

We attached a proxy and watched the traffic. Every 45 seconds, a small JavaScript heartbeat hit /api/v1/session/ping. The application treated that ping as activity and reset the idle timer. So far, that is a design choice, not a flaw. The flaw showed up when we hit logout. The client sent POST /auth/logout, the application responded with Set-Cookie: session=; Max-Age=0, and the reverse proxy stripped that header because the upstream was configured to rewrite all Set-Cookie attributes for domain consistency. The browser never saw the deletion. The cookie stayed in the jar, and the proxy kept accepting it because the token itself had no server-side revocation record.

We confirmed this with a simple test: capture the cookie value, log out through the UI, then replay the captured request from curl. It returned 200 with full account data. That is the field evidence. The token was valid until its cryptographic expiry, which was set to 30 days.

The root cause in one sentence#

The session had no server-side revocation, and the logout response never reached the browser because the proxy rewrote the cookie attributes. Two independent failures stacked: one in token design, one in proxy configuration. Either alone would have been survivable. Together they produced sessions that outlived the user's intent to end them.

Why the idle timeout did not save anyone#

The 30-minute idle timer lived in application memory. It reset on any authenticated request, including the heartbeat. It was never persisted, so a mid-tier restart cleared it without invalidating tokens. We tested that too: restart the app tier, replay an old cookie, and the session came back with a fresh timer. The documentation said "30-minute idle timeout." The implementation said "30 minutes of silence, and silence is rare when a tab is open."

What we recommend checking#

  1. Replay test after logout. Capture a session cookie, log out through the UI, and replay the request from a separate client. If it returns 200, the session is not revoked.
  2. Inspect Set-Cookie on the wire. Use browser dev tools or a proxy to confirm that the logout response actually carries a deletion directive to the client. If a proxy rewrites cookie attributes, verify that it preserves Max-Age=0 and Expires in the past.
  3. Check server-side session state. A token that is only validated by signature has no revocation path. Look for a token blocklist, a session store, or short-lived access tokens paired with refresh rotation.
  4. Test a tier restart. Restart the application tier and replay a cookie captured before the restart. If it still works, the idle timer is in memory only.
  5. Measure the heartbeat. Find every endpoint that resets the idle timer. Background pings, analytics calls, and polling endpoints should not count as user activity.

What the vendor changed#

After we reported it, the vendor added a server-side session record with a revocation flag and moved the idle timer into the same store. They also changed the proxy rule to pass Set-Cookie through unchanged for the auth path. The replay test now returns 401 after logout. The fix took nine days from report to deploy, which is fast for a change that touches session storage.

The general lesson#

Session bugs are rarely in the login form. They live in the seams between layers: the proxy that rewrites headers, the app tier that keeps state in memory, the client that pings on a timer. When you test authentication, do not stop at "can I log in." Test "can I log out, and does the server agree." That second question is where the interesting failures are.

More articles