Skip to content
Access control Disclosed report Intermediate

The Federalsit session cookie (federalist.sid) is not properly invalidated - backdoor access to the account is possible

The Federalist session cookie was not properly invalidated on logout, only becoming inactive until the next login. An attacker who obtained a valid cookie could reuse it after the victim logged out and then logged back in, potentially gaining access to the account, even if a different user logged in on the same machine.

sp1d3rs Follow

Originally disclosed on HackerOne

  • Triaged in 36 days
  • Fixed in 50 days
  • Paid in 38 days
  • Disclosed after 50 days

Summary by the researcher

Thanks to the 18F team for the great experience, fast fix and the bounty!

This report describes session management issue, when the session was not actually destroyed on logout - just became inactive till next login. It was possible to affect other user too, in case, if this user used same machine for login (see the "Exploitation scenario" section).

Issue was fixed by implementing correct session invalidation.

##References Running Federalist locally

The report

##Description Hello. This issue is not very dangerous itself, but can be dangerous in combination of others (like XSS, or malicious access to the user account). The user/attacker, who got once valid cookie federalist.sid from the account, can use it as backdoor for some time, because it is not actually invalidated on Logout. Also, i discovered, that privilege escalation is possible (it is possible to attack another user account in some cases). Actually, logout just invalidating GitHub access token, but session still can be valid. How it can be used by attacker, or malicious user? Let's see the POC below.

##POC Case 1. Using the flaw as BackDoor access to the account.

  1. Login to the Federalist instance with your test account.
  2. Save the federalist.sid cookie from the /v0/me endpoint using Burp or similar Web Debbuger.
  3. Do logout.
  4. Replay the request to the /v0/me endpoint using web debugger with same cookie. You will got 403 forbidden, as it should be.
  5. Login with same account.
  6. Replay the request to the /v0/me endpoint using web debugger with same cookie. You will got success response.

Case 2. Using the flaw (same session value) as BackDoor access to the account of another user. Continue testing from the last step. 7) Do logout again. 8) Login with the second test account. 9) Replay the request to the /v0/me endpoint using web debugger with same cookie from previous steps. You will got success response, and info about users.

##Impact Exploitation scenario.

Lets suppose, that some Federalist user worked on his PC, and did logout from Github and Federalist. It is supposed, that malicious user can't access his account without GitHub credentials. But, because federalist.sid was not invalidated properly, it is only a temporary restriction for the attacker. Let's suppose, that attacker somehow got federalist.sid cookie (using XSS, physical access to the PC, or attacker was previously the legit user, and saved cookie for the future access). He can't access the API just now, (as it throws 403), but he will can, when the login action will be performed on that PC again. Session will become valid, and, not matter, which user did the login! For example, if the second user logged in to the Federalist from different account, old federalist.sid will be assigned to him, and attacker's backdoor federalist.sid will work for the another account! Sure the session cookie has limited lifetime, but still, insufficient invalidation can pose some risks.

##Suggested fix

  1. The session cookie should be destroyed on user logout.
  2. The new session cookie should be established on login.

The original report as published on HackerOne, by sp1d3rs. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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. 6 min read.

Context

Federalist is a 18F product whose source lives at https://github.com/18f/federalist. The report concerns its session management: the application issues a session cookie named federalist.sid, and the researcher's testing centred on the /v0/me endpoint, which returns information about the currently authenticated user.

Normally, logging out of an application should destroy the server-side session and the cookie that references it, so that a copy of the cookie taken before logout is worthless afterwards. In Federalist, according to the researcher, logout only invalidated the GitHub access token while the session itself survived. The session became inactive rather than destroyed, and could become active again on a later login.

The researcher notes that the issue is not very dangerous on its own, but can be dangerous in combination with others, such as XSS or malicious access to a user account. The report was disclosed on 5 September 2017 and rated low severity, with the weakness classified as insufficient session expiration.

Setup

