Weak Session ID Implementation - No Session change on Password change
The application does not change the session identifier after a user changes their password. An attacker who already has a valid session (for example, after guessing the password) retains access to the account even after the victim changes the password.
Originally disclosed on HackerOne
- Fixed in 7 days
- Paid in 7 days
- Disclosed after 7 days
Summary: [Weak session id implementation]
Description: [Unikrn does not change session id after password is changed. Reusing same session ids, after password is changed is highly risky. Example scenario: Hacker has successfully brute forced the password of a victim and has access to the account. The victim notices that something's off and chooses to change the password of the account. Hacker has still full access to the account, even after the password is changed, because of the working session id that he got from the server when he logged in to the victim's account.]
Steps To Reproduce:
(Add details for how we can reproduce the issue)
- [Intercept requests when logged in to unikrn and retrieve current session id]
- [Change the password of the user]
- [Do the step 1 again and compare the session id]
Supporting Material/References:
If necessary, check my Proof of Concept video.
https://drive.google.com/file/d/0B28KqsVY5jK6aVdTYzg5RTNMcGM/view
Context
Unikrn is a betting platform reachable at unikrn.com. Like most authenticated web applications, it issues a session identifier to a user when they log in and uses that identifier to associate subsequent requests with the account. A standard expectation for such a design is that the session identifier is rotated whenever the credential that protects the account changes, so that any session established with the old password stops being usable.
This report is about that expectation not being met: after a user changes their password, the session identifier issued at login stays the same and keeps working.
Setup
The report does not describe any special accounts, roles, tools or versions. The only precondition is an authenticated session on Unikrn and the ability to intercept the traffic between the browser and the server, since the reproduction steps are built around reading the session identifier out of requests.
Finding it
The researcher observed that Unikrn does not change the session identifier after the password is changed. Reusing the same session identifiers after a password change is, in the researcher's words, highly risky.
The reasoning is straightforward: the session identifier is the thing that actually authenticates each request, and the password is only the means of obtaining it. If a password change leaves existing session identifiers valid, then changing the password does not revoke access for anyone who already holds one.
Exploitation
The report frames the issue with a concrete scenario rather than a single request/response pair.
Scenario: attacker already holds a session
A hacker has successfully brute forced the password of a victim and has access to the account. The victim notices that something is off and chooses to change the password of the account. The hacker still has full access to the account, even after the password is changed, because of the working session identifier that he got from the server when he logged in to the victim's account.
The point of the scenario is that the victim's natural remediation step, changing the password, does not evict the attacker. The attacker's session was created with the old password but is not tied to it.
Step 1: capture the current session identifier
Intercept requests when logged in to Unikrn and retrieve the current session identifier.
This establishes the baseline value that the rest of the test compares against.
Step 2: change the password
Change the password of the user.
This is the action that a user would expect to invalidate other sessions, or at least the session under which the change was made.
Step 3: compare the session identifier
Do step 1 again and compare the session identifier.
If the value retrieved after the password change is the same as the value retrieved before it, the session was not rotated. That is the observation the report is built on.
The report does not include the raw requests, headers, cookie names or server responses for these steps; it only describes them. A proof of concept video is referenced as supporting material:
https://drive.google.com/file/d/0B28KqsVY5jK6aVdTYzg5RTNMcGM/view
Root cause
The application keeps the same session identifier across a password change instead of issuing a new one. In practice this means the server-side session record created at login is not invalidated or replaced when the credential changes, so possession of the identifier alone continues to authorise requests. The report does not describe the implementation, so the exact mechanism is not stated; likely the password change handler simply updates the stored password without touching the session store or the session cookie.
No defence in the flow stopped it: the password change succeeded, but nothing in that operation revoked the existing session.
Impact
Anyone who already holds a valid session identifier for an account keeps full access to that account after the legitimate user changes the password. The report's example is an attacker who obtained the password by brute force and logged in; the victim's password change does not remove the attacker.
The impact depends on the attacker having a working session identifier in the first place, which in the report's scenario comes from a successful brute force of the password. The report does not discuss other ways an identifier might be obtained.
Fix
The fix implied by the finding is to rotate the session identifier on password change and invalidate the previous session, so that sessions established under the old password stop working.
Variants to test
- Change the password in one browser and keep a second logged-in session open. A positive result is that the second session continues to work with its original identifier.
- Capture the session identifier before and after the password change and compare them byte for byte. A positive result is an identical value.
- Repeat the comparison for other credential-affecting actions, such as email address changes, where the report's logic would apply equally. A positive result is again an unchanged identifier.
- Log in as the victim from a second client, change the password from the first, then replay a request from the second using the old identifier. A positive result is a successful authenticated response.
Hunting notes
This kind of bug hides in account settings flows: password change, email change and any other action that a user would treat as a security reset. During recon, the signal is a session cookie whose value does not change after such an action; comparing the cookie before and after is enough to spot it. The researcher illustrated impact with a scenario in which an attacker who already holds a session keeps access after the victim changes the password. The report was rated medium severity and paid a 40.00 USD bounty.
What happened, in plain words
Unikrn is a betting website at unikrn.com. When you log in to a website like this, the server needs a way to remember that you are you on every following page you open. It does that by handing your browser a small piece of text called a session identifier (often shortened to session ID). Your browser sends that identifier back with every request, and the server uses it to look up your account. Think of it like a cloakroom ticket: you hand in your coat, you get a numbered ticket, and from then on the ticket is what gets your coat back. The password is only used once, at the door, to get the ticket.
Because the ticket is what actually opens the door, it matters a lot what happens to old tickets when you change your password. The normal, safe behaviour is that changing the password should cancel every existing ticket, so anyone holding an old one is locked out. On Unikrn, that did not happen: after a password change, the session identifier stayed exactly the same and kept working.
The researcher gave an example scenario. A hacker brute forces a victim's password, logs in, and gets a session identifier. The victim notices something is wrong and changes the password, expecting that to kick the attacker out. It does not: the attacker's session identifier still works, so the attacker keeps full access to the account.
This kind of weakness is classed as Insufficient Session Expiration: old sessions are not ended when they should be. The report was rated medium severity and paid a 40.00 USD bounty.
Background you need first
A few ideas come up again and again below, so here they are from zero.
- Request and response. When you click a link or submit a form, your browser sends a request to a server, and the server sends back a response (the page, or a redirect, or an error). Every interaction on the web is made of these two things.
- Cookie. A cookie is a small label that a website asks your browser to store and to attach to every later request to that site. It is how a website recognises you between page loads, because the web itself has no memory.
- Session identifier (session ID). A long random-looking value stored in a cookie (or sometimes sent another way) that stands in for your login. The server keeps a record that says "this identifier belongs to this account". Anyone who has the identifier can act as that account until the server throws the record away.
- Session rotation. Replacing the session identifier with a fresh one at a sensitive moment, such as login or a password change, and invalidating the old one. It is the web equivalent of changing the locks when you move into a new house.
- Intercepting traffic. Using a tool that sits between your browser and the server so you can read and edit the requests and responses. Browser developer tools (usually opened with F12) can show this, and dedicated proxy tools do the same job with more control. The report does not name any particular tool.
- API. A way for software to talk to other software using defined requests, rather than a human clicking pages. The report does not mention an API; the steps work through ordinary browser traffic.
The setup
The only things you need are a logged-in session on Unikrn and the ability to intercept the traffic between your browser and the server, because the reproduction steps are built around reading the session identifier out of requests.
Finding it
The researcher observed that Unikrn does not change the session identifier after the password is changed. In the researcher's words, reusing the same session identifiers after a password change is highly risky.
The reasoning is simple once you separate the two things involved. The session identifier is what actually authenticates each request; the password is only the means of obtaining that identifier in the first place. If a password change leaves existing session identifiers valid, then changing the password does not revoke access for anyone who already holds one. Going back to the cloakroom: changing the password is like telling the attendant your name again, but the old numbered tickets still work at the counter.
Exploitation
The report frames the issue with a concrete scenario rather than a single request and response pair.
Scenario: the attacker already holds a session
A hacker has successfully brute forced the password of a victim and has access to the account. The victim notices that something is off and chooses to change the password of the account. The hacker still has full access to the account, even after the password is changed, because of the working session identifier that he got from the server when he logged in to the victim's account.
The point of the scenario is that the victim's natural repair step, changing the password, does not evict the attacker. The attacker's session was created with the old password but is not tied to it.
Step 1: capture the current session identifier
Intercept requests when logged in to Unikrn and retrieve the current session identifier.
Why this step: you need a known starting value to compare against later. Without a "before" reading, there is nothing to compare the "after" reading to. In practice you would open the developer tools or a proxy, load a page while logged in, and look at the request headers to find the cookie carrying the session identifier.
Step 2: change the password
Change the password of the user.
Why this step: this is the action a user would expect to invalidate other sessions, or at least the session under which the change was made. It is the moment where the safe behaviour (a new identifier, old one dead) should kick in.
Step 3: compare the session identifier
Do step 1 again and compare the session identifier.
Why this step: if the value retrieved after the password change is the same as the value retrieved before it, the session was not rotated. That is the observation the report is built on. If the value had changed, the old identifier would no longer work and the issue would not exist.
The report does not include the raw requests, headers, cookie names or server responses for these steps; it only describes them. A proof of concept video is referenced as supporting material:
https://drive.google.com/file/d/0B28KqsVY5jK6aVdTYzg5RTNMcGM/view
This is a single link to a video hosted on Google Drive. It is not a request or a command; it is where the researcher put a recording of the steps above being carried out. The report gives no further detail about what the video shows beyond that it is the proof of concept.
Root cause
The application keeps the same session identifier across a password change instead of issuing a new one. In practice this means the server-side session record created at login is not invalidated or replaced when the credential changes, so possession of the identifier alone continues to authorise requests.
A likely explanation is that the password change handler simply updates the stored password without touching the session store or the session cookie. Nothing in the flow stopped it: the password change succeeded, but nothing in that operation revoked the existing session.
Impact
Anyone who already holds a valid session identifier for an account keeps full access to that account after the legitimate user changes the password. The report's example is an attacker who obtained the password by brute force and logged in; the victim's password change does not remove the attacker.
The impact depends on the attacker having a working session identifier in the first place, which in the report's scenario comes from a successful brute force of the password. The report does not discuss other ways an identifier might be obtained.
Fix
The fix implied by the finding is to rotate the session identifier on password change and invalidate the previous session, so that sessions established under the old password stop working. In cloakroom terms: when the password changes, the attendant tears up every old ticket and hands out new ones.
Variants to test
These are follow-up checks in the same spirit, useful if you want to look for the same weakness elsewhere.
- Change the password in one browser and keep a second logged-in session open. A positive result is that the second session continues to work with its original identifier.
- Capture the session identifier before and after the password change and compare them byte for byte. A positive result is an identical value.
- Repeat the comparison for other credential-affecting actions, such as email address changes, where the report's logic would apply equally. A positive result is again an unchanged identifier.
- Log in as the victim from a second client, change the password from the first, then replay a request from the second using the old identifier. A positive result is a successful authenticated response.
Hunting notes
This kind of bug hides in account settings flows: password change, email change and any other action that a user would treat as a security reset. During recon, the signal is a session cookie whose value does not change after such an action; comparing the cookie before and after is enough to spot it. The researcher illustrated impact with a scenario in which an attacker who already holds a session keeps access after the victim changes the password.
Glossary
- Session identifier (session ID): a long random value the server gives your browser after login and uses to recognise your account on later requests.
- Cookie: a small piece of data a website stores in your browser and receives back with each request, commonly used to carry the session identifier.
- Session: the server-side record that ties a session identifier to a logged-in account.
- Session rotation: replacing the session identifier with a new one and invalidating the old one, typically at login or after a password change.
- Insufficient Session Expiration: a weakness where old sessions are not ended when they should be, so they keep working longer than intended.
- Brute force: guessing a password by trying many combinations until one works.
- Account takeover: an attacker gaining and keeping control of someone else's account.
- Request: a message your browser sends to a server asking for a page or an action.
- Response: the message the server sends back.
- Header: a labelled line of extra information attached to a request or response, such as which cookies are being sent.
- Intercepting traffic: capturing the requests and responses between your browser and a server so you can read or change them.
- Proxy: a tool that sits between your browser and the server and lets you inspect and modify the traffic.
- API: a defined way for software to make requests to other software, as opposed to a person clicking through pages.
- Recon: the early, exploratory phase of security testing where you look at how a site behaves and collect clues.
- Proof of concept (PoC): a demonstration, often a video or a set of steps, showing that a weakness really works.
- Severity: a rating of how serious a finding is; this one was rated medium.
- Bounty: a payment made to a researcher for reporting a valid security issue.