Skip to content
Account takeover Write-up Advanced

The Incomplete Fix: How a Critical Auth Vulnerability’s Patch Left a Second Door Open

The session-update endpoint accepted client-supplied identity fields, including the email address, and wrote them into the signed session token without validation. An attacker could forge their session's email and a newer-format profile identifier so the server rebuilt the token with the victim's organization context, including the owner role.

CypherNova1337 Follow

Published on cyphernova1337.medium.com

Hacking

CypherNova1337, on cyphernova1337.medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

The case involves an application whose session system had an update endpoint. When a user updates their session, the server accepts identity fields from the client, including the email address, and writes them into the signed session token without validation. Later, when resolving the user, the server looks the user up by the email carried in the token.

The profile identifier used in that resolution had two formats: a legacy, user-scoped ID, and a newer organization-profile identifier with a different prefix, introduced around the same time as the fix for the original bug. The article deliberately generalises the details: no names, no identifiers and no reproduction steps are published. The vulnerability was reported privately to the vendor before the write-up.

Setup

The write-up does not describe accounts, tooling or versions. The work was code reading rather than fuzzing: the researcher read the public advisory, found the patched function, and audited the patch. The whole hunt is described as hours, not weeks.

Finding it

The starting point was the original vulnerability. The session system had an update endpoint that accepted identity fields from the client, including the email address, and wrote them into the signed session token without validation. When resolving the user, the server looked the user up by the token's email. The exploit was one request: set your session's email to the victim's address, and every subsequent request was resolved as the victim. That is full account takeover, and no second factor stops it, because the compromise happens after authentication, at the session layer.

The fix added an authorization gate when resolving a user from a session token: if the token points at another user's profile, verify that the requester is an organization admin with authority over that user. Otherwise, refuse, log the attempt, and move on.

What the researcher noticed was that the gate was added to the legacy format's branch only. The newer format's branch, added during the same era as the patch, performed a bare database lookup: find the profile with this identifier, return it. No ownership check. The function even received the requesting user's ID as a parameter, and the new branch simply never used it. Separately, the session-update trust at the root of the original bug was never actually removed: the callback still copied client-supplied identity fields into the token.

Exploitation

Step 1: forge identity fields in a session update

Because the session-update callback still copied client-supplied identity fields into the token, an attacker could submit a forged email address and a forged newer-format profile identifier in a single session update. The write-up does not publish the request itself; it describes the two forged values only.

Step 2: let the server rebuild the token

The server's own rebuild logic then did the rest. It looked up the victim by the forged email, fetched the organization profile the attacker pointed at, and reconstructed the session token with the victim's organization context, including the victim's membership role. In the demonstration, that role was the organization owner.

Step 3: use the resulting session

The attacker's session became an owner session for a victim's organization, while the underlying user ID stayed their own. The victim's organization settings, members and data were then scoped to an attacker-controlled session. One request was enough.

Root cause

The root cause is a design pattern, not a typo. Authorization logic was added to one lookup format and not its sibling, because the two formats lived in the same function and the developer, reasonably, patched the branch they were told was vulnerable. Nobody re-read the whole function after the patch, and nobody asked whether there were other paths that resolve identity.

The gate only covered the legacy branch, and the trust in client-supplied identity fields at the session-update layer was never removed. The email-keyed lookup is what let the forged value propagate into the rebuilt token.

This is the incomplete-fix pattern, and the write-up lists familiar examples:

  • The SSRF guard that validates the URL but not the redirect targets
  • The file-upload filter that checks extensions but not content types
  • The parser that rejects one encoding but not the double-encoded form
  • The lookup function that gates one identifier format but not the other

Impact

An attacker could turn their own session into an owner session for a victim's organization, with the underlying user ID remaining their own. The victim's organization settings, members and data become scoped to an attacker-controlled session. The compromise happens after authentication, at the session layer, so a second factor does not stop it. In the demonstration, the role was the organization owner.

Fix