The testing required a Federalist instance and test accounts. The researcher refers to a first test account and a second test account, and links to the "Running Federalist locally" documentation page. The tooling named in the report is Burp or a similar web debugger, used to capture the federalist.sid cookie and to replay requests to /v0/me with a chosen cookie value.

The precondition for the whole exercise is simple: obtain a valid federalist.sid cookie once, from any account, and keep a copy of it.

Finding it

The researcher observed that logging out did not actually invalidate the session. The logout action invalidated the GitHub access token, but the session behind federalist.sid remained valid in the sense that it could be revived. Immediately after logout the cookie is rejected, which makes the behaviour look correct at first glance; the flaw only shows up when a new login happens on the same machine, at which point the old cookie value starts working again.

The researcher also found that this revival is not tied to the account that originally owned the session: after a second account logs in, the old cookie can return information about that second user. The researcher states that privilege escalation is possible, in the sense that one user's saved cookie can end up giving access to another user's account.

Exploitation

The report gives two cases. The second continues directly from the last step of the first.

Step 1: Log in with the first test account

Log in to the Federalist instance with your test account. This establishes a session and sets federalist.sid.

Step 2: Capture the session cookie

Save the federalist.sid cookie from the /v0/me endpoint using Burp or a similar web debugger. The endpoint is the one used throughout the proof of concept to test whether a given cookie is accepted.

Step 3: Log out

Perform the logout action. According to the report, this invalidates the GitHub access token but does not destroy the session.

Step 4: Replay the request after logout

Replay the request to /v0/me with the same cookie. The response is 403 Forbidden, which is the expected behaviour and makes the logout appear effective.

Step 5: Log in again with the same account

Log in with the same account. This is the point where the old session value is revived.

Step 6: Replay the request again

Replay the request to /v0/me with the same cookie from step 2. This time the response is a success, even though the cookie was captured before the logout. The session that should have been destroyed is live again.

Step 7: Log out again

Log out once more, continuing from the previous step.

Step 8: Log in with the second test account

Log in with the second test account on the same machine.

Step 9: Replay the old cookie against the new session

Replay the request to /v0/me with the same cookie captured in step 2, which belonged to the first account. The response is a success and contains information about users. The old cookie now authenticates as the second account.

Root cause

The report states the mechanism plainly: logout only invalidates the GitHub access token, while the session behind federalist.sid is not actually invalidated. The session is left in a state where it is inactive until the next login, and the next login reactivates it. Because the reactivation is not bound to the identity that created the session, the same cookie value can end up attached to whichever account logs in next on that machine.

Immediately after logout the cookie is rejected with 403, but the old value works again after a new login. It does not remove the server-side state that the cookie points to, so the check passes again as soon as a new login occurs. The report does not describe the server-side implementation, so the exact code path that revives the session is not shown; the observable behaviour is that the old value becomes valid again.

Impact

The report frames the issue as low risk by itself but significant in combination with other flaws. The exploitation scenario it gives is as follows.

A Federalist user works on a PC and logs out of both GitHub and Federalist. The expectation is that an attacker cannot access the account without GitHub credentials. However, because federalist.sid was not properly invalidated, that is only a temporary restriction. Suppose the attacker somehow obtained the federalist.sid cookie, through XSS, physical access to the PC, or because the attacker was previously the legitimate user and saved the cookie for future access. Right after logout the attacker cannot use the API, since it returns 403. But when a login is performed again on that PC, the session becomes valid, and it does not matter which user performed the login. If a second user logs in to Federalist from a different account, the old federalist.sid is assigned to that user, and the attacker's backdoor cookie works against the other account.

The researcher adds the limit explicitly: the session cookie has a limited lifetime, but insufficient invalidation can still pose risks. The researcher notes the session cookie has a limited lifetime, but insufficient invalidation can still pose risks.

Fix

The report states that the issue was fixed by implementing correct session invalidation. The suggested fix it gives has two parts:

  1. The session cookie should be destroyed on user logout.
  2. The new session cookie should be established on login.

The researcher also thanks the 18F team for the experience, the fast fix and the bounty.

