Turn a security video into a regression test
Use a repeatable worksheet to turn a Solidity security lesson into a testable claim, a negative control and a regression test you can explain.
TL;DR
- Pause before the explanation and write the property you think should hold.
- Separate a reachable failure from a test setup that merely permits one.
- Use a negative control to check that your test can distinguish safe behavior.
- Save the code version, command, expected result and limitation alongside the test.
Turn a security video into an investigation
A video can make a vulnerability look inevitable. You already know which function to inspect and the narrator explains the missing condition. The real skill is reconstructing that reasoning when the answer is hidden.
Use the same worksheet for a short Spot the Bug challenge, an episode in Public Audit Lab or a longer protocol lesson. The aim is a piece of evidence you can discuss, not another watched-video counter.
Start with a claim, not an exploit label
Instead of writing “access-control bug,” complete this sentence: “Actor A can perform action B in reachable state C, although the design requires condition D.” Name the exact function and the state variables that matter.
Here is a fictional teaching example. A vault tracks a balance for each account, but a withdrawal path checks only the vault's total token balance. A useful hypothesis is that one ordinary depositor can withdraw more than their own recorded claim. Whether that is possible still depends on the rest of the implementation.
Before running anything, write down the intended assertion in plain English: Alice's withdrawal must not reduce the assets backing Bob's remaining claim. Do not copy that assertion into a real protocol without checking how its shares, losses and fees are meant to work.
Keep setup, action and assertion separate
Use this small evidence worksheet:
| Field | What to record |
|---|---|
| Target | Repository, commit and function |
| Starting state | Actors, balances, roles and required prior actions |
| Expected property | What should remain true, with its assumptions |
| Action | The shortest sequence that tests the claim |
| Observation | Balance, state or permission change actually observed |
| Counterexample | A reachable case that should remain safe |
| Reproduction | Tool version, command and important configuration |
Setup deserves as much attention as the final assertion. A local test that gives an attacker an administrator role may show administrator power rather than a vulnerability. A mocked token may behave differently from the integration you are reviewing. State those choices explicitly.
If you want a weekly structure for this work, use the four-week audit practice plan.
Add a negative control
A negative control asks whether the test behaves differently when the suspected cause is absent. For the fictional vault, try a correctly enforced per-account withdrawal limit and keep the rest of the scenario constant. If your assertion still reports the same issue, inspect the assertion and accounting model.
Also test an ordinary permitted withdrawal. A fix that simply prevents every withdrawal can make an exploit test pass while breaking the product. A meaningful regression protects intended behavior as well as rejecting the unwanted path.
This is a teaching method, not proof that one extra test establishes complete security. Reentrancy, unusual token behavior, rounding, upgrades and multi-user sequences may need separate models and checks.
Use a quiz to choose the next experiment
Answer the relevant course checkpoint before reading the worked explanation. If you choose the right answer for the wrong reason, write down the mistaken assumption. Turn that assumption into another small test case.
For example, a question about balances might reveal that you treated “tokens held by the contract” as equivalent to “tokens owed to one user.” The next experiment should vary those two quantities independently. That is more useful than immediately repeating the quiz until the score improves.
The Fuzzing & Invariant Testing study guide connects properties and action sequences. The Uniswap V3 guide gives a different setting where principal, liquidity and fees must be kept distinct.
Write down what remains unproved
Finish your note with a limitation. You may have checked one function, one actor, one token model or one bounded sequence. A local reproduction is evidence about that scenario. It is not a statement that every attack is prevented or that a live deployment has the same configuration.
When asking the community for feedback, share the worksheet, the smallest relevant public snippet and the question you still need answered. Never post customer code, credentials, private reports or a live exploit against a system you are not authorized to test.
Related questions
Do I need an exploit to learn from a lesson? No. A well-explained counterexample or a test showing why a suspected path is unreachable is useful work.
Is passing a quiz evidence that my contract is secure? No. A quiz checks understanding of its questions. Contract security depends on the actual implementation, assumptions and scope of review.
Where do I open the free course? Choose a course from the catalogue, join Free Academy on Whop and open the course there. The website's study guides remain readable here; paid community areas are optional.
Sources and next reading
Ethereum's security documentation places testing alongside other review techniques. For a different developer risk, work through the recruitment repository checklist before running unfamiliar interview code.
Tagged