Coder Social home page Coder Social logo

coinfabrik / scout Goto Github PK

View Code? Open in Web Editor NEW
48.0 3.0 6.0 5.25 MB

Scout is an extensible open-source tool intended to assist ink! smart contract developers and auditors detect common security issues and deviations from best practices.

Home Page: https://coinfabrik.github.io/scout/

License: MIT License

Makefile 0.10% Rust 96.91% JavaScript 0.08% TypeScript 0.39% Shell 1.64% Python 0.88%
audit ink rust smart-contracts tool

scout's People

Contributors

aon avatar arlosiggio avatar arturobeccar avatar faculerena avatar jgcrosta avatar pinola007 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

scout's Issues

Improve CI formatting and linting to include missing dirs

Description

test-cases directory is not being included for linting and formatting. It should be included in order to detect lint or formatting errors.

Acceptance Criteria

  • Add to Makefile the missing formatting and linting of the test-cases directory
  • Add necessary scripts to list cargo directories recursively

Add test-case for `unsafe-unwrap`

Description

A test-case for unsafe-unwrap. This vulnerability is done when calling any sort of unwrap() operation on a Result or Option or any other. The correct way would be to define a custom Error type.

Acceptance Criteria

  • A test-case for unsafe-unwrap should be created

Estimate

3

Sprint number

1

Add detector for `unsafe-unwrap`

Description

A detector for unsafe-unwrap. This vulnerability is done when calling any sort of unwrap() operation on a Result or Option or any other. The correct way would be to define a custom Error type.

Acceptance Criteria

  • A detector for unsafe-unwrap should be created

Estimate

3

Sprint number

1

Add detector for `check-zero-or-test-address`

Description

User provided addresses should not be the zero address or any of the default test accounts (e.g. Bob, Alice).

Acceptance Criteria

  • Add a detector for the vulnerability
  • Add to integration tests

Add Getting Started section to docs

Description

Complete doc for Getting Started section.

Acceptance Criteria

Include these subsections

  • About Scout
  • Features
  • What you'll need
  • CLI
    • Installation
    • Usage
  • VSCode Extension
    • Installation
    • Usage

Estimate

2

Sprint number

1

Add --manifest-path to CLI

Description

Allows user to set path where to run the tool

Acceptance Criteria

Implements the following command:
cargo scout –manifest-path <PATH_TO_CARGO_TOML>

Estimate

1

Sprint number

1

Add filtering, exclusion and listing for detectors in `cargo-scout`

Description

Add options to allow:

  • filtering by detector
  • exclusion by detector
  • listing existing detectors

Acceptance Criteria

Implements the following commands:

  • cargo scout -–filter-by-detectors <DETECTOR_LIST_SEPARATED_BY_COMAS>
  • cargo scout –-exclude-detectors <DETECTOR_LIST_SEPARATED_BY_COMAS>
  • cargo scout –-list-detectors

Estimate

5

Sprint number

1

Add --help, -h, --version to CLI

Description

Display help message and version message.

Acceptance Criteria

Implements the following commands:
cargo scout --help
cargo scout -h
cargo scout --version

Estimate

1

Sprint number

1

Cargo-scout detectors build repository

Description

Detectors are being downloaded from the old web3-grant repository, causing the tests of new detectors to fail.

Acceptance Criteria

  • Come up with a solution to run those tests successfully
  • Build cargo-scout with the new detectors

Try scout on Windows

Description

Install and try scout on Windows 10.

Acceptance Criteria

Command cargo scout runs successfully without errors on sample repo.

Estimate

1

Sprint number

1

Add `cargo-scout` prototype

Description

We need to have a basic working CLI, and then start adding features to it.

Acceptance Criteria

  • The prototype should work with known vulnerabilities
  • It should download and compile the linter libraries
  • It should call dylint to run the linters against the given smart contract
  • It should detect if the tool is being run in a cargo project

Estimate

8 days

Sprint number

1

Add test-case for `unsafe-unwrap`

Description

Usage of unwrap() is frowned upon in production code, which can cause the contract execution to revert with panic without providing a reason or a proper error control. This is similar to the panic-error vulnerability.

Acceptance Criteria

  • Add a test-case for the vulnerability

Add `delegate-call` detector

Description

In the same way as slither detects delegate-calls, we should have a detector for it. This is an exploratory issue for learning the usage of MIR and testing in a low-hanging fruit example such as delegatecall.

Acceptance Criteria

  • Create detector using MIR

Estimate

5

Sprint number

1

Add Detectors section to docs

Description

Complete documentation on detectors.

Acceptance Criteria

