Skip to content

About

Open-source Solidity security examples, tests, and developer tools.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Motech Audit — Solidity Security Lab

Solidity Tests Slither Analysis

A practical, test-first lab for understanding common smart-contract security mistakes and checking how a mitigation changes the behavior. Examples are intentionally educational and paired with reproducible Foundry tests.

Useful to you? Give the repository a ⭐ Star so more Solidity builders can find it. Found a gap? Open an Issue. Want to help improve it? Beginner-friendly contributions are welcome.

Explore the lab

Topic What you can learn Code and tests
Reentrancy How calling external code before updating accounting can expose a withdrawal path, and how checks-effects-interactions changes it VulnerableVault.sol · FixedVault.sol · Reentrancy.t.sol
Access control Why privileged state changes must enforce authorization VulnerableFeeVault.sol · FixedFeeVault.sol · AccessControl.t.sol · Case notes
tx.origin authorization Why authorizing with the original transaction initiator can trust the wrong caller VulnerableTxOriginWallet.sol · FixedOwnerWallet.sol · TxOrigin.t.sol · Case notes
Failed ETH transfers How reverted transfers should preserve vault balances and accounting TransferFailure.t.sol
Vault accounting fuzzing How fuzz tests can probe deposits, withdrawals, and per-user accounting invariants VaultAccountingFuzz.t.sol
Empty withdrawal edge cases How reverts and per-user accounting protect other depositors' funds EmptyWithdrawal.t.sol

Run the tests

Install Foundry, then run from the repository root:

forge install foundry-rs/forge-std --no-git
forge test -vv

The dependency install is local; it does not need to be committed. GitHub Actions runs the suite on pushes and pull requests using forge test -vv --fuzz-runs 1000. This runs 1,000 fuzz cases for each Foundry fuzz test. The current suite contains 18 passing tests, including five fuzz tests.

Static analysis with Slither

A separate GitHub Actions workflow runs Slither on the compiled Solidity examples under src/. It excludes Foundry tests and scripts from the analysis build and exports a SARIF report as a downloadable workflow artifact.

The workflow is intentionally non-blocking on findings because this lab includes contracts that are vulnerable by design. A successful Slither run means compilation and analysis completed; it does not mean that no findings were detected or that the contracts are secure. Review findings in context and compare them with the paired Foundry tests and the documented mitigations.

See the Slither workflow and its reports.

Make your first contribution

You do not need to be a security expert to help. Choose a task that fits your experience:

Beginner-friendly

Intermediate

Have another idea?

Suggested path: open an issue → comment that you would like to work on it → make a focused change → run forge test -vv → open a pull request. You can also report a bug or suggest a test without submitting code.

Read the Community Guide to understand the participation process and how merged contributions are recognised. Substantive external contributions are recorded in CONTRIBUTORS.md.

Before contributing, read CONTRIBUTING.md. For community expectations, read our Code of Conduct. For security-sensitive reports, follow our Security Policy instead of posting exploit details publicly.

Please do not submit customer code, confidential audit reports, private findings, secrets, API keys, or credentials.

Scope and disclaimer

This is an educational repository, not a production-ready contract library and not a complete security audit. The examples are intentionally simplified. A passing test suite does not prove a contract is secure, and a mitigation shown here does not replace a context-specific review of external-call paths, access controls, accounting, dependencies, and business logic.

Do not deploy vulnerable examples or use these snippets to assess a production contract without an independent, context-specific review.

About Motech Audit

Motech Audit researches smart-contract security and develops tools and learning resources to help Web3 teams understand and mitigate risk.

About

Open-source Solidity security examples, tests, and developer tools.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages