For judges and auditors

Don't take our word for it. Run it.

Everything on this page is rendered from the reports in docs/results, written by the runs below. Each claim is a question, its answer, and the evidence, and a claim that fails fails its run. These results were recorded with Fe 26.6.0 on mac_arm64; CI repeats them on Linux.

One command, with only Docker
every offline check: make ci, with no networkshell
docker run --rm ghcr.io/femtech-web/dimension              # the published image
docker build -t dimension . && docker run --rm dimension   # or build it from a clone

Any other target runs the same way, such as docker run --rm ghcr.io/femtech-web/dimension make demo; the fork and live targets use the network, which docker run has by default. On x86-64 every check runs. On arm64, Docker on Apple silicon included, Fe 26.6.0 has no native backend, so those checks are skipped and say so.

Or step by step, from a clean clone
  1. 01
    Install
    Fe 26.6.0 downloaded and checksum-verified; forge-std and OpenZeppelin pinned by commit.
    $ make toolchain && make reference-deps
  2. 02
    See both incidents
    Each mistake written in Fe, the compiler's verdict, the fix, and the evidence the fork runs saved.
    $ make demo
  3. 03
    Run everything offline
    Formatting, unsafe policy, unit tests on both backends, compile-fail cases, probes, the differential test, the search, the EVM contracts with the typed-vs-hand-written pairs, the vault, and a fresh project through the CLI. About two minutes.
    $ make ci
  4. 04
    Against the real chains
    The attacker's own transactions, the deployed pool, and Moonwell's market on Base: public RPCs by default.
    $ make replay fidelity moonwell
  5. 05
    On a public chain
    The deployment on Base Sepolia, read back: every receipt, each contract's code against this build, every logged outcome, and the oracle, the declarations and the vault at the latest block.
    $ make live
  6. 06
    Try to break it
    Plants each bug below in a scratch copy and requires the check meant for it to fail.
    $ make mutants

The guided tour, with where each claim lives in the code →

Every claim

Questions, answered by runs.

Balancer's Solidity against the Fe port make differential

  • holds
    Does the Fe port compute exactly what Balancer V2's Solidity computes, reverts included?
    220,000 vectors over 22 functions: 170,900 identical results, 49,100 identical reverts, 0 mismatches

The Fe port against the deployed pool make fidelity

  • holds
    Does the Fe port return exactly what the deployed pool returned, on its state the block before the exploit?
    669 quotes against Vault.queryBatchSwap at block 23,717,396: 627 identical values, 42 identical reverts, 0 mismatches

The attacker's own transactions, step by step make replay

  • holds
    Does the Fe port compute every step of the real exploit exactly as Balancer's Vault did?
    360 of 360 steps across the three attack transactions (121, 121, 118): every amount equal
  • holds
    After each attack transaction, does the faithful kernel hold exactly what the real pool held?
    WETH and osETH balances and BPT supply equal after each transaction; value per BPT 1.02735 -> 0.02019 -> 0.000412136 -> 9.19223e-06
  • holds
    Do the typed and guarded kernels stop the attacker's own sequence?
    yes: transaction 1 reverts at step 25 with BAL#001; transaction 2 reverts at step 25 with BAL#001; transaction 3 reverts at step 22 with BAL#001. Before that, value per BPT on the typed kernel rose from 1.0273 to 1.1856
  • holds
    From the real dust state, does an attacker who re-plans every swap find a loss on Balancer's arithmetic, and none on Dimension's?
    on Balancer's arithmetic: -43.9% in 90 swaps. On the typed and guarded kernels, never below where it started; after 90 swaps it ends +13.1%

Native search over the three kernels make explore

  • holds
    Does the faithful port lose value per BPT on GIVEN_OUT exits, as Balancer V2 did?
    57990 losing exits, worst 14.8607%
  • holds
    Do the types alone remove the losses at Balancer's two _upscale sites?
    swapGivenOut 48 -> 0; exitGivenOut 57990 -> 8
  • holds
    Are the operations the types do not change identical with and without them?
    swapGivenIn, exitGivenIn, joinGivenIn and joinGivenOut counts match between faithful and typed
  • holds
    With the runtime guard added, does any operation lose value per BPT or store an invariant its balances do not back?
    guarded: 0 losses and 0 stored-invariant violations in every operation kind
  • holds
    Does the guard reject exactly the operations that would have lost value, and nothing else?
    exitGivenOut 8, joinGivenIn 9 rejected; each equals the typed losses
  • holds
    Can a repeated-exit attacker gain against the faithful kernel, and is it always a loss with Dimension?
    pool 300/300: faithful -0.743 D, typed -95.011 D, guarded -95.011 D; pool 8/8: faithful +1.386 D, typed -2.493 D, guarded -2.493 D; pool 1000/1000: faithful +20.923 D, typed -151.416 D, guarded -151.416 D

