osec.one case analysis cover: Bybit 2025: one developer laptop, a swapped JavaScript file in a storage bucket and a $1.5 billion transfer

On 21 February 2025 at 14:13:35 UTC three Bybit signers approved what their screen showed as a routine move from the exchange's Ethereum cold wallet to its warm wallet. Two minutes and thirty-six seconds later, 401,346 ETH left that cold wallet for an address controlled by North Korea's TraderTraitor group, followed by stETH, cmETH and mETH: about $1.46 billion, the largest theft in crypto's history.

Bybit's own systems were not broken into. The signers used Safe{Wallet}, the web app many companies use for multi-signature wallets, and the web app had been changed: one JavaScript file in the storage bucket that serves app.safe.global was replaced two days earlier with a copy that only misbehaved when Bybit's wallet was the one signing. Everyone else got the normal app.

This is a client-side supply chain attack, like Polyfill.io and British Airways 2018, with a different way in: no domain was sold and no checkout page was skimmed. A developer laptop led to the cloud account, and the cloud account to the file that every visitor's browser ran. We pulled the archived copies of that file and the page that loaded it; the numbers below are from them.

Attack chain: 4 Feb a Safe developer's Mac runs a Docker stock-trading project; 5 Feb the attacker uses the developer's live AWS session, getting around MFA; 19 Feb one Next.js file in the S3 bucket behind app.safe.global is replaced; the swapped file only acts for Bybit's cold wallet; signers see a normal transfer and the Ledger signs a delegatecall; 21 Feb 14:16 UTC 401,346 ETH is swept
Nineteen days from the laptop to the transfer. The swapped file was live for about 47 hours.

The timeline

text
Bybit / Safe{Wallet}, February 2025 (times UTC)

 2 Feb            getstockprice[.]com registered (used by the lure)
 4 Feb            Safe developer "Developer1": macOS workstation runs a Docker project,
                  "MC-Based-Stock-Invest-Simulator-main", which talks to that domain
 5 Feb 14:06      attacker tries to register their own MFA device on the AWS account: fails
 5 Feb            attacker uses Developer1's active AWS session tokens instead
                  (ExpressVPN addresses, a Kali Linux user agent)
 5-17 Feb         reconnaissance inside Safe's AWS
19 Feb ~15:29     _app-52c9031bfa03da47.js replaced in the S3 bucket behind app.safe.global
21 Feb 14:13:35   Bybit signs execTransaction on Cold Wallet 1 (block 21895238)
21 Feb ~14:15     clean file put back
21 Feb 14:16:11   sweepETH moves 401,346.77 ETH out (block 21895251)
26 Feb            FBI attributes it to TraderTraitor (DPRK); Sygnia and Verichains reports
 6 Mar            Safe publishes Mandiant's findings

From the laptop to the theft took 19 days. The swapped file was served for about 46 hours 46 minutes (19 Feb 15:29 to 21 Feb 14:15). The attacker removed it about two minutes after Bybit signed, which is why the first reports said Safe's code looked clean.

Step 1: a developer's laptop

Sygnia's investigation and Safe's Mandiant update say the attack began on a Safe developer's Mac. A Docker project dressed up as a stock-trading simulator reached out to getstockprice[.]com, registered two days earlier; Netlas, citing the preliminary report, describes a Python file in it loading YAML with an unsafe loader, which lets the file run code. The developer had AWS access to Safe's production front end on the same machine. TraderTraitor is known for this opening: a job test, a coding exercise or a trading tool sent to a developer.

Control: keep production cloud credentials off the machine where you open code from strangers. In practice: a separate browser profile or device for the cloud console, a container or VM for anything from a recruiter, a candidate or a chat, and no long-lived keys in ~/.aws.

Step 2: the session token, not the password

On 5 February the attacker tried to add their own MFA device to the account and failed. They then used Developer1's active AWS session tokens, which had already passed MFA. Safe's setup asked for re-authentication every 12 hours, so a stolen token kept working for up to half a day. The traffic came from ExpressVPN addresses with a Kali Linux user agent; nothing blocked that.

text
AWS temporary credentials: how long a stolen one works (AWS STS docs)

API                     default      range                     notes
GetSessionToken         12 h         15 min - 36 h             1 h max with root credentials
AssumeRole              1 h          15 min - role max (1-12 h) role chaining caps at 1 h
Safe's setting (2025)   12 h         re-authentication every 12 hours

This is the same lesson as CircleCI 2023: MFA protects the sign-in, not the session that comes after it. Controls: short sessions for any role that can write to production (1 hour, not 12), role sessions limited by aws:SourceIp or a VPC endpoint where that's practical, and an alert when a session is used from a new network or user agent, especially a hosting VPN or a pentest distribution.

Step 3: one file in the bucket

app.safe.global was a Next.js static export served from Amazon S3 behind CloudFront. On 19 February the attacker replaced two JavaScript files, _app-52c9031bfa03da47.js and 6514.b556851795a4cbaa.js. The name ends in a content hash: Next.js names each build file after what's in it, so a new file should get a new name. The attacker kept the old name and changed what was in it, and nothing on the way to the browser checked.

