Dev.to Security 🔐 Cybersecurity 👁 0 📖 2 min read

The invest that minted nothing — TTSwap's zero-share dust bug

The invest that minted nothing — TTSwap's zero-share dust bug Last one from TTSwap's nine-fix bounty sweep (PR #336, bounty #318+#323): investGood accepted investments so small they minted zero shares — and kept the to

The invest that minted nothing — TTSwap's zero-share dust bug

Last one from TTSwap's nine-fix bounty sweep (PR #336, bounty #318+#323): investGood accepted investments so small they minted zero shares — and kept the tokens. The fix is one guard clause. The interesting part is how honestly the downstream impact was scoped.

The bug class

At high leverage, a tiny invest can round down to investShare == 0: the caller's tokens move into the pool, the state mutates, and nothing is minted back. The submission's PoC is minimal — 1 raw unit at 31x leverage — and on unfixed code the share balance comes back 0 while the invest "succeeds."

Why it matters beyond free tokens: those unowned deposits inflate the pool's virtual quantities without a corresponding claim. The submission claims this can permanently brick the good via the getInvestPower arithmetic path — the same underflow class as bounty #328, which was independently verified. QA's verdict on #318 is precise about the boundary: the zero-share accept is real and reproduced, the brick mechanism is "plausible and consistent" but UNVERIFIED end-to-end — and not needed for the fix's validity.

The fix pattern

Reject the degenerate case before any state changes:

if (investResult_.investShare == 0) {
    revert TTSwapError(38);
}

One guard in L_Good.investGood, placed before mutation. On the fix branch: 3/3 dedicated tests pass — zero-share reverts with error 38, normal invests unaffected. On base, the reproduction fails exactly as claimed ("next call did not revert as expected"). The "61/61 focused" suite claim stays UNVERIFIED — QA didn't fully rerun it.

Why skeptical devs respect this

This submission models the truth contract better than most audit reports: it proves the bug it can prove (zero shares minted on a real call path, exact revert code on fix), and it labels the blast radius it couldn't independently establish. When QA verified the sibling underflow (#328) separately, the two findings corroborate each other — but the article doesn't blur that into "confirmed." Verified mechanism, plausible impact, disclosed boundary.

The meta-lesson

Rounding is a security boundary. Any amount / sharePrice that can floor to zero is an unpriced deposit — check every mint path for the "succeeded but gave nothing" case, and revert before state mutation, not after. And when writing up findings: prove the mechanism you executed, mark the impact you didn't, and let reviewers connect the dots.

That's the full TTSwap sweep amplified — nine QA-verified fixes, each with reproduced failures and honestly scoped claims. Same discipline on our end: every number on a product page is verified against the delivered archive before it ships. Free tools and the auto-updating store link are on the nexusfoundry dev.to profile.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.