Skip to content

Vault shares can be inflated by donating ERC20 token to the vault.

Notifications You must be signed in to change notification settings

Maheswaranx15/Vault_Inflation_attack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vulnerability

Vault shares can be inflated by donating ERC20 token to the vault.

Attacker can exploit this behavior to steal other user's deposits.

results

result!

Source_link

source!

Example Scenario

  • User 0 front runs user 1's deposit.

  • User 0 deposits 1.

  • User 0 donates 100 * 1e18. This inflates the value of each share.

  • User 1 deposits 100 * 1e18. This mints 0 shares to user 1.

  • User 0 withdraws all 200 * 1e18 + 1.


Protections

  • Min shares -> protects from front running
  • Internal balance -> protects from donation
  • Dead shares -> contract is first depositor
  • Decimal offset (OpenZeppelin ERC4626)

Foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.

Foundry consists of:

  • Forge: Ethereum testing framework (like Truffle, Hardhat and DappTools).
  • Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
  • Anvil: Local Ethereum node, akin to Ganache, Hardhat Network.
  • Chisel: Fast, utilitarian, and verbose solidity REPL.

Documentation

https://book.getfoundry.sh/

Usage

Build

$ forge build

Test

$ forge test

Format

$ forge fmt

Gas Snapshots

$ forge snapshot

Anvil

$ anvil

Deploy

$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>

Cast

$ cast <subcommand>

Help

$ forge --help
$ anvil --help
$ cast --help

About

Vault shares can be inflated by donating ERC20 token to the vault.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published