The write-up does not say what the vendor changed. It sets out what defenders should do:

  1. When a fix adds an authorization gate, audit every sibling path in the same function. If the function has two lookup formats, both need the gate. Better: route them through one shared, gated resolution function so the check cannot be missed by construction.
  2. Identity fields must never be client-writable. A session update endpoint should whitelist exactly the fields it exists to change (locale, preferences) and reject identity fields outright. If the field cannot be submitted, it cannot be forged.
  3. Look up identity by immutable subject identifiers, never by user-mutable attributes. The email-keyed lookup is what let the forged value propagate.
  4. Regression tests should assert the negative case: a session update with a foreign email or profile pointer must not change the session's organization, profile or role. Test the attack, not the feature.
  5. When a new identifier format is introduced next to a legacy one, treat the new branch as unreviewed attack surface, because in practice that is exactly what it is.

Variants to test

The fix-diff methodology is the transferable technique: read public advisories, find the fix commit, and audit the patch rather than the vulnerability. The patch tells you exactly which checks were added; then ask what the checks do not cover: the sibling branch, the alternate format, the second encoding, the other caller.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 16 min read.

What happened, in plain words

A website had a serious session problem. Once you were logged in, the site kept a small piece of information about you, called a session token, so it could remember who you were on every later page you opened. The site also let you update that session, and when it did, it trusted identity fields your browser sent, including the email address. The server then used that email to decide whose account you were. So if you changed the email in your session to someone else's address, the site started treating you as that person. That is a full account takeover: you become another user without knowing their password.

The developers fixed it. When the server looked up a user from a session token, it now checked whether the token pointed at someone else's profile, and if so, it only allowed the request when the requester was an organisation admin with authority over that user. Otherwise it refused and logged the attempt. That sounds complete.

It was not. The profile identifier, the label the site uses to find a profile, came in two formats: an older one tied to a single user, and a newer one tied to an organisation profile, with a different prefix. The new check was added only to the older format's branch of the code. The newer branch just looked the profile up in the database and returned it, with no ownership check at all. The function even received the requesting user's ID as an argument, and the new branch never used it. On top of that, the original trust problem was never removed: the session update still copied identity fields sent by the browser into the token.

Put those two halves together and one request is enough. Send a forged email and a forged newer-format profile identifier in a single session update. The server looks up the victim by the forged email, fetches the organisation profile the attacker pointed at, and rebuilds the session token with the victim's organisation context, including the victim's membership role. In the demonstration that role was the organisation owner. The attacker's session becomes an owner session for the victim's organisation, while the underlying user ID stays the attacker's own.

The researcher found this by reading code, not by running automated attack tools. The method: read the public security advisory, find the patch that fixed the original bug, and audit the patch itself. The patch shows exactly which checks were added, and then you ask what those checks do not cover. The whole hunt took hours, not weeks.

The write-up deliberately leaves out names, identifiers and reproduction steps. The vulnerability was reported privately to the vendor before the article appeared. What follows is the shape of the bug, which is the lesson.

The pieces you need to know first

