CS 360 — Password Storage, Session Cookies, Third-Party Tracking, Same-Origin Policy & CORS
Enter the demo folder: cd auth-demo
Run both servers: ./run.sh
Open http://localhost:5050 — main app on port 5050, third-party server on port 5051
auth_demo.db is created automatically.
Use the Reset Database button in Step 2 to clear all users between demos.
Choose a hashing scheme, then register. See exactly what gets stored.
What actually gets persisted. Note how MD5 users with the same password have identical hashes.
| # | Username | Scheme | Salt | Stored Hash |
|---|---|---|---|---|
| No users yet. Register some above. | ||||
Verify a password against the stored hash. On success, the server sets a session cookie.
Precomputed lookup tables instantly reverse unsalted MD5 hashes for common passwords.
Paste any MD5 hash (copy one from the Database table above, or use an MD5 user's hash).
Attacks every MD5 account in the database simultaneously. SHA-256 + salted accounts are immune because each salt would require its own table.
After login, the server sets a session cookie. See what the browser sends on each request.
Set-Cookie: session_token=<token>.
The browser attaches this cookie to every request to the same origin — no password re-entry needed.
The server stores each session token → username mapping. This is what gets looked up on every request.
| Username | Session Token | Created |
|---|---|---|
| No sessions yet. | ||
View, create, and experiment with cookie security attributes.
Only non-HttpOnly cookies are visible to JavaScript. HttpOnly cookies are hidden here but still sent by the browser.
| Name | Value | Actions |
|---|
See how a different origin (port 5051) sets tracking cookies while you're on port 5050.
https://cs360umass.org, but resources from https://tp.cs360umass.org can set their own cookies.
Ad networks use this to track you across sites. Modern browsers increasingly block these.
A 1×1 transparent GIF loaded from https://tp.cs360umass.org/pixel.gif.
The third-party server sets a tracking_id cookie when delivering it.
An iframe loading https://tp.cs360umass.org/embed.
It sets its own cookies — visible inside the iframe but not to your JS on :5050.
document.cookie only shows cookies
for this origin (:5050). The tracking cookies from :5051 are invisible to your JavaScript.
Check DevTools → Application → Cookies → https://tp.cs360umass.org to see them.
The browser's most important security boundary — and the standard mechanism to relax it.
localhost:5050 and
localhost:5051 are different origins.
Access-Control-Allow-Origin in the response, the third-party server
tells the browser "I trust this other origin to read my data."
| URL A | URL B | Same Origin? | Why? |
|---|---|---|---|
| https://cs360umass.org/a | https://cs360umass.org/b | Yes | Same scheme, host, port |
| https://cs360umass.org | https://tp.cs360umass.org | No | Different origin |
| http://example.com | https://example.com | No | Different scheme |
| http://example.com | http://api.example.com | No | Different host |
Same origin — always works, no CORS needed.
Fetches from https://tp.cs360umass.org/api/no-cors. No Access-Control-Allow-Origin header
→ browser blocks your JS from reading the response.
The request STILL reaches the server! SOP blocks reading the response, not sending the request.
The server on https://tp.cs360umass.org includes Access-Control-Allow-Origin: https://cs360umass.org — the browser lets your JS read the data.
Cross-origin fetch() does NOT send cookies by default. You need
credentials: 'include' AND the server must respond with
Access-Control-Allow-Credentials: true (and must NOT use wildcard *).