Giter Club home page Giter Club logo

hardhat-security-fcc's Introduction

Hardhat Security

This is a section of the Javascript Blockchain/Smart Contract FreeCodeCamp Course. This part of the course is to help users understand basic security and some fundamentals of auditing.

This repo has a few contracts with big flaws, see if you can see them, and see if the tools help you find them!

This repo has been updated for Goerli over Rinkeby.

โŒจ๏ธ (31:28:32) Lesson 18: Security & Auditing

Full Repo

This project is apart of the Hardhat FreeCodeCamp video.

What is an Audit?

An audit is a security focused code review for looking for issues with your code.

Help your auditors!

When writing good code, you 100% need to follow these before sending you code to an audit.

Tweet from legendary security expert Tincho

  • Add comments
    • This will help your auditors understand what you're doing.
  • Use natspec
    • Document your functions. DOCUMENT YOUR FUNCTIONS.
  • Test
    • If you don't have tests, and test coverage of all your functions and lines of code, you shouldn't go to audit. If your tests don't pass, don't go to audit.
  • Be ready to talk to your auditors
    • The more communication, the better.
  • Be prepared to give them plenty of time.
    • They literally pour themselves over your code.

"At this time, there are 0 good auditors that can get you an audit in under a week. If an auditor says they can do it in that time frame, they are either doing you a favor or they are shit. " - Patrick Collins, March 4th, 2022

Process

An auditors process looks like this:

  1. Run tests
  2. Read specs/docs
  3. Run fast tools (like slither, linters, static analysis, etc)
  4. Manual Analysis
  5. Run slow tools (like echidna, manticore, symbolic execution, MythX)
  6. Discuss (and repeat steps as needed)
  7. Write report (Example report)

Typically, you organize reports in a chart that looks like this:

impact image

Resources

These are some of the best places to learn even MORE about security:

PRs welcome to improve the list.

Tools

Games

Blogs

  • rekt
    • A blog that keeps up with all the "best" hacks in the industry.
  • Trail of bits blog
    • Learn from one of the best auditors in the space.
  • Openzeppelin Blog
    • Another blog of one of the best auditors in the space.

Audit Examples:

Articles

Getting Started

Requirements

  • Git
    • You'll know you did it right if you can run git --version and you see a response like git version x.x.x
  • Nodejs
    • You'll know you've installed nodejs right if you can run:
      • node --version and get an ouput like: vx.x.x
  • Yarn instead of npm
    • You'll know you've installed yarn right if you can run:
      • yarn --version and get an output like: x.x.x
      • You might need to install it with npm
  • Docker
    • You'll know you've installed docker right if you can run:
    • docker --version and get an ouput like Docker version xx.xx.xx, build xxxxx

Quickstart

git clone https://github.com/PatrickAlphaC/hardhat-security-fcc
cd hardhat-security-fcc
yarn

Then, go right into usage

No Typescript Support

Sorry! Feel free to make a PR if you'd like to see typescript here.

Optional Gitpod

If you can't or don't want to run and install locally, you can work with this repo in Gitpod. If you do this, you can skip the clone this repo part.

Open in Gitpod

Usage

Slither

Open the docker shell:

yarn toolbox

Then, run:

slither /src/contracts/ --solc-remaps @openzeppelin=/src/node_modules/@openzeppelin --exclude naming-convention,external-function,low-level-calls

To exit:

exit

Echidna

Open the docker shell:

yarn toolbox

Then, run this:

echidna-test /src/contracts/test/fuzzing/VaultFuzzTest.sol --contract VaultFuzzTest --config /src/contracts/test/fuzzing/config.yaml

To exit:

exit

Linting

To check linting / code formatting:

yarn lint

or, to fix:

yarn lint:fix

Formatting

yarn format

Thank you!

If you appreciated this, feel free to follow me or donate!

ETH/Polygon/Avalanche/etc Address: 0x9680201d9c93d65a3603d2088d125e955c73BD65

Patrick Collins Twitter Patrick Collins YouTube Patrick Collins Linkedin Patrick Collins Medium

hardhat-security-fcc's People

Contributors

patrickalphac avatar robocrypter avatar 0xalpharush avatar dounbug avatar rohitsingh107 avatar uday03meh avatar 0xjepsen avatar joonakauranen 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.