Get the free coreGet core

Session hijacking: how stolen cookies let attackers act as you

Updated 4 min readSection 05 / Threats
SHORT ANSWER

Session hijacking is when an attacker uses your stolen session cookie or token to act as you. A cookie is the small piece of data a site gives your browser after you sign in, and a token is the same idea for apps and scripts. On a Mac the theft can start with a stealer that takes browser sessions. If you think that happened, replace your passwords and sessions from a clean computer.

Session hijacking sounds like a hack of a website. In the cases below it is closer to a copied ticket: something takes the proof that you signed in, and someone else holds it up. This page explains how that happens, what 2FA does and does not cover, how to spot it and what to do. The theft itself usually comes from what an infostealer is, a program that copies what is stored on your machine.

01What a session is

When you sign in, a site gives your browser a cookie, or an app a token, so you do not have to sign in on every click. That data is the site's record that you already proved who you are.

Stolen tokens and cookies can be used to impersonate the victim and reach everything the victim could. The same goes for developer tokens, such as the keys that let a script talk to GitHub or a cloud account.

02How session hijacking runs

StepWhat happens
1You run something that looks harmless: a fake installer, a mounted DMG (a disk image used to install apps), or a command pasted into Terminal.
2The stealer reads browser data and sessions from Chrome, Edge, Safari and Firefox, plus the Keychain, the Mac's store for passwords.
3It packs the data and sends it to the attacker.
4The attacker uses the session from their own machine and does not need to stay on yours.
5The session opens online accounts, cloud and company resources and cryptocurrency, and it can support further intrusion.

The same stolen data is later used for account takeovers, data breaches, ransomware and supply chain attacks, which enter through software you rely on.

03What 2FA covers and what it does not

Two-step sign-in, called 2FA or MFA, checks who you are at the moment you sign in. A stolen cookie or token is something the site handed out after that check, so whoever holds it can act as you. As MFA became more common, real attacks that steal and replay cookies and tokens appeared.

That does not make 2FA pointless. Phishing-resistant MFA is part of the advice against token theft, and the first line of defense is protecting the devices with security software and device management. If you manage accounts for a team, a token protection policy in Microsoft Entra cryptographically protects against replay of stolen tokens.

It also explains why a Mac does not need to stay infected. Stolen credentials and session material can be used without the attacker keeping a foothold on the original system. The stealer does not have to stay for the attacker to use what it took.

04Where the sessions and tokens come from

Browsers are the obvious source. Chrome, Edge, Safari and Firefox sessions are among what AMOS harvested, and MacSync targets the Chrome and Firefox stores. AMOS also takes cookies and stored cards. Read more on Atomic Stealer and the Mac stealer table.

Developer tokens are the second source. Campaigns that start with a fake job interview harvest API tokens, cloud credentials, signing keys, wallets and password manager files. See fake job interview malware for how that reaches developers, session cookie theft for the browser side, and crypto wallet drained for where the chain ends for a wallet.

05Signs that a session was stolen

There is no single alarm for this, so look at both ends: the service and your Mac.

Neither check is proof alone, because a stolen session is used after the stealer's work is done. If your answer to the second question worries you, assume the sessions of that Mac could have been copied and go to the next section.

06What to do now

Order matters, and the first step is where you do it.

  1. Use a clean computer. Replace credentials and sessions that the affected Mac could reach, working from a trusted system.
  2. Change the passwords stored on the machine and turn on two-step sign-in.
  3. If you are a developer, replace your tokens as well. GitHub can revoke all your credentials at once from account settings. The GitHub steps are on GitHub account hacked, and leaked API key covers keys in general.
  4. Clean the Mac after that: remove suspicious login items, LaunchAgents and LaunchDaemons, and consider a clean reinstall of macOS.

07How to lower the chance of session hijacking

The cookie is taken from the machine, so the machine is where prevention starts.

On the Mac side, Artificial Immunity's free, open-source core watches program starts, the moment a session stealer would show up, and reports what it finds.

FAQ

What is a session hijacking attack?

An attacker uses a stolen cookie or token to impersonate you. Stolen tokens and cookies can be used to act as the victim and reach everything the victim could.

Do stolen cookies get around 2FA?

A stolen cookie is something a site handed out after you signed in, and with it an attacker can act as you. As MFA became more common, real attacks that steal and replay cookies and tokens appeared.

How to stop session hijacking?

Protect the devices where you sign in: do not run copy-pasted commands from random pages, and keep security software and device management in place, which is the first line of defense against token theft. Use short-lived credentials instead of long-lived tokens.

What are signs that your session may have been hijacked?

Look at the logs or audit trails that show a secret or key in use, and ask whether your Mac ran a stealer. The infostealer check page lists the traces.

What should I do if my session was stolen?

Replace credentials and sessions from a trusted system, and change the passwords stored on the machine. GitHub steps are on the GitHub account hacked page.

Does 2FA still help?

Yes. Phishing-resistant MFA is part of the advice against token theft, together with protected devices. It guards the sign-in, and protecting the device is the first line of defense for what happens after it.

Sources

  1. Microsoft Entra, addressing token theft
  2. Microsoft Defender Experts, hunting infostealers on macOS
  3. Microsoft, Contagious Interview
  4. GitHub docs, token revocation
  5. Malwarebytes, poisoned AI chats spread AMOS
  6. BleepingComputer, Script Editor ClickFix campaign
  7. GitHub docs, managing personal access tokens
  8. GitHub docs, remediating a leaked secret
  9. AWS IAM docs, rotating access keys
  10. Artificial Immunity
A stolen session starts with one program on your Mac. Artificial Immunity watches program starts on the Mac where your agents work.Get the free core