Add intro to detectors.
Add references to types of detectors and detection techniques
Add a separate page for each detector.

Estimate

5

Sprint number

1

Add test-case for `unsafe-expect`

Description

A detector and test-case for unsafe-expect. This vulnerability is done when calling any sort of expect() operation on a Result or Option or any other. The correct way would be to define a custom Error type.

Acceptance Criteria

  • A test-case for unsafe-expect should be created

Check `integer-overflow-underflow` for all arithmetic operations

Description

A verification should be done in order to verify the detector for integer-overflow-underflow is complete for all arithmetic operations that could produce an overflow/underflow.

Acceptance Criteria

  • Validate for all other arithmetic operations
  • Add test-cases for other arithmetic operations
  • Add new test-cases to integration tests

Sprint number

1

Add `delegate-call` test-case and detector

Description

In the same way as slither detects delegate-calls, we should have a detector for it. This is an exploratory issue for learning the usage of MIR and testing in a low-hanging fruit example such as delegatecall.

Acceptance Criteria

  • Create test-case

Estimate

5

Sprint number

1

Add Tests section in README

Description

Add minimum test section (just a paragraph) explaining:

  • How to run the integration tests for cargo-scout
  • How to run the tests for each test-case

Add detector for `divide-before-multiply`

Description

Due to the impossibility to represent floating point numbers in Ink, order of multiplications and divisions are important to ensure numerical precision.

Take for example the following function. It is intended to return the percentage of a total profit:

#[ink::message]
pub fn split_profit(uint64 percentage, uint64 total_profit) -> uint64 {
    (percentage / 100) * total_profit
}

The result however, will always be zero, given the integer division percentage / 100 yields zero.

Reordering operations to perform multiplications before divisions is a good way to avoid loss of precision:

#[ink::message]
pub fn split_profit(uint64 percentage, uint64 total_profit) -> uint64 {
    (percentage * total_profit) / 100
}

Acceptance Criteria

  • Add a detector for this vulnerability
  • Add to integration tests

Improve CI times

Description

CI github workflow takes now around 40 minutes. This is too long and we will run out of our monthly free quota in no time.

Acceptance Criteria

  • Improve cache usage so as to reduce build times.

Try scout on Mac

Description

Install and try scout on Mac.

Acceptance Criteria

Command cargo scout runs successfully without errors on sample repo.

Estimate

1

Sprint number

1

Add Vulnerabilities section to docs

Description

Complete Vulnerability documentation to docs.

Acceptance Criteria

Add an intro to vulnerabilities.
Add references for further reading.
Add separate pages for each class of vulnerability

Estimate

3

Sprint number

1

Add sections and scout image to README.md

Description

Add main sections and image to README.md

Acceptance Criteria

Add scout image within assets folder. Link the image to the README.md
Add license and license badge.
Add the following sections:

  • (Introduction)
  • Getting Started
  • Documentation
  • Detectors
  • About CoinFabrik
  • License

Estimate

1

Sprint number

1

Add front-page images and icons

Description

For each icon, image or logo in this drive create an equivalent image for scout, maintaining file format an size.
Please take a look at the subfolder Image Ideas for an idea on how each image should look like.
Leave all the new image files in the folder Scout Icons.
Follow the image names specified in the Acceptance Criteria below.

Acceptance Criteria

The following files in bold must be saved in the Scout Icons folder.

  • docusaurus-social-card.jpg -> scout-social-card.png. The phrase in this image is the one in this file.
  • docusaurus.png -> scout.png. Use as inspiration this image.
  • favicon.ico (keep file name and change its image for scout).
  • logo.svg (keep file name and change its image for scout).
  • undraw_docusaurus_mountain.svg -> scout_tool.svg (see Image Ideas).
  • undraw_docusaurus_tree.svg -> scout_security.svg (see Image Ideas).
  • undraw_docusaurus_react.svg -> scout_research.svg (see Image Ideas).

Estimate

To be confirmed

Sprint number

1

Add detector and test-cases for `insufficiently-random-values`

Description

Using block.number or block.timestamp together with a hash function to produce random numbers is insecure, since these attributes can be manipulated by miners for the current block or read by anyone else if using attributes of a previous block.

Acceptance Criteria

  • Add test-case demonstrating this vulnerability
  • Add a detector for this vulnerability
  • Add to integration tests

Add detector for `unsafe-expect`

Description

A detector and test-case for unsafe-expect. This vulnerability is done when calling any sort of expect() operation on a Result or Option or any other. The correct way would be to define a custom Error type.

Acceptance Criteria

  • A detector for unsafe-expect should be created