Our test: the archived file, before and after

The Internet Archive captured _app-52c9031bfa03da47.js seven times between 14 and 22 February 2025. We downloaded each capture and hashed it:

text
app.safe.global/_next/static/chunks/pages/_app-52c9031bfa03da47.js
(Wayback Machine captures, downloaded and hashed 25 Oct 2026)

capture (UTC)        bytes       SHA-384 (first 16 chars)   Bybit cold wallet address in it
14 Feb 13:06         3,744,304   MPjZhNfm6V99zHNH           no
14 Feb 19:07         3,744,304   MPjZhNfm6V99zHNH           no
17 Feb 02:49         3,744,304   MPjZhNfm6V99zHNH           no
19 Feb 11:19         3,744,304   MPjZhNfm6V99zHNH           no
19 Feb 17:29         3,746,298   phq8cxuKVW6RU57m           yes (0x1db92e2e...dfcf4, twice)
22 Feb 02:26         3,744,304   MPjZhNfm6V99zHNH           no
22 Feb 17:55         3,744,304   MPjZhNfm6V99zHNH           no

difference: +1,994 bytes, one changed region of about 8.8 kB in the minified file

Same name, a size within 0.06% of the original, a different hash. The capture of 19 February at 17:29 is also the first one served as application/javascript instead of text/javascript (and it stayed that way after the clean copy went back): the file had been uploaded by a different tool than the usual deploy. Both are the kind of signal a simple watcher catches.

Controls: only the deploy pipeline's role can write to the bucket (no developer has s3:PutObject on production); turn on S3 versioning and CloudTrail data events for the bucket, and alert on any write that doesn't come from that role; never overwrite a file: content-hashed names mean a changed file must be a new name, so a write to an existing name is an incident by definition.

Step 4: what the browser checked

We also pulled the archived app.safe.global HTML. Its archive digest is identical on 15 February and 19 February at 17:28, one minute before the tampered script was captured: the attacker didn't touch the page, only the script. The page loaded 9 scripts and had 0 integrity attributes. Its Content-Security-Policy allowed script-src 'self' plus a few analytics hosts.

text
Would it have stopped the swapped file?

control                                    on app.safe.global (19 Feb 2025)    effect on this attack
Content-Security-Policy script-src 'self'  yes                                  none: the file came from 'self'
Subresource Integrity on <script> tags     no (0 of 9)                          would have blocked it: the
                                                                                 HTML was unchanged, the hash not
content-hashed file names                  yes                                  none: nothing checks the name
a job comparing served hashes to the       unknown (not in any report)          46 h window: 561 chances at
build manifest every 5 minutes                                                   one check every 5 minutes

Subresource Integrity is an attribute on the script tag (integrity="sha384-...") holding the hash of the file the page expects. If the file that arrives has a different hash, the browser refuses to run it. Had the build written those attributes into the HTML, the swapped _app file would have failed to load on every visitor's browser, including Bybit's, and Safe's own monitoring would have seen a broken app instead of a quietly hostile one.

The limit is plain: whoever can write the script to the bucket can usually write the HTML too, and rewrite the hash. SRI moves the target from one file to two, and makes a script-only swap like this one fail loudly. To go further, the HTML needs to be stored or signed apart from the files, or checked from outside: a small job that downloads the live page and its scripts every few minutes and compares the hashes with the build manifest in git. Safe added more checks of transaction hashes and signatures after the attack; the reports don't describe any check of the served files.

Step 5: a payload for one customer

Sygnia's analysis of the swapped file shows it ran only when the transaction came from one of two Safe contract addresses: Bybit's cold wallet and one more, probably the attacker's test wallet. For those, it changed the transaction just before signing: the operation became a delegatecall (operation 1) to an attacker contract instead of a plain call, and that contract's transfer() wrote to storage slot 0 of Bybit's Safe, which holds the address of the code the wallet runs. After the signatures, Bybit's cold wallet was running the attacker's contract, with sweepETH and sweepERC20 functions. Every other Safe user got normal behaviour, which is why nobody else reported anything in 46 hours.

This targeting is what makes front-end tampering hard to spot from the outside. A skimmer like British Airways' has to act on every checkout; this file acted once. Scanning the site as an ordinary user would have shown nothing, but the file's hash would have changed all the same.

Step 6: what the signers saw

The Safe screen showed a transfer to Bybit's warm wallet, with the right address and the real app.safe.global URL. Bybit's CEO Ben Zhou said the Safe UI looked correct but the data sent to the Ledger had been altered, and that he did not check the details on the Ledger's own screen. Hardware wallets display raw call data for a Safe transaction unless the app decodes it, so the signers approved bytes they couldn't read: blind signing.

Controls: decode the transaction independently of the web app before signing (a second tool, a script, or a transaction simulator that shows the effect: "this changes the wallet's implementation" is unmistakable); refuse any Safe transaction where operation is 1 (delegatecall) unless it's a known, planned upgrade; use hardware wallet apps that clear-sign Safe transactions; and keep the bulk of cold funds behind a time lock so an approved transaction can still be stopped.

