GithubHelp home page GithubHelp logo

juanxavier / defi-security-summit-stanford Goto Github PK

View Code? Open in Web Editor NEW

This project forked from secureum/defi-security-summit-stanford

0.0 1.0 0.0 659 KB

DEFI Focus Smart Contract Security Capture the Flag

Home Page: https://ctf-maker-monorepo.vercel.app/

Solidity 100.00%

defi-security-summit-stanford's Introduction

Secureum A-MAZE-X Stanford

A Smart Contract Security Capture the Flag Workshop

A-MAZE-X-Stanford-LOGO hosted by the Stanford University as part of Defi Security 101
built by eugenioclrc and luksgrin
special thanks to patrickd, StErMi, tinchoabbate and Rajeev for reviewing, commenting and helping during the elaboration and design of this CTF Workshop


Instructions ๐Ÿ•น๏ธ

This Workshop consists in a series of challenges, of increasing difficulty, targetting different concepts and common vulnerabilities found in DeFi. The CTF is designed in different flavors for all kinds of users.


How to play

This workshop provides different flavors. Feel free to use the one you feel more comfortable with:


Important note

This set of challenges aren't set for competitive purposes. Their main objective is to showcase scenarios involving DeFi, Solidity concepts and common vulnerabilities.

Focus on learning and having fun! ๐Ÿ˜Š


Challenges ๐ŸŽฎ

Challenge 0: VitaToken seems safe, right?

Let's begin with a simple warm up. Our beloved Vitalik is the proud owner of 100 $VTLK, which is a token that follows the ERC20 token standard. Or at least that is what it seems... ๐Ÿ˜‰๐Ÿ˜‰๐Ÿ˜‰

๐Ÿ“Œ Upon deployment, the VToken contract mints 100 $VTLK to Vitalik's address.

Is there a way for you to steal those tokens from him? ๐Ÿ˜ˆ๐Ÿ˜ˆ๐Ÿ˜ˆ

๐Ÿ—’๏ธ Concepts you should be familiar with (spoilers!)

The contracts that you will hack are:


Challenge 1: What a nice Lender Pool!

Secureum has raised a lot of Ether and decided to buy a bunch of InSecureumTokens ($ISEC) in order to make them available to the community via flash loans. This is made possible by means of the InSecureumLenderPool contract.

๐Ÿ“Œ Upon deployment, the InSecureumToken contract mints an initial supply of 10 $ISEC to the contract deployer.

๐Ÿ“Œ The InSecureumLenderPool contract operates with $ISEC.

๐Ÿ“Œ The contract deployer transfers all of their $ISEC to the InSecureumLenderPool contract.

๐Ÿ“Œ The idea is that anyone can deposit $ISECs to enlarge the pool's resources.

Will you be able to steal the $ISECs from the InSecureumLenderPool? ๐Ÿ˜ˆ๐Ÿ˜ˆ๐Ÿ˜ˆ

๐Ÿ—’๏ธ Concepts you should be familiar with (spoilers!)
  • The concept of flashloans. Focus on the definition, how they work and what's their original purpose.
  • Solidity's delegatecall.

The contracts that you will hack are:

Which have interactions with the following contracts:


Challenge 2: it's always sunny in decentralized exchanges

I bet you are familiar with decentralized exchanges: a magical place where one can exchange different tokens.
InsecureDexLP is exactly that: a very insecure Uniswap-kind-of decentralized exchange.
Recently, the $ISEC token got listed in this dex and can be traded against a not-so-popular token called $SET.

๐Ÿ“Œ Upon deployment, the InSecureumToken and SimpleERC223Token contracts mint an initial supply of tokens 10 $ISEC and 10 $SET to the contract deployer.

๐Ÿ“Œ The InsecureDexLP operates with $ISEC and $SET.

๐Ÿ“Œ The dex has an initial liquidity of 9 $ISEC and 9 $SET, provided by the contract deployer. This quantity can be increased by anyone through token deposits.

๐Ÿ“Œ Adding liquidity to the dex rewards liquidity pool tokens (LP tokens), which can be redeemed in any moment for the original funds.

๐Ÿ“Œ In the foundry implementation, the deployer graciously airdrops the challenger (you!) 1 $ISEC and 1 $SET. In the TenderlySandbox implementation, the challenger must call the exclusive claimAirdrop() functions of each of the token contracts, obtaining this way 1 $ISEC and 1 $SET.

Will you be able to drain most of InsecureDexLP's $ISEC/$SET liquidity? ๐Ÿ˜ˆ๐Ÿ˜ˆ๐Ÿ˜ˆ

๐Ÿ—’๏ธ Concepts you should be familiar with (spoilers!)

The contracts that you will hack are:

Which have interactions with the following contracts:


Challenge 3: borrow, hide and seek

Finally, as a conclusion to this not-so-secure ecosystem, the Secureum team built the BorrowSystemInsecureOracle lending platform where one can borrow and loan $ISEC and BoringToken ($BOR). Both tokens can be borrowed by either providing themselves or the other token as collateral.

๐Ÿ“Œ Upon deployment, the InSecureumToken and BoringToken contracts mint an initial supply of 30000 $ISEC and 20000 $BOR to the contract deployer.

๐Ÿ“Œ BorrowSystemInsecureOracle uses the InsecureDexLP to compute the $ISEC/$BOR price.

๐Ÿ“Œ The deployer adds an initial liquidity of 100 $ISEC and 100 $BOR to the InsecureDexLP.

๐Ÿ“Œ Similarly, InSecureumLenderPool contract is funded with 10000 $ISEC by the deployer.

๐Ÿ“Œ The BorrowSystemInsecureOracle contract has an initial amount of 10000 $ISEC and 10000 $BOR provided by the deployer.

๐Ÿ“Œ Users can add collateral and take loans from BorrowSystemInsecureOracle.

๐Ÿ“Œ Users may also get liquidated.

Will you be able to drain all the $ISEC from BorrowSystemInsecureOracle? ๐Ÿ˜ˆ๐Ÿ˜ˆ๐Ÿ˜ˆ

๐Ÿ—’๏ธ Concepts you should be familiar with (spoilers!)

The contracts that you will hack are:

Which have interactions with the following contracts:


CTF Writeup ๐Ÿ—’๏ธ๐Ÿ—’๏ธ๐Ÿ—’๏ธ

Follow this link to access this CTF's writeup by patrickd.


defi-security-summit-stanford's People

Contributors

luksgrin avatar

Watchers

 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.