Poisoned Pipeline / Incidents / AS509
fragment-api-py 14.4.2 was an older release republished under a higher version number with a wallet sweep wired into client startup
fragment-api-py is a Python client for Telegram's Fragment marketplace. To
pay for purchases it holds the user's The Open Network wallet seed, which
makes it a package whose whole purpose is to be given a key to money.
Version 14.4.2, uploaded to PyPI at 12:12 UTC on 8 November 2026, moves
that money out: opening the client sends the wallet's Tether and almost
all of its TON to an address the attacker chose. SafeDep published the
analysis on 10 November and the version has since been deleted from PyPI.
The release is not a fork of the previous one. A diff against 14.4.1 is
large and reads like a bad refactor — modules missing, modules added,
nearly every file touched — which is what makes it hard to review. A
byte-for-byte comparison against every earlier wheel resolves it: 14.4.2
is the 13.0.0 release with a backdoor in four files and a higher version
number. Twenty-eight of 32 files are identical to 13.0.0; the changes are
confined to __init__.py, client.py, types/models.py and utils/wallet.py,
and the two test modules present in 13.0.0 are dropped. In __init__.py
only the version string differs. The higher number is the whole delivery
mechanism: pip install -U and any dependency resolver that prefers the
newest release both select it, and no resolver has a reason to compare
14.4.2 against 13.0.0.
The theft is a function called sweep_wallet_to_self() in utils/wallet.py.
The name reads as a consolidate-funds helper and the body is written in
the library's own idioms — its wallet lock, its provider, its error types
— and returns a SweepResult model like the real API calls. Line 172
hardcodes the destination as
UQAolfC7fyf__0H-1GzG9y5ZtV2CPC7yDno4W2cSVuYlJ6DU. A companion
sweep_amounts() keeps back 0.1 TON for the transfer, 0.02 TON as margin
and a further 0.06 TON when the wallet holds USDT for the jetton
transfer's gas, and sends everything else. Where the wallet holds USDT,
the sweep builds a JettonTransferBuilder for the full jetton balance and
a TONTransferBuilder for the remainder, so both leave in one wallet
message.
The trigger is client construction, not a purchase. The attacker added a
call to _ensure_swept() in __aenter__ at client.py:295, so the ordinaryasync with FragmentClient(seed=...) line drains before any user code
runs; a second call at the start of execute_prepared() in
utils/wallet.py:410 catches code that never uses the context manager. A
flag and a lock make it run once per client, so a victim who keeps
working does not see repeated transfers in their wallet history. Source
archive timestamps put the backdoor's authoring at 2026-10-12, about four
weeks before the upload.
Two wallets are known to have lost funds. The first, 0.879963599 TON at
18:19 UTC on 8 November, never reported anything: SafeDep found it in the
attacker wallet's history, and the amount matches the fee formula
exactly. Three seconds later the victim wallet paid the library's own
FEE_ADDRESS from types/constants.py, which is how the analysis ties that
transfer to fragment-api-py rather than to another drainer. That drain
happened about six hours after the upload, so the backdoor took money on
its first day. The second, 43.982037696 TON plus 0.01 TON at 23:02 and
23:18 UTC on 9 November, is the one GitHub issue #8 reports. The three
inflows total 44.872001295 TON and the attacker wallet sent
44.871449124 TON out at 07:11 UTC on 10 November to UQDJvvp…lVYbM8,
which is the same amount less network fees. That wallet has been active
since at least 22 October, received and sent about 1,000 TON on 1
November and made recurring payments to one address on 30 and 31 October
and 1 November. SafeDep lists those two counterparties as unattributed
leads, not as exchange deposits it has identified.
How the release reached the registry is unresolved, and the report is
careful about it. No tag and no commit: GitHub tags end at v14.4.1 and
every other recent release has one. The project publishes through a
workflow holding a long-lived PyPI API token, and the maintainer builds
most releases locally. The 14.4.2 wheel was built on a Windows machine
set to UTC+4, which matches the maintainer's local build profile — and
an attacker can fake a timezone, so that observation does not identify
who uploaded it. A compromised machine, a stolen token and an insider
all fit what is visible, and only PyPI and the maintainer can see which
credential was used.
There is no download count, install base or loss figure beyond the two
wallets. The package is small and niche, the malicious version existed
for roughly two days, and the second victim found it by reading a wallet
balance rather than a scanner alert.
Mapped techniques
- T0230 Re-release an older version under a higher version number
- T0109 Publish malicious artifact
- T0138 Backdoor in code
- T0159 Malicious artifact execution
- T0191 Malicious code in artifacts
supply-chain Republish an old release as a new version
14.4.2 is 13.0.0 plus a backdoor and a bumped version string.
28 of 32 files are byte-identical to 13.0.0, the four changed
files carry the payload, and the two test modules are removed.
Against 14.4.1 the diff looks like a mangled refactor, which is
what a reviewer sees first; only a comparison against every
earlier wheel resolves the base. The higher number is what makes
resolvers, pip install -U and any newest-wins policy pick it.
Uploaded to PyPI at 12:12 UTC on 8 November 2026 as
fragment_api_py-14.4.2-py3-none-any.whl, 67,491 bytes, sha256
24c402f3c47e3d8bc29597d000def922fa507970e47322d6fd7f28a4d253d447,
with sdist fragment_api_py-14.4.2.tar.gz, 57,595 bytes, sha256
f046a53fa9007ff4cecc3ca7c5811b3fe44b09905af162d260885d091519531e.
No GitHub tag and no commit back it; tags end at v14.4.1. The
version has since been deleted from PyPI.
post-supply-chain The client sweeps the wallet it was given the seed for
sweep_wallet_to_self() sits in utils/wallet.py behind a
legitimate-sounding name, uses the library's own lock, provider,
error types and SweepResult model, and hardcodes the destination
at line 172. Source timestamps put its authoring at 2026-10-12,
four weeks before publication.
One call to _ensure_swept() in __aenter__ at client.py:295 makes
the ordinary async with FragmentClient(seed=...) drain before
user code runs. A second call at the start of execute_prepared()
in utils/wallet.py:410 covers code that skips the context
manager. A flag and a lock keep it to one sweep per client so the
wallet history shows a single transfer.
The sweep keeps 0.1 TON for the transfer, 0.02 TON margin and
0.06 TON of jetton gas when USDT is held, and sends the rest —
USDT as a JettonTransferBuilder and the TON remainder in the same
wallet message. Known losses are 44.872001295 TON across two
wallets, cashed out at 07:11 UTC on 10 November.
Framework gaps noted
- How 14.4.2 was published is not established. There is no tag and no commit; the workflow holds a long-lived PyPI API token; the maintainer builds most releases locally, and the wheel's Windows/UTC+4 build profile matches the maintainer's own. A compromised machine, a stolen token and an insider all fit, and only PyPI and the maintainer can see which credential was used. Not mapped as T0112 on the record.
- The library is handed the seed by design, so nothing is harvested from the environment or from files. The theft uses the access the package is supposed to have, which is why T0140 and T0184 do not apply.
- Two victims are known because one reported it and one was found in the attacker wallet's history. How many installs ran the backdoor and whether other wallets were drained elsewhere are unknown.
- The two other counterparties in the attacker wallet's history — the recipient of about 1,000 TON on 1 November and the recurring payments on 30 October, 31 October and 1 November — are unattributed. SafeDep presents them as leads for exchanges and investigators.
- Removing the package does not restore funds, and no revocation exists for a wallet transfer. SafeDep's guidance is to check the installed version and grep site-packages for the hardcoded address, the function name and _ensure_swept.