mirror of
https://github.com/autistic-symposium/blockchains-security-toolkit.git
synced 2025-11-23 08:01:04 -05:00
| .. | ||
| hacking-address.md | ||
| README.md | ||
| research-papers.md | ||
☠️ Security
Basic security notes
tx.originis used: you want to replace it by “msg.sender” because otherwise any contract you call can act on your behalf.- Avoid potential reetrancy bugs:
msg.sender.transfer(amount);
balances[msg.sender] -= amount;
- Inline assembly should be used only in rare cases.
- Unclear semantics:
nowis alias forblock.timestampnot current time; use of low levelcall,callcode,delegatecallshould be avoided whenever possible; usetransferwhenever failure of ether transfer should rollnack the whole transaction. - Beware of caller contracts:
selfdestructcan block calling contracts unexpectedly. - Invocation of local functions via
this: never usethisto call functions in the same contract, it only consumes more gas than normal call. - Transferring Ether in a for/while/do-while loop should be avoid due to the block gas limit.
- ERC20
decimalsshould haveuint8as return type.
References
- Uniswap Oracle Attack Simulator by Euler
- "Given current concentrated liquidity profile of the ABC/WETH pool, what would it cost the attacker to move a N-minute TWAP of the ABC price to x?"
- Hacking the Blockchain by Immunifi
- Thinking About Smart Contract Security by Vitalik
- Spoof tokens on Ethereum