tolk-less

May 22, 2026 · View on GitHub

tolk-less is a Tolk compiler fuzzer. It demonstrates a zero-effort way to find nasty math bugs in the compiler.

  • Key idea: sound EMI mutations + bitwise diff of TVM outputs across Tolk/FunC × optimized/non-optimized builds
  • Target: arithmetic miscompilations
  • Effort: <1 hour to vibecode a 1k-loc script, 2 hours to execute and review
  • Result: 13 semantic drifts in arithmetic, 6 ICEs

Usage

Clone with submodules, build ./third-party/ton and execute:

SEED=0 MKL=10 MKH=20 N=195000 MD=4 MK=3 Z3=1 ABORT=0 ZINP=1 ZIT=500
python3 tl.py

Findings

⚠️ Note: No Tolk contracts on mainnet, no bug bounty coverage. Nothing exploitable.

Commit: 4539cfab

Miscompiles

ICE

  • tolk-bool-and-chaintrue && true && true && true && expr crashes Tolk (tolk.h:892)
  • tolk-codegen-208 — nested !((true||false) != true) shape crashes Tolk (codegen.cpp:208)
  • tolk-codegen-578 — duplicated false ? K : a ternary + (0<<3)>>3 shape crashes Tolk (codegen.cpp:578)
  • func-stack-validatea + ((a + (-1 ? 0 : 1)) * 0) crashes FunC (func.h:1622)
  • func-codegen-168(a + (0 ? c : a*0)) * 0 crashes FunC (codegen.cpp:168)

Further work

If you are serious about spending time on this, look at:

  1. Better oracles: anything is better than the FunC oracle, some sane alternatives:
  • hand-written concrete interpreter
  • translation validation TVM/Fift→SMT for equivalence checks
  1. Program generation beyond constants and arithmetic
  2. EMI synthesis: start from the Souper paper and this work