Curriculum·G305 Reading Contracts Fluently·about 34 min
Read the inputs it trusts, and the ones it does not check
By the end of this lesson you can
- →Explain that a function acting on an unchecked input is trusting whatever the caller supplies
- →Describe how Qubit's deposit credited bridged collateral without verifying real assets had arrived
- →Reason that the most dangerous line is often the input a function never validates
- →Read a function for which inputs it trusts and which it fails to check before acting on them
Graduate · enrolled learners
This lesson opens with Qubit Finance, January 2022.
- What happened
- Qubit ran a cross-chain bridge whose deposit function was meant to accept a real asset on one side and credit the depositor with bridged collateral, called xETH, that they could then borrow against. But the function did not properly validate its inputs: a token-address input was not checked, and a path let a deposit be credited as if assets had arrived when in fact none had. So an attacker called the deposit function in a way that credited them enormous xETH collateral without ever sending real value, then used that phantom collateral to borrow out about 80 million dollars of real assets from the protocol. Nothing exotic was broken; the function simply trusted an input it should have verified, acting on the caller's supplied data as though it were true. The gap was readable by asking, of the deposit function, which of its inputs it checked and which it took on faith, and the fatal one was the assumption that the assets the caller claimed to deposit had actually been received.
- The decision point
- A function that acts on an input without validating it is trusting whatever the caller supplies, so the most dangerous line in a contract is often not a complex calculation but a simple input, a token address, an amount, a claim that funds were sent, that the function never checks before acting on it. Qubit is the case: its bridge deposit credited bridged collateral based on inputs it did not verify, including whether real assets had actually arrived, so an attacker supplied a deposit that credited them enormous phantom collateral and borrowed about 80 million dollars of real value against it. This is the final reading skill of the course, and it is the one that catches a whole class of exploits: a function that credits, pays, or acts on the strength of an unchecked input is only as honest as the caller, and the caller is an adversary. The pattern to read for is a function that takes an input, an address, an amount, a proof, a flag, and then does something valuable based on it without confirming the input is legitimate: that the address is an allowed token, that the amount was actually transferred, that the claimed deposit really arrived. So the discipline is to read a function's inputs and ask, for each, whether the function validates it before acting or simply trusts it, and to treat any valuable action taken on an unchecked input as an open door, because the caller controls the inputs and will supply whatever benefits them. Qubit is what an unchecked deposit input becomes when a function credits collateral for assets that were never received, and reading for the input a function never checks is how that door is seen before someone walks through it with 80 million dollars.
- Recorded loss
- $80,000,000
What you will be able to answer
- →How was Qubit Finance drained (January 2022)?
- →What is a function doing when it acts on an unchecked input?
- →Where is the most dangerous line often found?
- →How to read a function's inputs
Orientation and Year One are open: anyone can read them without an account. From Year Two onward the lessons are for enrolled learners, because progress through the later years only means anything if it is tracked against a record.
It is free. We do not sell the list and there is nothing to buy at the end of it.
Sources and review
Confidence high·Volatility low·Reviewed 2026-09-17·Owner unassigned
Contested
The roughly 80 million dollar figure is the approximate value borrowed out against the phantom collateral; reports vary slightly. The lesson uses the unchecked-input mechanism, not a precise figure.
The exact code path is summarized here as a deposit that credited bridged collateral without verifying that real assets had arrived, involving an unvalidated input; the specific function and parameters are secondary to the reading skill of asking which inputs a function checks and which it trusts.
