Python Penetration Testing 0365 Session Id Login With Python
The text explains that if an attacker obtains a user's Microsoft 365 session ID after MFA authentication, they can reuse it to access the account without providing MFA again. A Python script is shown to make API calls and open a browser with the session ID.
Published on infosecwriteups.com
Tailgating and bypassing MFA with session IDs have some similarity. Tailgating refers to the act of an employee inadvertently granting unauthorized access to a restricted area by opening a locked door for someone without verifying their credentials or without being aware of their presence.
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the session ID (a bearer token) is not bound to the original client and remains valid for a period, allowing reuse from a different context.
Impact
An attacker with a stolen session ID could access the victim's Microsoft 365 data without needing MFA, though an external network may trigger another MFA prompt.
What the attacker needed
A stolen session ID; network access to Microsoft 365
How it was found
- Obtain a valid session ID after MFA authentication (e.g., via phishing or pass-the-hash).
- Use the session ID in an Authorization header to call the Microsoft Graph API endpoint for the current user.
- Check if the response status is 200 to confirm successful login.
- Optionally, open a Chrome browser with a URL containing the session ID to access the account without re-entering MFA.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When you log into a website with extra security (MFA), the site gives your browser a temporary pass (session ID) so you don't have to log in again for a while. If a bad person steals that pass, they can use it to get into your account without needing your password or the extra security code. This article shows how a stolen pass can be used with a simple script.
What is Account takeover?
Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.