Before the details make sense, here are the basic ideas, explained from zero.

  • A web application is a program you use through your browser. You type an address, the browser asks a server for pages and data, and the server sends them back. You never see the server itself, only what it sends.
  • An API is the part of a web application that accepts requests and returns data rather than whole web pages. Think of a restaurant: the menu and the dining room are the website you see, and the kitchen is the API. You place an order (a request), the kitchen prepares it, and a waiter brings back a result (a response). You do not walk into the kitchen yourself.
  • An endpoint is one specific address inside that API where a particular action happens, like a counter in the restaurant for one kind of order. The session update endpoint is the counter where you change details about your current session.
  • A session is the site's memory of you while you are logged in. When you log in, the server creates a session and gives your browser a small piece of data to hold on to, so it can recognise you on the next page. Without it, you would have to log in again for every click.
  • A token (here, a session token) is that piece of data. It is usually a long string of characters that the server can read back. A signed token is one the server has stamped with a secret mark, so it can tell whether the contents were changed after it issued them. A useful comparison is a cloakroom ticket: you hand it in, the attendant checks it is genuine, and gives you your coat. If someone could print their own ticket with your number on it, they would get your coat.
  • A cookie is one common way a browser stores and automatically sends a token back to the site on every request. You do not have to do anything; the browser carries it for you.
  • Authentication means proving who you are, usually by logging in with a password. Authorisation means deciding what a proven user is allowed to do. Logging in is authentication; being allowed to open someone else's settings is authorisation.
  • Account takeover means an attacker gains control of another person's account, as if they had the password.
  • A second factor is an extra proof at login, such as a code from a phone app. It protects the login step. It does nothing once you are already logged in, because the compromise happens later, at the session layer.
  • A vulnerability is a weakness in software that someone can abuse to make it do something it should not.
  • A patch is a change to the code that fixes a vulnerability. A fix commit is the saved record of that change, showing exactly which lines were added or removed.
  • **A CVE is a public identifier given to a specific known vulnerability so people can refer to it unambiguously. A severity score is a number expressing how bad it is; the article calls the original bug a ten out of ten on the severity scale.
  • An advisory is the public announcement a vendor or catalogue publishes about a vulnerability, usually describing what was wrong and which versions are affected.
  • A function is a named block of code that does one job when called. A branch is one path through the code, chosen by a condition, like a fork in a road: if the identifier is the old format, take this road; if it is the new format, take that one.
  • A database lookup means asking the database, the store where the site keeps its records, for a record matching some value. A bare lookup means it just fetches and returns the record, with no extra permission check.
  • Fuzzing means throwing large amounts of automatically generated, often malformed input at a program to see if it breaks. The researcher here did not fuzz; they read code.
  • SSRF (server-side request forgery) is a weakness where an attacker makes the server fetch a web address of the attacker's choosing. A redirect is when one web address sends your browser on to another address.
  • Encoding is a way of writing characters so they survive transport, for example turning a space into %20 in a web address. Double encoding means encoding something that was already encoded, which can slip past filters that only check once.
  • A regression test is an automated check that a bug which was fixed stays fixed. A negative test checks that something forbidden is actually refused.

The original bug

The original vulnerability was simple and devastating. The application's session system had an update endpoint. When a user updated their session, the server accepted identity fields from the client, including the email address, and wrote them into the signed session token without validation. Later, when resolving the user, the server looked the user up by the token's email.

In plain words: the site let your browser tell it who you are. Your browser said "my email is this", the server believed it, wrote it into the token, and from then on used that email to decide whose account you were using. There was no check that the email belonged to you.

The exploit was one request. Set your session's email to the victim's address. Every subsequent request was resolved as the victim. Full account takeover. No second factor stops it, because the compromise happens after authentication, at the session layer.

Why one request is enough: the session update is a normal feature, and the server wrote the client-supplied email into the token. Change the email inside your own session, and the server's next lookup finds the victim's account instead of yours. You never touch the victim's password, so nothing at the login step has a chance to notice.

The fix looked correct. When resolving a user from a session token, the developers added an authorisation gate: if the token points at another user's profile, verify that the requester is an organisation admin with authority over that user. Otherwise, refuse. Log the attempt. Move on.

An authorisation gate is a checkpoint. Before the server hands over a profile, it asks: is the person making this request allowed to see this profile? If the token points at someone else, the answer is only yes when the requester is an organisation admin with authority over that user. Otherwise the request is refused and the attempt is written to a log, a record of events that administrators can review later.

A textbook patch. Except for one thing.

Two formats, one gate

The profile identifier had two formats. The legacy format, a user-scoped ID, and a newer format introduced around the same time as the fix: an organisation-profile identifier with a different prefix.

A profile identifier is the label the site uses to find a profile, like a house number. A prefix is the first few characters of that label, which signal what kind of thing it points at. The legacy format pointed at a single user. The newer format pointed at an organisation profile. Both were handled inside the same function.