Variants to test

  • Logout then re-login with the same account. Capture the session cookie, log out, confirm the cookie is rejected, log in again, and replay the old cookie. A positive result is a successful authenticated response with the pre-logout cookie value.
  • Logout then login with a different account on the same client. Capture the cookie from account A, log out, log in as account B, and replay A's cookie. A positive result is a response identifying account B, which shows the session is not bound to its original owner.
  • Compare logout behaviour across session stores. If logout only revokes a federated token (OAuth access token, SSO ticket) but leaves the local session record intact, the same revival pattern is likely. A positive result is the old cookie working again after any subsequent authentication event.
  • Check other authenticated endpoints, not just the profile endpoint. If /v0/me is revived, test state-changing endpoints with the old cookie after a new login to see whether the revived session carries write access.
  • Test session fixation style flows. If a session identifier supplied before authentication is adopted unchanged after login, the same class of weakness appears without any logout step. A positive result is a pre-authentication cookie value that authenticates as the user who logs in afterwards.
  • Check expiry handling. Confirm whether the revived session inherits the original expiry or a fresh one; a fresh expiry extends the window in which a captured cookie remains useful.

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. 11 min read.

What happened, in plain words

Federalist is a website built by 18F, a team inside the US government's technology agency, and its source code is public at https://github.com/18f/federalist. The report is about how Federalist handles the thing that keeps you logged in after you type your username and password: a session.

When you log in to a website, the server needs a way to remember you on the next page load. Browsers and servers do this with a cookie, a small piece of text that the server hands to your browser and that your browser sends back with every request to that site. Think of it like a cloakroom ticket: the server keeps your coat (your logged-in state) and gives you a numbered ticket (the cookie). When you come back and show the ticket, the server fetches your coat. Federalist's ticket is called federalist.sid.

The researcher found that logging out of Federalist did not really throw the coat away. It only made the ticket stop working for a while. If someone had copied the ticket earlier, they could not use it right after you logged out, but as soon as anyone logged in again on that same computer, the old ticket started working again. Worse, it did not matter which account logged in: the old ticket could end up giving access to the new person's account.

The report was disclosed on 5 September 2017 and rated low severity, with the weakness classified as insufficient session expiration. The researcher notes the issue is not very dangerous on its own, but can be dangerous in combination with others, such as XSS or malicious access to a user account.

The pieces you need to know

Before walking through the steps, here are the ideas the report relies on.

  • API: an API is the part of a website that answers requests with data rather than web pages. Your browser's address bar is not usually how you talk to it; tools do. Federalist's API lives under paths starting with /v0/.
  • Endpoint: a specific address inside an API that does one job. The report uses one endpoint, /v0/me, which returns information about the user who is currently logged in. It is a convenient test: if the server answers with your details, your cookie was accepted; if it refuses, it was not.
  • Session cookie: the cookie that proves who you are. Copying it is like photocopying your cloakroom ticket.
  • GitHub access token: Federalist lets you log in through GitHub, the code hosting site. When you do, GitHub gives Federalist a token, a short string that lets Federalist act on your behalf at GitHub. Logging out of Federalist is supposed to throw that token away.
  • Burp or a similar web debugger: a tool that sits between your browser and the server so you can see every request and response, copy cookies out, and send the same request again later, possibly with a different cookie. "Replay" means exactly that: send a request you captured earlier, again.
  • 403 Forbidden: the standard HTTP status code a server returns when it understands your request but refuses to let you do it. It is the server saying no.
  • XSS (cross-site scripting): a class of bug where an attacker gets their own code to run inside someone else's browser on a trusted site, which can be used to read cookies.
  • Privilege escalation: getting access to more than you should have. Here it means one person's saved cookie ending up giving access to another person's account.
  • Session fixation: a related weakness where a session identifier chosen before login is kept unchanged after login, so whoever knew the identifier before also knows it after.

Setup

