Giter Site home page Giter Site logo

secureum-medusa's Introduction

Secureum Medusa workshop

The goals of this workshop are to:

  • Learn about invariants development
  • Become familar with the medusa fuzzer

Medusa is a new experimental fuzzer. Do not hesitate to ask questions on secureum's discord, or create github issues if you encounter any issue.

Before starting

To install medusa, follow the installation instructions.

Solc

Solc 0.8.19 is used for this workshop. We recommend solc-select to easily switch between solc versions:

pip3 install solc-select
solc-select install 0.8.19
solc-select use 0.8.19

The contest

The goals of the contest is to write invariants for three targets (SignedWadMath, FixedPointMathLib, ERC20Burn). All the contracts are inspired from solmate.

Helper

  • helper comes from the properties repo, and contains helpers to ease the creation of invariants. In particular we recommend to use:
    • asssertX (Eq, Neq, Gte, Gt, Lte, Lt) to test assertion between values
    • clampX ( Between, Lt, Lte, Gt, Gte ) to restraint the inputs' values

SignedWadMath

  • SignedWadMath is a signed 18 decimal fixed point (wad) arithmetic library.
  • SignedWadMathTest is an example of test for SignedWadMath
    • testtoWadUnsafe is an example of invariant to help you

FixedPointMathLib

  • FixedPointMathLib is an arithmetic library with operations for fixed-point numbers.
  • FixedPointMathLibTest is an example of test for SignedWadMath
    • testmulDivDown is an example of invariant to help you

ERC20Burn

  • ERC20 is a standard ERC20 token.
  • ERC20Burn extends ERC20 with a burn function
  • ERC20Test is an example of test for ERC20Burn
    • fuzz_Supply is an example of invariant to help you
  • ERC20TestAdvanced is an example of an advanced test for ERC20Burn
    • ERC20TestAdvanced uses the external testing approach and uses a proxy contract to simulate a user. This approach is more complex to use, but allows to test for more complex scenario
    • testTransferFrom is an example of invariant to help you

ERC20Burn

How to start

A few pointers to start:

  • Read the documentation
  • Start small, and create simple invariants first
    • Start with SignedWadMath
  • Consider when operation should or it should not revert
  • Some properties could require to use certain tolerance
  • ERC20TestAdvanced is recommended only for users that have already explored the other contracts
  • Do not hesitate to introduce bugs in your code to verify that your invariants can catch them

To start a fuzzing campagn

medusa fuzz --target contracts/NAME.sol --deployment-order CONTRACT_NAME

Replace NAME.sol and CONTRACT_NAME.

Expected Results and Evaluation

User should be able to fully test the contracts. It is worth mentioning that the code is unmodified and there are no known issues. If you find some security or correctness issue in the code do NOT post it in this repository nor upstream, since these are public messages. Instead, contact us to confirm the issue and discuss how to proceed.

For Secureum, the resulting properties will be evaluated introducing an artificial bug in the code and running a short fuzzing campaign.

We encourage you to try different approaches and invariants. Invariants based development is a powerful tool for developer and auditors that require practices and experience to master it.

Configuration

medusa.json was generated with medusa init. The following changes were applied:

  • testAllContracts was set to true
  • corpusDirectory was set to "corpus"
  • assertionTesting/enabled was set to true

Documentation

Self-Evaluation

See Evaluation

secureum-medusa's People

Contributors

anishnaik avatar montyly 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.