The authorisation gate was added to the legacy format's branch. The newer format's branch, the one added during the same era as the patch, performed a bare database lookup: find the profile with this identifier, return it. No ownership check. The function even received the requesting user's ID as a parameter, and the new branch simply never used it.

Picture a building with two doors. The guard was posted at the old door. The new door, installed around the same time, had no guard at all, even though the guard's instructions were sitting right there in the same room. The function was handed the requesting user's ID, exactly the information needed to check ownership, and the new branch ignored it.

Meanwhile, the session-update trust at the root of the original bug was never actually removed. The callback still copied client-supplied identity fields into the token.

A callback here is the piece of code that runs when the session update happens. It was still copying identity fields sent by the browser into the token, so the original hole was still open. The patch had closed the lookup side for one format but left the input side untouched.

Put those two halves together: forge the email and the newer-format profile identifier in one session update, and the server's own rebuild logic does the rest. It looks up the victim by the forged email, fetches the organisation profile the attacker pointed at, and reconstructs the session token with the victim's organisation context, including the victim's membership role.

One request. The attacker's session becomes an owner session for a victim's organisation, while the underlying user ID stays their own. The victim's organisation settings, members, and data are now scoped to an attacker-controlled session.

"Scoped to" means the session now sees the world through the victim organisation's lens: its settings, its member list, its data. The underlying user ID stayed the attacker's own, but the session carried the victim organisation's context and the owner role. But the session carried the victim organisation's context and the owner role, which is what the site uses to decide what to show and allow.

Why this keeps happening

The root cause is a design pattern, not a typo. Authorisation logic was added to one lookup format and not its sibling, because the two formats lived in the same function and the developer, reasonably, patched the branch they were told was vulnerable. Nobody re-read the whole function after the patch. Nobody asked: are there other paths that resolve identity?

A design pattern is a recurring way of structuring code. The mistake was not a stray character; it was a habit of fixing the reported spot and not its neighbours. The developer did what they were asked. The gap was in the question, not the answer.

This is the incomplete-fix pattern, and it is everywhere:

  • The SSRF guard that validates the URL but not the redirect targets
  • The file-upload filter that checks extensions but not content types
  • The parser that rejects one encoding but not the double-encoded form
  • The lookup function that gates one identifier format but not the other

Each example is the same shape. A check is added for one way of doing something, and a second way, right next to it, is left open. The SSRF guard checks the address you submit but not where that address redirects to. The upload filter checks the file name's ending but not what the file actually contains. The parser rejects one encoding but not the same thing encoded twice. The lookup function gates one identifier format but not the other.

The fix-diff methodology

If you are on the research side, this is the most productive technique I know: read public advisories, find the fix commit, and audit the patch, not the vulnerability. The patch tells you exactly which checks were added. Then ask what the checks do not cover. The sibling branch. The alternate format. The second encoding. The other caller.

A "diff" is the side-by-side view of what changed between two versions of a file: lines added in one colour, lines removed in another. Reading the diff of a security fix is like reading the builder's notes after a repair. The notes say exactly which lock was fitted and on which door. The natural next question is which doors have no lock.

In this case, the entire hunt was: read the advisory, read the patched function, notice that one identifier format received the gate and the other did not, and confirm the session-update trust still existed. Code reading, not fuzzing. Hours, not weeks.

For defenders, the lessons are concrete

  1. When a fix adds an authorisation gate, audit every sibling path in the same function. If the function has two lookup formats, both need the gate. Better: route them through one shared, gated resolution function so the check cannot be missed by construction.
  2. Identity fields must never be client-writable. A session update endpoint should whitelist exactly the fields it exists to change, locale, preferences, and reject identity fields outright. If the field cannot be submitted, it cannot be forged.
  3. Look up identity by immutable subject identifiers, never by user-mutable attributes. The email-keyed lookup is what let the forged value propagate.
  4. Regression tests should assert the negative case: a session update with a foreign email or profile pointer must not change the session's organisation, profile, or role. Test the attack, not the feature.
  5. When a new identifier format is introduced next to a legacy one, treat the new branch as unreviewed attack surface, because in practice, that is exactly what it is.