The testing needed a Federalist instance and test accounts. The researcher refers to a first test account and a second test account, and links to the "Running Federalist locally" documentation page. The tooling named in the report is Burp or a similar web debugger, used to capture the federalist.sid cookie and to replay requests to /v0/me with a chosen cookie value.

The precondition for the whole exercise is simple: obtain a valid federalist.sid cookie once, from any account, and keep a copy of it.

Finding it

The researcher observed that logging out did not actually invalidate the session. The logout action invalidated the GitHub access token, but the session behind federalist.sid remained valid in the sense that it could be revived. Immediately after logout the cookie is rejected, which makes the behaviour look correct at first glance; the flaw only shows up when a new login happens on the same machine, at which point the old cookie value starts working again.

The researcher also found that this revival is not tied to the account that originally owned the session: after a second account logs in, the old cookie can return information about that second user. The researcher states that privilege escalation is possible, in the sense that one user's saved cookie can end up giving access to another user's account.

Exploitation

The report gives two cases. The second continues directly from the last step of the first.

Step 1: Log in with the first test account

Log in to the Federalist instance with your test account. This establishes a session and sets federalist.sid. In plain terms, you show your ID at the cloakroom and get a ticket back.

Step 2: Capture the session cookie

Save the federalist.sid cookie from the /v0/me endpoint using Burp or a similar web debugger. The endpoint is the one used throughout the proof of concept to test whether a given cookie is accepted.

Why this step: you need a copy of the ticket before you log out, because the whole question is whether that copy still works afterwards. The web debugger shows you the request your browser made to /v0/me and the cookie it carried, and lets you keep that cookie value for later.

Step 3: Log out

Perform the logout action. According to the report, this invalidates the GitHub access token but does not destroy the session.

Why this step: logging out is the moment the ticket is supposed to become worthless. If it does not, that is the bug.

Step 4: Replay the request after logout

Replay the request to /v0/me with the same cookie. The response is 403 Forbidden, which is the expected behaviour and makes the logout appear effective.

Why this step: to check the obvious thing first. The server says no, so at this point everything looks fine. This is what makes the bug easy to miss.

Step 5: Log in again with the same account

Log in with the same account. This is the point where the old session value is revived.

Why this step: the researcher is testing whether the refusal in step 4 was permanent or only temporary. A new login is the event that, according to the report, brings the old session back to life.

Step 6: Replay the request again

Replay the request to /v0/me with the same cookie from step 2. This time the response is a success, even though the cookie was captured before the logout. The session that should have been destroyed is live again.

Why this step: this is the proof. The same ticket that was refused in step 4 is now accepted, without anyone having done anything to it. The only change was a login happening on the same machine.

Step 7: Log out again

Log out once more, continuing from the previous step.

Why this step: to set up the second case, where a different account logs in on the same machine.

Step 8: Log in with the second test account

Log in with the second test account on the same machine.

Why this step: the first case showed the old cookie comes back for the same account. This step asks a sharper question: does it come back for a different account too?

Step 9: Replay the old cookie against the new session

Replay the request to /v0/me with the same cookie captured in step 2, which belonged to the first account. The response is a success and contains information about users. The old cookie now authenticates as the second account.

Why this step: this is the privilege escalation. A ticket that belonged to one person now opens the locker of another, simply because that other person logged in on the same computer.

Root cause

The report states the mechanism plainly: logout only invalidates the GitHub access token, while the session behind federalist.sid is not actually invalidated. The session is left in a state where it is inactive until the next login, and the next login reactivates it. Because the reactivation is not bound to the identity that created the session, the same cookie value can end up attached to whichever account logs in next on that machine.

Immediately after logout the cookie is rejected with 403, but the old value works again after a new login. It does not remove the server-side state that the cookie points to, so the check passes again as soon as a new login occurs. The report does not describe the server-side implementation, so the exact code path that revives the session is not shown; the observable behaviour is that the old value becomes valid again.

The next guest who checks in at the front desk causes the door to accept that old card again, and it opens the room for the new guest.

Impact

The report frames the issue as low risk by itself but significant in combination with other flaws. The exploitation scenario it gives is as follows.

