TON Scanner Skill

SkillCommunication

Use when the user wants to audit TON smart contracts for security vulnerabilities, scan FunC or Tact contracts for message chain replay, bounce handling, or gas issues, review TON DeFi protocols for actor-model concurrency flaws, or analyze asynchronous message passing security.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the TON Scanner Skill skill

What this skill tells your AI

The instructions your AI receives, as published by 0x-shashi/web3-audit-skills in skills/ton-scanner/SKILL.md and read by ahel’s review.

Purpose

Analyze TON (The Open Network) smart contracts written in FunC or Tact for security vulnerabilities. TON's actor-model architecture, asynchronous message passing, and TVM (TON Virtual Machine) create a fundamentally different security model from EVM-based chains.

TON Architecture Overview

┌─────────────────────────────────────────────────────────────────┐
│                         TON Network                             │
│                                                                 │
│  ┌──────────────┐    async messages     ┌──────────────┐        │
│  │  Contract A   │ ──────────────────► │  Contract B   │        │
│  │  (Shard 1)    │ ◄────────────────── │  (Shard 2)    │        │
│  │               │    bounce/reply      │               │        │
│  │  FunC / Tact  │                      │  FunC / Tact  │        │
│  └──────┬───────┘                      └──────┬───────┘        │
│         │                                      │                │
│         ▼                                      ▼                │
│  ┌──────────────┐                      ┌──────────────┐        │
│  │    Storage    │                      │    Storage    │        │
│  │  (Cells/BoC)  │                      │  (Cells/BoC)  │        │
│  │  pays rent    │                      │  pays rent    │        │
│  └──────────────┘                      └──────────────┘        │
└─────────────────────────────────────────────────────────────────┘

Key Differences from EVM

AspectEVM (Solidity)TON (FunC/Tact)
Execution ModelSynchronous, atomicAsynchronous, actor-based messages
Cross-Contract CallsAtomic within transactionNon-atomic, separate transactions
Storage CostOne-time gasOngoing rent (storage fees)
Data StructureKey-value mappingCell trees (max 1023 bits, 4 refs)
ReentrancyWithin same transactionNot possible (async messages)
Failure HandlingRevert entire txBounce messages, partial failure
LanguagesSolidity, VyperFunC (low-level), Tact (high-level)
Address Format20-byte, single chainWorkchain ID + 256-bit hash

Languages

LanguageLevelUsageSecurity Characteristics
FunCLow-levelCore contracts, jettons, NFTsDirect TVM access, manual cell serialization, easy to misuse
TactHigh-levelModern contractsType-safe, auto-serialization, safer defaults but newer
FiftAssembly-levelDeployment scriptsDirect TVM opcodes, used for contract deployment

Detection Capabilities

Critical Vulnerabilities

  • Message chain gas exhaustion: Multi-hop messages run out of gas before completing all operations
  • Missing bounce handling: Bounced messages not processed → permanent fund loss
  • Unbounded storage growth: Attacker-controlled data storage drains contract balance via rent
  • Missing replay protection: Same message processed multiple times

High Vulnerabilities

  • Carry-value attacks: Incoming message value used to fund outgoing messages without accounting
  • Cell overflow/underflow: Exceeding 1023-bit or 4-reference cell limits during serialization
  • Workchain ID confusion: Not validating workchain in address leads to cross-chain issues
  • Incorrect message mode flags: Wrong send mode causes unintended gas forwarding or balance drain

Medium Vulnerabilities

  • Storage fee drain: Contract balance slowly depleted by rent payments on stored data
  • Sharded message ordering: Assuming message order across shards causes race conditions
  • Tick-tock contract abuse: Automatic execution contracts with expensive operations
  • Missing accept_message() in external handlers: External messages silently dropped without gas acceptance

Real-World TON Incidents

IncidentVulnerabilityImpact
Early Jetton implementationsMissing bounce handlingToken loss on failed transfers
DNS auction contractsGas exhaustion in multi-message chainsAuctions stuck irrecoverably
Various NFT marketplacesReplay attacks (no seqno)Duplicate sales/purchases
Storage-based attacksUnbounded storage growthContract balance drained by rent

Resources

Related Scanners

Error Code Reference

Common TON/FunC error codes encountered during audits. TON uses numeric exit codes in throw() / throw_if() / throw_unless() statements.

Standard TVM Exit Codes

Exit CodeNameMeaning
0SuccessNormal successful execution
2Stack underflowToo few arguments on the stack — FunC function signature mismatch
3Stack overflowStack exceeded limits
4Integer overflowInteger does not fit into 257-bit signed range
5Integer out of rangeValue outside expected range for operation
6Invalid opcodeUnknown TVM instruction — possible code corruption
7Type check errorWrong type on stack — e.g., expected cell, got integer
8Cell overflowCell data exceeds 1023 bits or 4 references
9Cell underflowAttempted to read more data than cell contains
10Dictionary errorInvalid dictionary (hashmap) operation
11Unknown errorGeneral "most common" error
13Out of gasComputation exceeded gas limit
-14Out of gas (credit)Gas credit depleted before accept_message()

Common Application Exit Codes (Convention)

Exit Code RangeConventionMeaning
30-39Auth errorsUnauthorized sender (throw_unless(33, ...))
40-49State errorsInvalid contract state for operation
50-59Balance errorsInsufficient balance for operation
60-69Validation errorsInvalid input parameters
100-199Jetton StandardJetton (token) specific errors
200-299NFT StandardNFT specific errors
300-399DEX errorsLiquidity pool / AMM errors
400+Application-specificCustom application logic errors

Jetton Standard Error Codes

Exit CodeMeaning
73Insufficient jetton balance for transfer
74Not enough TON for gas fees attached to transfer
75Invalid sender — not the jetton wallet owner
76Discovery: unknown jetton wallet

Troubleshooting

IssueLikely CauseSolution
Bounce handler vulnerabilities missedScanner doesn't analyze bounced<> message handlersAudit all recv_internal branches that handle bounced messages — check for state rollback correctness
Message chain replay not detectedScanner analyzes single messages, not chainsTrace full message chains: initial message → internal messages → bounces; check seqno/query_id uniqueness
Gas estimation issues not flaggedScanner doesn't model TON gas economicsFlag messages without accept_message() or with insufficient gas forwarding via msg_value
Actor model concurrency bugs missedScanner uses synchronous mental modelMap all async message flows; check for time-of-check/time-of-use between separate messages
FunC vs Tact pattern mismatchScanner patterns written for FunC, code is in TactVerify Tact's auto-generated FunC output; Tact handles some safety checks automatically
Storage fee drain not caughtScanner doesn't model TON storage costsCheck that contracts handle storage_fee deductions; verify minimum balance maintenance

Signals

GitHub stars
60
Forks
10
Last commit
Feb 2026
Advanced
Catalog kind
skill
Gateway key
ton-scanner
Source
github.com/0x-shashi/web3-audit-skills