A whitelist is a list of what is allowed, with everything else refused by default. An immutable identifier is one that cannot be changed by the user, such as an internal account number; an email address is mutable because users can change it. Attack surface is the total set of places where an attacker could try to get in.

A note on disclosure

The specific vulnerability behind this article was reported privately to the vendor before this was written. The details here are deliberately generalised, no names, no identifiers, no reproduction steps, because publishing a working exploit for an unpatched critical helps nobody but attackers. The vendor's team now has the full report. What can be shared is the shape of the bug, because the shape is the lesson.

Disclosure is the process of telling the people who can fix a problem, and then deciding what to publish and when. Publishing exact steps while the problem is still open would hand attackers a recipe.

The takeaway

The most dangerous vulnerabilities are often not the ones being exploited. They are the ones inside the patch of the last one. When a critical gets fixed, that is not the end of the story, it is the start of the audit. Read the fix. Walk every branch. Ask which path the gate forgot.

Because somewhere, in a function with two lookup formats, there is a branch that never got its check. And someone is going to find it.

Glossary

  • Account takeover: an attacker gaining control of another person's account, as if they had the password.
  • Advisory: a public announcement describing a vulnerability, usually what was wrong and which versions are affected.
  • API: the part of a web application that accepts requests and returns data rather than whole pages.
  • Attack surface: all the places where an attacker could try to get in.
  • Authentication: proving who you are, usually by logging in.
  • Authorisation: deciding what a proven user is allowed to do.
  • Authorisation gate: a checkpoint in code that checks permission before handing over data.
  • Bare database lookup: fetching a record by a value and returning it with no extra permission check.
  • Branch: one path through code, chosen by a condition, like a fork in a road.
  • Callback: the piece of code that runs when a particular event, such as a session update, happens.
  • Cookie: a small piece of data a browser stores and sends back to a site automatically on each request.
  • CVE: a public catalogue number for a known vulnerability.
  • Database: the store where a site keeps its records.
  • Design pattern: a recurring way of structuring code.
  • Diff: the side-by-side view of lines added and removed between two versions of a file.
  • Double encoding: encoding something that was already encoded, which can slip past filters that check only once.
  • Encoding: writing characters in a transport-safe form, for example a space as %20.
  • Endpoint: one specific address in an API where a particular action happens.
  • Fix commit: the saved record of a code change that fixes a vulnerability.
  • Function: a named block of code that does one job when called.
  • Fuzzing: sending large amounts of automatically generated or malformed input to a program to see if it breaks.
  • Immutable identifier: an identifier the user cannot change, such as an internal account number.
  • Incomplete-fix pattern: fixing one path to a problem while a sibling path stays open.
  • Log: a record of events that administrators can review later.
  • Negative test: a test that checks something forbidden is actually refused.
  • Patch: a code change that fixes a vulnerability.
  • Prefix: the first few characters of an identifier, signalling what kind of thing it points at.
  • Profile identifier: the label a site uses to find a profile.
  • Redirect: when one web address sends the browser on to another address.
  • Regression test: an automated check that a fixed bug stays fixed.
  • Scoped to: limited to a particular context, such as one organisation's settings, members and data.
  • Second factor: an extra proof at login, such as a code from a phone app.
  • Severity score: a number expressing how bad a vulnerability is.
  • Session: the site's memory of you while you are logged in.
  • Session token: the piece of data that lets the server recognise your session.
  • Signed token: a token stamped with a secret mark so the server can tell whether its contents were changed after issue.
  • SSRF (server-side request forgery): a weakness where an attacker makes the server fetch a web address of the attacker's choosing.
  • Vulnerability: a weakness in software that someone can abuse to make it do something it should not.
  • Whitelist: a list of what is allowed, with everything else refused by default.

More by CypherNova1337

View all

12 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.