The three pool contracts on an EVM make evm

  • holds
    Deployed on an EVM, does the faithful pool let a repeated-exit attacker take value from LPs?
    value per BPT -3.38% over 51 exits
  • holds
    Do the typed and guarded pools keep the value behind each BPT under the same attack?
    typed +19.51%, guarded +19.51%
  • holds
    Does every optimization level compute the same attack, to the wei?
    the attack's exits and value per BPT on each kernel are identical at -O0, -O1, -O2 and -Os
  • holds
    Built on Dimension itself, does typed code return exactly what the same code written by hand on raw u256 returns, at every optimization level?
    4,096 calls per level over 8 functions (the four roundings, an ERC-4626 vault's four previews), reverts included: all equal at -O0, -O1, -O2 and -Os
  • holds
    Above -O0, is Dimension's typing free, gas for gas, against the same code written by hand?
    at -O1, -O2 and -Os the roundings compile to identical bytes, and the vault to the same size with identical gas on every call. At -O0, which no one deploys, typed costs rounding +7.8%, vault +15.0% per call

Moonwell's cbETH market on Base forks make moonwell

  • holds
    Did Moonwell's deployed oracle price cbETH at the bare exchange rate throughout MIP-X43's window?
    12 blocks from 42,194,663 to 42,538,948: 1.1224 USD to 1.1229 USD
  • holds
    At the same blocks, does the Fe oracle price cbETH as cbETH/ETH times ETH/USD from the same feeds?
    2,091.1616 USD to 2,243.1581 USD, asserted equal at every block to the product of the two feeds' answers
  • holds
    Where Moonwell's oracle was right, is the Fe price identical to it?
    block 42,194,662: 2206683650838065175827 wad, block 42,538,949: 2091161605700000000000 wad, identical
  • holds
    Is MIP-X43's misconfiguration rejected in each form it can take, and at which layer?
    compile: 8-0000 type mismatch; bind: WrongDecimals; read: AnswerOutOfBand

Each declared feed against Chainlink's directory make feeds

  • holds
    Is every feed in Moonwell's registry the feed Chainlink lists at its address, as the chain reports it?
    CBETH_ETH is "CBETH / ETH": 10 of 10 checks; ETH_USD is "ETH / USD": 10 of 10 checks
  • holds
    Is MIP-X43's declaration, the cbETH/ETH feed as cbETH/USD, rejected before deployment?
    declared CBETH/USD, listed CBETH/ETH. Chainlink lists CBETH/USD at 0xd7818272B9e248357d13057AAb0B417aF31E817d (8 decimals, heartbeat 1,200 s)
  • holds
    Is a wrong feed rejected even when it compiles and passes every check Dimension makes on chain?
    the cbETH/USD feed declared as ETH/USD compiles, and on chain its decimals, answer, freshness and band all pass: 1,858.68 USD per ETH, while ETH/USD reads 1,625.55 USD per ETH. feed-check: declared ETH/USD, listed CBETH/USD

The ERC-4626 vault against OpenZeppelin make vault

  • holds
    Do the vault's roundings, which no line of it names, give exactly what OpenZeppelin's ERC4626 gives?
    40,000 vectors over the four previews, each equal to OpenZeppelin v5.1.0 in the same state
  • holds
    Does the comparison test the rounding direction, not only the formula?
    in 33,684 of the vectors the exact result is fractional, so rounding the other way would differ

The deployment on Base Sepolia, read back from the chain make live

  • holds
    Did every recorded transaction succeed, in the block the record gives?
    21 transactions from 0x84e223Fb745B157a5f71d831634302B968129dB3, blocks 61,288,219 to 61,289,310
  • holds
    Is each contract's code on chain exactly the code this repository builds?
    7 Fe contracts byte-identical to fe build with Fe 26.6.0; LiveRecorder and MockRateProvider (rate 1.21) identical to forge's build apart from Solidity's metadata hash
  • holds
    On chain, does the attacker's planned batch lower the value behind each share of the pool that rounds as Balancer V2?
    51 exits in one transaction (0x0ecf…9520, block 61,289,251): 1.0000 to 0.9662 per BPT (-3.38%), equal to the wei to LivePlan's run of the same batch
  • holds
    Do the typed and guarded pools reject the same batch on chain, keeping the value behind each share?
    TypedPool: reverted Error("BAL#004") at exit 51 of 51, as LivePlan finds; 1.0000 per BPT unchanged; GuardedPool: reverted Error("BAL#004") at exit 51 of 51, as LivePlan finds; 1.0000 per BPT unchanged
  • holds
    Without the exit they reject, does the same batch raise the value behind each typed and guarded share instead?
    TypedPool: 50 exits, 1.0000 to 1.1391 per BPT (+13.91%); GuardedPool: 50 exits, 1.0000 to 1.1391 per BPT (+13.91%), equal to the wei to LivePlan
  • holds
    Does the oracle price cbETH as cbETH/ETH times ETH/USD, read from Chainlink's Base Sepolia feeds with every check?
    block 61,374,818: 1,857.42 USD, equal to the wei to the product of the feeds' answers; recorded on chain at deployment: 1,989.70 USD (block 61,289,281)
  • holds
    Declared as an 8-decimal USD feed, is cbETH/ETH rejected when the contract binding it is deployed?
    WrongDecimals(0x91b2…944d, 8, 18) in 0x432c…0b53, block 61,289,286
  • holds
    Declared with its real 18 decimals, does it deploy, and is every read of it rejected?
    deployed at 0xc3e3…45f1; its read reverted AnswerOutOfBand(0x91b2…944d: 1.1443, outside 100 to 100,000) in 0x1771…7289, and AnswerOutOfBand(0x91b2…944d: 1.1443, outside 100 to 100,000) at block 61,374,818
  • holds
    Declared correctly, does Chainlink's own cbETH/USD feed read through the same contract?
    block 61,374,818: 1,863.56 USD, its answer to the wei; the oracle's price through ETH is 0.33% from it
  • holds
    Does the deployed typed vault preview as OpenZeppelin's ERC4626?
    24 of 24 previews equal OpenZeppelin's formulas, in 3 states including a first deposit after a one-token donation

The Balancer kernels in WebAssembly, against the EVM make wasm

  • holds
    Compiled to WebAssembly from the same source, do the kernels compute every step of the batch exactly as the deployed contracts do on the EVM?
    154 values per BPT, the start and after each exit on each kernel, equal to forge's run of the same contracts to the wei; faithful 1.0000 to 0.9662; typed and guarded fail exit 51 with BAL#004, as on the EVM
  • holds
    Is the module reproducible, and is it the one the site serves?
    two builds byte-identical: 110,023 bytes, sha256 3f12cdf8f7952bad…, unchanged in web/public
  • holds
    Do the unit suites run on the WebAssembly backend?
    24 tests pass in 4 suites; 1 not built: debiting_more_than_is_held_reverts, which uses the EVM's `should_revert`

The same kernels as a native library, called from C make native

  • holds
    Built as a native static library and called from C, do the kernels compute every step of the batch exactly as the deployed contracts do on the EVM?
    154 values per BPT, the start and after each exit on each kernel, equal to forge's run of the same contracts to the wei; faithful 1.0000 to 0.9662; typed and guarded fail exit 51 with BAL#004, as on the EVM

Dimension as someone else's dependency make consumer

  • holds
    Can a new project depend on Dimension from git, and does it get Dimension's checks?
    `dimension new` creates the quickstart taking Dimension at 5a1aafe by git source; it builds and passes its 3 tests; an incoming amount used as an outgoing one is rejected with 8-0000
  • holds
    Does `dimension check` pass that project, list its labels for review, and fail it once it can forge values Dimension trusts?
    the new project: 6 of 6 checks ok, no warnings; its 3 labels listed for review (given<USDC, In>, owed<USDC, Out>, owed<USDC, In>); with allow_unsafe set on Dimension it fails allow_unsafe; with a price forged by a pointer cast, which compiles, it fails unsafe code; with the forgery between the strings "/*" and "*/", it fails unsafe code; with a feed built where feed-check cannot read it, it fails feeds
  • holds
    In each project compared, does `dimension check` list exactly the label calls a second compiler method finds?
    identical to the compiler's list in each of the projects compared: tests/labels 11, examples/quickstart 3, ingots/vault 6, ingots/balancer_v2 18, ingots/balancer_explorer 24, ingots/moonwell 0. tests/labels writes them in every form found so far: type inferred, aliased, re-exported and renamed in another file, through an aliased module and a module path, generic in the direction, a holding and a supply, and decoys: a comment, a string, a local function sharing a label's name, and an unrelated function sharing a re-exported one

The same library and tests on Fe 26.7.0 make compat

  • holds
    On fe 26.7.0 (e6e6342), does every ingot type-check, and every unit suite pass on the backends it declares?
    6 of 6 ingots type-check; 11 of 11 suite runs pass, 63 tests
  • holds
    On fe 26.7.0 (e6e6342), is every compile-fail case rejected with its expected code, and its corrected twin accepted?
    23 of 23 cases

Planted bugs, each caught by the check meant for it make mutants

  • holds
    Is every planted bug in the safety-critical code caught by the check meant to catch it?
    22 of 22 mutants caught, each for the reason expected of it, across 7 layers: bind time, compile time, port fidelity, read time, runtime guard, types, unsafe policy
Planted bugs

Would the checks notice if the code were wrong?

Bug plantedLayerCaught byEvidence
Balancer's _upscale put back into the typed pool's exitcompile timecaught
fe check ingots/balancer_v2
error[8-0000]: type mismatch
An amount leaving the protocol is admitted rounded down, as Balancer didtypescaught
make unit
FAIL core
A charge is settled rounded down, in the caller's favourtypescaught
make unit
FAIL core
The seal's key is made public, so code outside Dimension can implement the seal and add a flowtypescaught
make compile-fail
FAIL compile_fail/custom_flow_through_the_seal
An exchange gives back value moving the same way as what it receivedtypescaught
fe check ingots/vault
error[8-0000]: type mismatch
A feed's answer is not checked against its bandread timecaught
make unit
FAIL oracle
A feed's answer is not checked for stalenessread timecaught
make unit
FAIL oracle
A feed's reported decimals are not checked when it is boundbind timecaught
make unit
FAIL oracle
A rate provider's answer is not checked against its bandread timecaught
make unit
FAIL oracle
The share-value comparison always passesruntime guardcaught
make explore
FAILS With the runtime guard added, does any operation lose value per BPT or store an invariant its balances do not back?
The guarded pool's exact-out exit runs without its guardruntime guardcaught
make explore
FAILS With the runtime guard added, does any operation lose value per BPT or store an invariant its balances do not back?
A risk policy's bonus no longer has to avoid bad debt at the thresholdcompile timecaught
make compile-fail
FAIL compile_fail/liquidation_bonus_creates_bad_debt
A held balance can be credited with an amount labelled as leavingtypescaught
make compile-fail
FAIL compile_fail/vault_deposit_labeled_as_leaving
An amount in internal 18-decimal units counts as token unitstypescaught
make compile-fail
FAIL compile_fail/internal_units_credited_to_balance
A held balance can be credited with an amount of another tokentypescaught
make compile-fail
FAIL compile_fail/deposit_credited_to_another_token
A supply the protocol issues can be credited, as if the protocol held ittypescaught
make compile-fail
FAIL compile_fail/share_supply_credited_as_held
The port drops the + 1 Balancer adds in calc_in_given_outport fidelitycaught
make differential
22 functions, 200000 vectors: 156219 succeeded identically, 43781 reverted identically, 2 mismatched
The port's mulUp rounds downport fidelitycaught
make differential
22 functions, 150005 vectors: 119597 succeeded identically, 30408 reverted identically, 7 mismatched
The vault counts two virtual shares on deposit instead of oneport fidelitycaught
make vault
[FAIL: previewDeposit: 3992760530 != 3962963809; counterexample: calldata=0x7c407e8000000000000000000000000000000000000000000000000000000000…
A protocol ingot gains an unsafe blockunsafe policycaught
make unsafe-policy
unsafe code outside dimension::value::testing
Joins and exits stop minting the protocol's fee on their own swap feesport fidelitycaught
make replay
[FAIL: every step must compute what Balancer computed: 94 != 121] test_attack1() (gas: 13752828)
The registry declares ETH/USD with 18 decimalsbind timecaught
make moonwell
[FAIL: the Fe oracle must bind the real feeds] test_pricesThroughTheWindow() (gas: 133752)

A mutant counts as caught only if its check fails for the reason expected of it; a failure for any other reason, such as a network error, is reported as inconclusive and fails the run. The last two need a fork: run all of them with make mutants FORKS=1.

Found along the way

A Fe compiler issue, reduced to 60 lines.

fe build --help describes -O s as size-oriented and "currently similar to 2". On Fe 26.6.0 a 60-line program is 364 bytes at -O 2 and 513 at -O s: the size level skips the shared revert tails -O 2 forms. In the Balancer pool it also emits a large solver three times instead of once, for +14% in all.

Reported upstream as argotorg/fe#2043, with the reproducer kept in this repository.

What the compiler rejects

23 constructions, each with a corrected twin.

CaseMechanismErrorTwin
add_collateral_to_debtAdding a debt value to a collateral value, which hides the shortfall a solvency check must see8-0000passes
balancer_floor_upscale_as_admittedAn amount leaving the pool is scaled with floor rounding and handed to the math as if it had been admitted8-0000passes
compose_prices_without_shared_assetMultiplying cbETH/ETH by USD/ETH, which is not a cbETH/USD price8-0000passes
custom_flowDefining a new flow with its own choice of admission and settlement rounding6-0003passes
custom_flow_through_the_sealImplementing the seal from outside to add a flow, which Fe 26.6 allows for a private trait (argotorg/fe#2036): the seal requires the private Key2-0003passes
custom_rounding_directionAdding a third rounding direction that could round in the caller's favour6-0003passes
custom_rounding_through_the_sealImplementing the seal from outside to add a rounding direction, which Fe 26.6 allows for a private trait (argotorg/fe#2036): the seal requires the private Key2-0003passes
deposit_credited_to_another_tokenA two-token pool credits a WETH deposit to its USDC balance: a held balance takes only amounts of its own token8-0000passes
forge_admitted_quantityBuilding an admitted quantity directly, skipping the rounding admission applies2-0003passes
forge_priceBuilding a trusted price from a raw number outside the verified boundary2-0003passes
internal_units_credited_to_balanceA deposit is credited to a raw USDC balance in internal 18-decimal units, overstating it by 10^12: only amounts in token units can be credited6-0003passes
liquidation_bonus_creates_bad_debtA liquidation bonus so large that liquidating at the threshold needs more collateral than the position holds8-0093passes
ltv_at_liquidation_thresholdA loan-to-value equal to the liquidation threshold, so a new loan can be liquidated at once8-0093passes
moonwell_component_feed_in_usd_marketcbETH's USD price is configured as the cbETH/ETH exchange-rate feed alone, written against the real Base feed registry8-0000passes
oracle_read_without_effectsReading a price feed from a function whose signature does not declare the call and clock capabilities it uses8-0036passes
payout_settled_as_chargeA payout rounded down is used where the amount charged must be rounded up8-0000passes
scale_asset_with_too_many_decimalsScaling a 24-decimal asset into 18-decimal internal units, which cannot be done without losing value8-0093passes
share_supply_credited_as_heldA redemption credits the shares coming back to the vault's share supply, as if the vault held them, which would raise the supply instead of retiring them: a supply is only issued or retired2-0010passes
test_constructor_from_production_rootA production root reaching Dimension's unsafe test constructors without trusting them in fe.toml16-0015passes
typed_pool_with_balancer_upscaleInside the typed pool, one line of Balancer V2 is put back: the amount out is scaled with _upscale's floor rounding and handed to StableMath8-0000passes
value_with_another_assets_priceValuing a USDC balance with the cbETH price8-0000passes
vault_deposit_labeled_as_leavingA vault deposit labelled, consistently, as assets leaving the vault: every signature agrees, so its shares round up in the depositor's favour, and only the vault's books refuse the label: the deposit cannot be credited to its assets, nor its shares issued8-0000passes
vault_deposit_rounds_shares_upA vault deposit computes the shares to issue as if the deposited assets were leaving, which rounds the shares up, in the caller's favour8-0000passes

Also: 6 of 6 unit suites pass on the EVM and natively, and 20 of 20 language probes reproduce their recorded diagnostics and bytecode hashes. Run any case live with make show CASE=<name>.