Add --output-file to CLI

Description

Add an option to allow output to be exported to a file (e.g: json file).

Acceptance Criteria

Specifies the output file type.
Implements the following command:
cargo scout –output-file <OUTPUT_FILE_NAME>

Estimate

To be discussed

Sprint number

1

Test-cases directory structure

Description

The goal of this task is to enhance the repository by adding a vulnerabilities folder and/or tests folder. The folder should contain examples of vulnerabilities, both before and after remediation, as specified in the Proof of Concept (PoC) milestone.

Acceptance Criteria

Estimate

1

Sprint number

1

Add integration tests

Description

Add integrations tests to ensure that detectors mantain their expected behaviour as we modify scout and add new detectors. Proposal: create a vulnerabilities folder with the vulnerability examples and a tests folder with the necessary scripts to automate scout's run on these vulnerabilities.

Acceptance Criteria

  • Adds required scripts to run scout on all involved files.
  • Adds a script that compares the result against the output file generated in the last run.

Estimate

To be defined.

Sprint number

1

Add filtering, excluding and listing for detector categories in `cargo-scout`

Description

Add options to allow:

  • filtering by detector categories
  • exclusion by detector categories
  • listing existing detector categories

Acceptance Criteria

Implements the following commands:

  • cargo scout –-filter-by-categories <CATEGORY_LIST_SEPARATED_BY_COMAS>
  • cargo scout –-exclude-categories <CATEGORY_LIST_SEPARATED_BY_COMAS>
  • cargo scout -–list-categories

Estimate

3

Sprint number

1

Add test-case for `check-zero-or-test-address`

Description

User provided addresses should not be the zero address or any of the default test accounts (e.g. Bob, Alice).

Acceptance Criteria

  • Add a test-case that breaks a contract for passing a zero address or a default test account

Add Ink! detection to vscode extension

Description

In the current iteration of the vscode extension, whenever a Rust project is detected, doesn't matter if it's a smart contract or not, the extension is activated. This is not the correct behaviour as the linter is only suitable for Ink! smart contracts.

As a suggestion, the detection could be done verifying if the Cargo.toml has the dependencies needed to create a smart contract.

Acceptance Criteria

  • Enable the extension only if we're running in an Ink! project

Subtasks

  • Detect if we're in an Ink! project
  • Enable the extension depending on the detection of the Ink! project

Estimate

2

Sprint number

1

Deploy docs

Description

Deploy documentation in Github Pages.

Add test-case for `floating-point-and-numerical-precision`

Description

Due to the impossibility to represent floating point numbers in Ink, order of multiplications and divisions are important to ensure numerical precision.

Take for example the following function. It is intended to return the percentage of a total profit:

#[ink::message]
pub fn split_profit(uint64 percentage, uint64 total_profit) -> uint64 {
    (percentage / 100) * total_profit
}

The result however, will always be zero, given the integer division percentage / 100 yields zero.

Reordering operations to perform multiplications before divisions is a good way to avoid loss of precision:

#[ink::message]
pub fn split_profit(uint64 percentage, uint64 total_profit) -> uint64 {
    (percentage * total_profit) / 100
}

Acceptance Criteria

  • Add a test-case that shows the vulnerability of floating-point-and-numerical-precision

Validate tool against deployed projects

Description

Tool should be ran against deployed projects in order to verify false positives and general usage.

Acceptance Criteria

  • Run tool against a set of deployed projects (e.g. Paraswap)
  • Create document that summarize findings

Add detector for `unsafe-unwrap`

Description

Usage of unwrap() is frowned upon in production code, which can cause the contract execution to revert with panic without providing a reason or a proper error control. This is similar to the panic-error vulnerability.

Acceptance Criteria

  • Add detector for the vulnerability
  • Add to integration tests

Try scout on Linux

Description

Install and try scout on Linux

Acceptance Criteria

Command cargo scout runs successfully without errors on sample repo.

Estimate

1

Sprint number

1

Add key features to front page

Description

Add sections and links associated to the key features of our project to the front page.

Acceptance Criteria

  • The file docs/docusaurus.config.js should be updated with the project's relevant data.
  • The file docs/src/components/HomepageFeatures/index.txt should be updated with the project's relevant data.
  • The file docs/src/pages/index.txt should be modified to link to doc's intro page.

Estimate

2

Sprint number

1

Evaluate `scout` vscode extension

Description

This is an exploratory issue about creating a vscode extension for scout.

Acceptance Criteria

  • Evaluate the difficulty of building a vscode extension instead of using rust-analyzer
  • Create follow-up issues

Estimate

3

Sprint number

1

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.