GithubHelp home page GithubHelp logo

perseverancesuccess2021 / kyberswap-exploit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from one-hundred-proof/kyberswap-exploit

0.0 0.0 0.0 222 KB

PoC of KyberSwap double liquidity add exploit

Shell 0.09% Nix 0.02% Makefile 0.05% Solidity 99.84%

kyberswap-exploit's Introduction

A Proof of Concept demonstrating the ability to drain KyberSwap Elastic pools

Introduction

This repo contains the details of an exploit that drains 82.37% of the Elastic pool for wstETH-ETH on the Ethereum Mainnet at block height 17050000 (2023-Apr-15 04:13:47 AM +UTC). This root cause of this exploit has now been fixed and a new audit has been conducted.

The exploit is generalisable to any pool running on the old Elastic code in the ks-elastic-sc-legacy repo.

I submitted this Proof of Concept to Kyber Network on 17 April 2023. Kyber Network quickly disabled minting of new positions, and asked their LPs to withdraw their liquidity. After swiftly fixing the code and performing a fresh audit with Chain Security Kyber Network re-launched the Elastic pools on 24 April 2023.

You can read more about the exploit in my blog post Saving $100M at risk in KyberSwap Elastic.

Details

  1. The report for this exploit is in REPORT.md
  2. The test file that performs the exploit is in test/KyberswapLegacyTest.sol. The details are in function performFullHack at KyberswapLegacyTest.sol:133-236
  3. A PoC showing the that vulnerability is not present in the updated contracts is in KyberswapTest.sol.

Setup

Environment Variables

  1. Install Foundry

Follow the installation instructions

Set EVMNET_FORK_URL

e.g.

export EVMNET_FORK_URL="https://mainnet.infura.io/v3/deadbeefdeadbeefdeadbeefdeadbeef"

Or you can add an entry in a .env file e.g.

EVMNET_FORK_URL="https://mainnet.infura.io/v3/deadbeefdeadbeefdeadbeefdeadbeef"
$ npm install

Run PoC

$ ./run-forge

kyberswap-exploit's People

Contributors

one-hundred-proof avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.