A Federalist user works on a PC and logs out of both GitHub and Federalist. The expectation is that an attacker cannot access the account without GitHub credentials. However, because federalist.sid was not properly invalidated, that is only a temporary restriction. Suppose the attacker somehow obtained the federalist.sid cookie, through XSS, physical access to the PC, or because the attacker was previously the legitimate user and saved the cookie for future access. Right after logout the attacker cannot use the API, since it returns 403. But when a login is performed again on that PC, the session becomes valid, and it does not matter which user performed the login. If a second user logs in to Federalist from a different account, the old federalist.sid is assigned to that user, and the attacker's backdoor cookie works against the other account.

The researcher adds the limit explicitly: the session cookie has a limited lifetime, but insufficient invalidation can still pose risks. The researcher notes the session cookie has a limited lifetime, but insufficient invalidation can still pose risks.

Fix

The report states that the issue was fixed by implementing correct session invalidation. The suggested fix it gives has two parts:

  1. The session cookie should be destroyed on user logout.
  2. The new session cookie should be established on login.

In cloakroom terms: when you hand back your ticket, the coat is thrown away and the ticket number is retired for good; and every new visit gets a brand new number, never a recycled one.

The researcher also thanks the 18F team for the experience, the fast fix and the bounty.

Variants to test

These are the same checks, written so you can repeat them on another site.

  • Logout then re-login with the same account. Capture the session cookie, log out, confirm the cookie is rejected, log in again, and replay the old cookie. A positive result is a successful authenticated response with the pre-logout cookie value.
  • Logout then login with a different account on the same client. Capture the cookie from account A, log out, log in as account B, and replay A's cookie. A positive result is a response identifying account B, which shows the session is not bound to its original owner.
  • Compare logout behaviour across session stores. If logout only revokes a federated token (OAuth access token, SSO ticket) but leaves the local session record intact, the same revival pattern is likely. A positive result is the old cookie working again after any subsequent authentication event.
  • Check other authenticated endpoints, not just the profile endpoint. If /v0/me is revived, test state-changing endpoints with the old cookie after a new login to see whether the revived session carries write access.
  • Test session fixation style flows. If a session identifier supplied before authentication is adopted unchanged after login, the same class of weakness appears without any logout step. A positive result is a pre-authentication cookie value that authenticates as the user who logs in afterwards.
  • Check expiry handling. Confirm whether the revived session inherits the original expiry or a fresh one; a fresh expiry extends the window in which a captured cookie remains useful.

Glossary

  • 18F: a team inside the US government's technology agency that builds digital services, and the organisation behind Federalist.
  • 403 Forbidden: an HTTP status code meaning the server understood the request but refuses to carry it out.
  • API: the part of a service that answers requests with data rather than web pages.
  • Burp: a web debugging proxy used to inspect, capture and replay HTTP requests.
  • Cookie: a small piece of text a server gives a browser, which the browser sends back on later requests to the same site.
  • Endpoint: a specific address in an API that performs one job.
  • GitHub access token: a string issued by GitHub that lets another application act on a user's behalf at GitHub.
  • HTTP status code: a number in a response that says broadly what happened, such as success or refusal.
  • Insufficient session expiration: a weakness where a session is not properly ended when it should be, so it can still be used later.
  • Privilege escalation: gaining access to more than you are entitled to, such as another user's account.
  • Replay: sending a request you captured earlier, again, possibly with a different cookie.
  • Session: the server-side record that says a particular browser is logged in as a particular user.
  • Session cookie: the cookie that identifies a session, here federalist.sid.
  • Session fixation: a weakness where a session identifier chosen before login is kept after login, so anyone who knew it beforehand still knows it.
  • Token: a string that stands in for credentials, so a service can prove or delegate access without a password.
  • XSS (cross-site scripting): a bug that lets an attacker run their own code in another person's browser on a trusted site, often used to read cookies.

More by sp1d3rs

View all

62 more disclosed reports, best first.

More from GSA Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.