Browser credential storage boundaries
Separate page lifetime, origin storage, and browser-attached session state before choosing a sign-out or credential-storage design.
Predict first
Before you read: predict
A results page's own script set a harmless page-global marker and a harmless localStorage marker; the page also has an HttpOnly session cookie. A separate in-page diagnostic script reads those browser-visible places and makes no request.
Which report is observed?
The 30-second version
Start with the boundary that holds a value and the component that must use it. Page globals, origin storage and browser session state have different lifetimes and readers. HttpOnly changes cookie access, not every response body. Treat cleanup as separate state transitions, then verify the specific browser observation.
Separate page lifetime, origin storage, and browser-attached session state before choosing a sign-out or credential-storage design.
How it works
Step 1 of 9
In the kitchen
- fresh apartment note → page global (step 1)
Analogy: An apartment concierge
Each apartment visit gets a fresh note; the building keeps a tenant noticeboard. The concierge uses a master key for service, but residents never see it. Erasing a noticeboard entry does not void the master key.
| Apartment detail | Browser boundary |
|---|---|
| fresh apartment note | page global (step 1) |
| tenant noticeboard | localStorage (step 2) |
| master key unseen by residents | HttpOnly cookie (step 4) |
| concierge service order | browser request attachment (step 5) |
| erase noticeboard entry; master-key service permission remains | local cleanup is independent of cookie (step 7) |
Breaks down when: the concierge suggests request safety. Cookie attributes, intent validation, and XSS controls are separate.
Examples, run for real
4.1 ExamHall: keep interface preferences separate from credentials
EXH-1920 is a synthetic browser-storage case: a results reviewer had used durable origin storage for a credential. MR !2120 changes the storage contract so that JavaScript stores harmless interface preferences. The browser session and any server-held upstream credential have separate responsibilities. This is a placement decision, not proof that a complete production authentication system is secure. OWASP
In the executed preference fixture, the page stores export format csv and theme lime, then overwrites export format with json. It retains two entries rather than appending another entry for the changed format. The theme survives because it has a different key. These are non-secret preferences, not session markers. MDN
preference overwrite: format=json theme=lime entries=2
The observation establishes a specific key/value operation. It does not make localStorage a safe credential vault. The application must first classify the value: a layout preference can tolerate disclosure under a different policy from a value that authorizes account access. A short-lived copy still needs that classification; lifetime and readability answer different questions. OWASP
4.2 Payments preferences: the origin is part of the storage boundary
The same Chromium context visits a second fixture origin on another loopback port. That document initially has no theme entry. It stores lavender under the same key, while the original origin still reads lime. Both observations run in real pages; the script compares values and never uses a timeout to decide the result. MDN
different-origin preference: initial=null own=lavender original=lime
The two equal key names do not identify one shared entry across different origins. Conversely, creating another document within the same origin does not by itself create a separate localStorage namespace. Document lifetime and origin identity must be reasoned about separately. This example changes origin; it does not establish a cookie sending policy, which belongs to the linked cookie pack. MDN
Their scope is deliberately small: they exercise preference replacement and origin separation. They do not implement session revocation, validate an identity provider, or claim that removing a browser cookie invalidates a server-side record. The marker-based assessment laboratory separately tests the stated placement and request boundaries. Internet-Draft
Try it
Answer first, then check. Nothing is saved.
Question 1 of 4
A ledger page has an HttpOnly session. Its release writes the harmless marker credential-marker to localStorage, then makes a normal request.
Which inventory follows?
Question 2 of 4
A catalog page holds harmless markers in page memory and localStorage, plus an HttpOnly session. Its script deletes the page-global marker and makes a normal request.
Which inventory follows?
Question 3 of 4
Two same-origin ticket tabs start with a harmless credential-marker, a page-global marker, and a badge that reports the local marker. A cleanup click runs one candidate handler in the first tab.
Which handler uses the correct browser boundaries?
Question 4 of 4
A payments page calls its local BFF with an opaque HttpOnly session. This harmless fixture then receives {"ok":true,"marker":"harmless-upstream-marker"} from the BFF; page code makes no storage write.
Why can page script read body.marker?
Go deeper
Pro tip
Write sign-out acceptance tests as separate browser-boundary observations, then record which server response each transition actually received. OWASP distinguishes session identifiers from UI preferences (OWASP).
Source
MDN Window, fetched 2026-09-30;
sources/mdn-window.txt, SHA-256bd70c8c3595d564d82339188b435ed7cf414cf9961bf115b0faae8e69fd49234. Each tab has its own Window object and page globals belong to that window.MDN Set-Cookie, fetched 2026-09-30;
sources/mdn-set-cookie.txt, SHA-256bceeea4b95f09f159b4a04fe0cc5ab449e3f967c6a5270e7e6162a63c9e03e1d. HttpOnly and request attachment.MDN Window.localStorage, fetched 2026-09-30;
sources/mdn-localstorage.txt, SHA-256ef7d14b9ec8b41de5b7f483d8439282b0c896bcc885d99190a19a2fda2b11059. It defines localStorage as storage for a document's origin and says stored data survives browser sessions; supports the reload/tab lifecycle and origin-state claims.MDN Window.storage event, fetched 2026-09-30;
sources/mdn-storage-event.txt, SHA-25685c410d8819a6fff845e31557638cb4b07c3ee7ea504f920d6c2c2f5405ea725. It says the event is not fired on the changing window and, for localStorage, is fired in other same-origin browsing contexts including tabs; supports step 8.IETF Internet-Draft: OAuth browser-based applications, fetched 2026-09-30;
sources/oauth-browser-apps.txt, SHA-256d11c55b562dd45a4626262cdf0e995b0c7ca1745520b332a61fb30b3d6ff29e1. BFF boundary context for D2.OWASP HTML5 Security Cheat Sheet, fetched 2026-09-30;
sources/owasp-html5.txt, SHA-2563dea81c2a1671302966042452a2bbfd3622e40b226126eb49b423cdd6162804b. Local-storage warning.