EthSecurity
5.22K subscribers
112 photos
20 files
760 links
Download Telegram
Always handle return value from functions enterMarket() and exitMarket() of Compound V2.
if market is not listed it will return MARKET_NOT_LISTED error. Every external call to other protocol should be reviewed and handled.@EthSecurity1
2
The "1 Wei Attack" is an exploitation of some DeFi platforms' vaults or liquidity pools, specifically those employing AMMs.

This attack takes advantage of the lack of slippage protection which leads to asset dilution and potential loss of funds for unsuspecting users. Suppose the following occurred:

1. The vault is empty
2. Alice deposits 1 token (1e18 units) into vault
3. Bob front-runs it, depositing 1 unit
4. Bob donates 1 token (1e18 units) into the vault using ERC20 transfer
5. Alice's deposit is executed

What happens?With an empty vault, the shares are being minted at a 1:1 rate with the amount. After Bob deposits 1 unit, the rate is 1:1 unit:shares.

Then, Bob donates another 1e18 units. This will make totalAssets = 1e18 + 1.Finally, Alice's transaction is completed and she gets:

(1e18*1) / (1e18 + 1) = 0.99999.. shares

In solidity, the decimals are truncated, and she gets 0 shares! 😲
@EthSecurity1
👍3🔥1🤯1
Find the bug #simple
I will post answer @EthSecurity1
🔥2
Watch out for arbitrary NFT approvals inside of loops! 👇

If you attempt to call the "setApprovalForAll" function on an AxieInfinity NFT for an address that already has approval, it will revert.
@EthSecurity1
The CoreCollection.withdraw function uses payableToken.transferFrom(address(this), msg.sender, amount) to transfer tokens from the CoreCollection contract to the msg.sender ( who is the owner of the contract). The usage of transferFrom can result in serious issues. In fact, many ERC20 always require that in transferFrom allowance[from][msg.sender] >= amount, so in this case the call to the withdraw function will revert as the allowance[CoreCollection][CoreCollection] == 0 and therefore the funds cannot ben withdrawn and will be locked forever in the contract.

Recommendation : replace transferFrom with transfer @EthSecurity1
4
tldr of tornado governance hack
1. hacker makes a proposal that executes code from a contract
2. users vote for the proposal since contract code looks good, proposal passes
3. hacker self-destructs contract and deploys malicious one in same address
4. 2nd contract is executed

so hacker got voters to vote a proposal, and, after the proposal passed, they changed the code for it and executed their malicious proposal, giving themselves full control of the DAO and draining the tokens held there.

another resource:

https://twitter.com/samczsun/status/1660012956632104960?s=21

@EthSecurity1
😁1
Storage collision because of lack of EIP1967 could cause conflicts and override sensible variables
Proof of Concept

contract CoreProxy is Ownable {
address private immutable _implement;

When you implement proxies, logic and implementation share the same storage layout. In order to avoid storage conflicts EIP1967 was proposed.(https://eips.ethereum.org/EIPS/eip-1967) The idea is to set proxy variables at fixed positions (like impl and admin ).

For example, according to the standard, the slot for for logic address should be

0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc (obtained as bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) ).

In this case, for example, as you inherits from Ownable the variable _owner is at the first slot and can be overwritten in the implementation. There is a table at OZ site:https://docs.openzeppelin.com/upgrades-plugins/1.x/proxies @EthSecurity1
🔥1
Anyone holding funds in Tornado Cash Nova must withdraw the funds ! The attacker can simply upgrade the contract (takes 7 days tho to execute) on Gnosis Chain (is managed by governance) and drain the ETH funds. For how to do it, see here

https://t.co/LXoG9cEMpn
@EthSecurity1
👍1