What happened to the money

text
Stolen from Bybit Cold Wallet 1, 21 Feb 2025

asset      amount
ETH        401,346
stETH       90,375
cmETH       15,000
mETH         8,000
USDT            90
total      about $1.46 billion at the day's prices (FBI: about $1.5 billion)

The funds were spread over about 50 wallets within two hours (Elliptic). Within about ten days all of the roughly 499,000 ETH had been converted, mostly through THORChain into Bitcoin; Zhou said on 4 March that 417,348 ETH (about 83%) had gone that way. Bybit stayed open: bridge loans and purchases of about 446,870 ETH (about $1.23 billion) closed the gap by 24 February. Its bounty offered 10% of anything recovered, up to $140 million; by April 2025 it had paid $2.3 million to 12 people, with 68.6% of the funds still traceable and 27.6% gone dark.

Bybit, Polyfill.io and British Airways side by side

text
case                 way in                          what changed          who got the bad code
British Airways 2018 stolen third-party login,       a library file on     every visitor to the
                     then the web server             BA's own server       payment page, 15 days
Polyfill.io 2024     the domain and its CDN were     the CDN's response     visitors of 380,000+
                     sold to a new owner             per browser            sites (mobile, some only)
Bybit 2025           developer laptop, then AWS      one build file in     one company's signers,
                     session tokens                  the S3 bucket         once

The common thread: the browser ran whatever arrived under a trusted name. SRI on the script tags covers the Polyfill.io case when the file is static, the British Airways case when the HTML and the library file live apart, and the Bybit case as it happened. It does nothing for a script that's meant to change (a tag manager, Stripe.js), which is where Content-Security-Policy reports and a watch on the served hashes come in.

If you ship a front end from a bucket

1. Write access: only the deploy role can write to the production bucket; people get read-only. Use short sessions (1 hour) for that role.
2. Never overwrite: content-hashed names for every build file; alert on any write to an existing key, and on any write not from the pipeline (CloudTrail data events).
3. SRI in the HTML for every script and stylesheet, written by the build. Most bundlers have a plugin or option for it.
4. Watch what you serve: every 5 minutes, fetch the live page and its files from outside and compare the hashes with the build manifest in git. Page someone on a mismatch.
5. CSP with reports so a script from a new origin shows up the day it appears.
6. For anything that signs money or grants access: decode and simulate what's being signed outside the web app that prepared it.

To see where your own pages stand, the free osec SRI check lists every script and stylesheet a page's HTML loads, whether each has an integrity hash that still matches the file served today, and the attribute to paste for the ones without; it also names the files that change under the same URL, where a hash would break the page.

Paste a page address and see which of its scripts and stylesheets could be swapped without the browser noticing, with the integrity attributes to paste. Free.

Run the SRI check

Sources

• Sygnia: Investigation of the Bybit hack (16 Mar 2025): https://www.sygnia.co/blog/sygnia-investigation-bybit-hack/
• FBI PSA I-022625-PSA, North Korea responsible for $1.5 billion Bybit hack (26 Feb 2025): https://ic3.gov/psa/2025/psa250226
• BleepingComputer: Lazarus hacked Bybit via breached Safe{Wallet} developer machine (26 Feb 2025): https://www.bleepingcomputer.com/news/security/lazarus-hacked-bybit-via-breached-safe-wallet-developer-machine/
• Cointelegraph: Safe Wallet releases Bybit hack post-mortem (Mandiant findings, 6 Mar 2025): https://cointelegraph.com/news/safe-wallet-releases-bybit-hack-post-mortem
• Netlas: the Bybit hack, timeline and indicators: https://netlas.io/blog/bybit_hack/
• CertiK: Bybit incident technical analysis: https://www.certik.com/resources/blog/bybit-incident-technical-analysis
• Etherscan: execTransaction https://etherscan.io/tx/0x46deef0f52e3a983b67abf4714448a41dd7ffd6d32d32da69d62081c68ad7882 and sweepETH https://etherscan.io/tx/0xb61413c495fdad6114a7aa863a00b2e3c28945979a10885b12b30316ea9f072c
• Elliptic: Bybit hack, largest in history: https://www.elliptic.co/blog/bybit-hack-largest-in-history
• The Block: Bybit closes ETH shortfall (24 Feb 2025): https://www.theblock.co/post/342896/bybit-ceo-says-exchange-has-closed-shortfall-in-eth-reserves-plans-to-release-audited-por-report
• Cointelegraph: two-thirds of hacked Bybit funds remain traceable (Apr 2025): https://cointelegraph.com/news/two-thirds-hacked-bybit-funds-remain-traceable-ceo
• AWS STS API reference: GetSessionToken https://docs.aws.amazon.com/STS/latest/APIReference/API_GetSessionToken.html and AssumeRole https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html
• Wayback Machine captures of the file: https://web.archive.org/web/2025*/https://app.safe.global/_next/static/chunks/pages/_app-52c9031bfa03da47.js
• MDN: Subresource Integrity: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity