Web app persistence: sessions, keys, hooks
Brief
Persistence in a web application is anything that keeps working after the user changes a password or is disabled: a session, a refresh token, an API key, an OAuth grant, an admin invite, a webhook or an uploaded file the server will execute. Each is checked with an object created for the test, and each check ends by deleting that object.
On this page
- Check first
- Do sessions survive a password change?
- Do refresh tokens outlive a password change or a logout?
- Do API keys and OAuth grants outlive the user?
- What can a user create that keeps acting after they leave?
- Do uploaded files execute?
- The defender sees
- Done when
- Not covered
- Tools
- Related research
- Reviewed
- Situation
- Test accounts in a tenant we created on an application named in the scope letter, an intercepting proxy, and admin rights in that test tenant so we can disable our own user. Everything created on this page carries the test's name and is removed in the same hour; no key, hook or file is ever pointed at a real customer's tenant.
- Goal
- A persistence table: for each object type, whether it outlived the password change or the disabled user, the test object's id, and when it was removed.
- Outputs
- Captured on 4 Nov 2026 against the Atarus Bench Web and API lab fixture, edition
web-api-0.2, running on loopback, with one origin playing every host, renamed to the example domains and printed ashttps(the lab ran plainhttp). The password change, the disable and every removal on this page ran in the same capture.
Check first
- The route list from the first hour, with every route that mints something: sessions, tokens, keys, invites, webhooks, uploads.
- Two test users in our own tenant, one a tenant admin, so the password change and the disable happen to our own accounts.
- A proxy capturing every response from the first login, because the tokens we replay later are issued now.
- A host we control for webhook deliveries.
- The client's written answer to one question: what is revoked when a user changes a password, and when a user is disabled.
Steps
Do sessions survive a password change?
# tester-a is signed in twice: in the browser and in this shell. The browser changes the password.
curl -s -w '\n%{http_code}\n' -b "session=$OLD_SESSION_A" https://app.example.com/api/me
Expected output
{"id":"u_test_a","email":"tester-a@test.example","display_name":"tester a","role":"member","email_verified":false,"org":"org_test_a"}
200 # <- a session issued before the password change still answers
The second session is the one an attacker would hold. A password change that leaves it alive is the gap the Microsoft 365 token replay campaign was built to survive; the same check applies to any "sign out everywhere" button. Read the body, not only the status, since single page apps answer 200 with their own shell.
Negative result. A 401, or a 200 whose body is the login page. Check the idle and absolute lifetimes too.
Fix. Keep a session version on the user record, bump it on password change, disable and "sign out everywhere", and reject any session whose version is behind. Give sessions an absolute lifetime as well as an idle one.
Do refresh tokens outlive a password change or a logout?
curl -s -X POST https://app.example.com/oauth/token -d grant_type=refresh_token -d client_id=web-spa \
-d "refresh_token=$OLD_REFRESH_A" | jq -c '.access_token = "<redacted>" | .refresh_token = "<redacted>"'
Expected output
{"access_token":"<redacted>","token_type":"Bearer","expires_in":3600,"refresh_token":"<redacted>"} # <- a fresh hour of access after the password changed
OLD_REFRESH_A is the refresh token minted before the password change, and the jq filter masks both token values before the response is saved, so the evidence keeps the shape and never the values. Send the old refresh token once after the password change and once after a logout. Then send one refresh token twice in a row: with rotation and reuse detection, the second use is refused and the active refresh token revoked, as RFC 9700 describes. A token that works through all three outlasts every control the user can see.
Negative result. invalid_grant on the first replay after the change and on the second use of a rotated token. Note the refresh token's expiry as well.
Fix. Rotate refresh tokens on every use, revoke the family when a rotated token is presented twice, revoke them all on password change and logout, and expire them after a period of inactivity.
Do API keys and OAuth grants outlive the user?
# key named ATARUS-TEST-2026-10-27, created by tester-a; tester-a is then disabled by the tenant admin
curl -s -o /dev/null -w '%{http_code}\n' -H "Authorization: Bearer $KEY_ATARUS_TEST" https://app.example.com/api/v1/projects
curl -s -H "Authorization: Bearer $TOKEN_ADMIN" https://app.example.com/api/v1/tenant/api-keys | grep -c ATARUS-TEST
Expected output
200 # <- the key still works after its owner was disabled
0 # <- and the tenant admin's key list does not show it
A key a user can mint in a settings page is a credential with no MFA, often no expiry and no owner once that user is gone. The same check runs for third party OAuth grants: list them, disable the user, see whether the grant's token still answers. The analytics vendor breach is what a surviving grant looks like from the customer's side. Delete the key when the row is written.
Negative result. 401 after the disable, and the key visible in the admin's list before it. A key with no expiry is still a note in the report.
Fix. Tie every key and grant to its owner's status, give keys an expiry and a scope, list and revoke them from the tenant admin view, and write their creation, use and revocation to the audit log.
What can a user create that keeps acting after they leave?
curl -s -w '\n%{http_code}\n' -X POST https://app.example.com/api/webhooks \
-H "Authorization: Bearer $TOKEN_A" -H 'Content-Type: application/json' \
-d '{"url":"https://hooks.tester.example/atarus-test-2026-10-27","events":["user.created","invoice.paid"]}'
Expected output
{"id":"whk_test_0192","url":"https://hooks.tester.example/atarus-test-2026-10-27","created_by":"u_test_a","verified":false} # <- a member can point tenant events at any host
201
A webhook sends the tenant's events to a host the creator chose; an admin invite adds an account that answers to nobody once the inviter leaves. For each, record who may create it, whether a second admin approves it, whether the destination is checked, and whether it outlives the creator's disable. The invite goes to atarus-test-admin@tester.example, and both objects are deleted the same hour.
Negative result. Webhooks limited to admins with destination verification, invites that need a second admin, and both ending with the creator.
Fix. Require admin rights and a second approval for new admins and new webhook destinations, sign deliveries, disable hooks and invites with their creator, and alert on each creation.
Do uploaded files execute?
printf 'ATARUS-TEST-2026-10-27 plain text, no code\n' > atarus-test.php
curl -s -w '\n' -F "file=@atarus-test.php" -H "Authorization: Bearer $TOKEN_A" https://app.example.com/api/uploads
curl -s -D - https://app.example.com/uploads/atarus-test.php
Expected output
{"id":"upl_test_0417","url":"/uploads/atarus-test.php"}
HTTP/1.1 200 OK
Server: nginx/1.18.0
Content-Type: text/html; charset=UTF-8 # <- served through the script handler, not as a download
Content-Length: 43
X-Powered-By: Express
ATARUS-TEST-2026-10-27 plain text, no code
The file holds no code. If the server hands it to a script handler, the handler prints the text unchanged and the response says text/html with no Content-Disposition, so the extension reached an interpreter with no code run. A stored file survives every password change in the tenant. Delete the upload through the app and confirm the URL is gone.
Negative result. The upload refused, renamed to a random name with the extension dropped, or served with Content-Disposition: attachment and application/octet-stream from another origin.
Fix. Store uploads outside the web root or in object storage under random names, allow-list extensions and content types, serve them as attachments from a separate origin with X-Content-Type-Options: nosniff, and give the upload path no execute permission.
The defender sees
The replayed session is a request carrying a session id issued before the password change event for the same user, visible in any log that records session id, user and issue time. The refresh replay shows as a token request after the change, and as a reuse detection event where rotation is on. The key, the webhook and the invite each show as an audit log entry carrying the marker name, with a second entry for the deletion, and the key's one use shows against its id after the owner's disable event. The upload shows as an accepted file with its original name and content type, and the request for it as a hit on the uploads path served as text/html. If the client finds the marker on every row of our table, revocation is a design gap, not a logging one; a row with no entry is a finding of its own.
Done when
Every row has a result with the request and response, every test object has been deleted and its id recorded, and the client has been asked to find each creation and deletion in the application's audit log.
Not covered
Getting into the account in the first place, which the authentication page covers, and persistence in the cloud account or on the server underneath the app.