GSA Bounty · Report #250688
The Federalsit session cookie (federalist.sid) is not properly invalidated - backdoor access to the account is possible
Summary
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
How it was found
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.
- Login to the Federalist instance with your test account.
- Save the
federalist.sidcookie from the/v0/meendpoint using Burp or similar Web Debbuger. - Do logout.
- Replay the request to the
/v0/meendpoint using web debugger with same cookie. You will got 403 forbidden, as it should be. - Login with same account.
- Replay the request to the
/v0/meendpoint 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. - Do logout again.
- Login with the second test account.
- Replay the request to the
/v0/meendpoint 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
- The session cookie should be destroyed on user logout.
- The new session cookie should be established on login.