Git Product home page Git Product logo

awesome-mina-security's Introduction

awesome-mina-security

A curated list of Mina resources with a focus on security from Extropy.io .

Getting started

๐Ÿ‘‰๐Ÿป Mina and zkApp essentials
๐Ÿ‘‰๐Ÿป Basics of o1js
๐Ÿ‘‰๐Ÿป Deploy and interact with your first zkAPP under 10 minutes

Security aspects of zkApps

A list of security considerations to keep in mind when writing zkApps:

NOTE: links should open the related page of the docs at the correct point where the issue is being mentioned. However for unknown reason after a page is opened it quickly goes at the top. At the moment please search for the mentioned words in the page, we will try to find a solution asap to this problem

Generic issues:
๐Ÿ”’ Underconstrained Proofs: unproved logic can be manipulated by a malicious prover
๐Ÿ”’ Overriding init() is unnecessary if only super.init() is called inside without no other state initialization
๐Ÿ”’ Conversion between an o1js Bool and javascript boolean is always truthy
๐Ÿ”’ Using Provable.asProver() on inputs moves them out from the zk proof: anyone can remove the Provable block, execute the off-chain code and send a valid proof passing constraints
๐Ÿ”’ Writing custom low-level provable methods may add underconstrained logic
๐Ÿ”’ Never trust methods callers
๐Ÿ”’ Foreign Field Arithmetic should be used with caution
๐Ÿ”’ Usage of requireNothing() when retrieving On-chain Values may be dangerous
๐Ÿ”’ if condition is used instead of const x = Circuit.if(new Bool(foo), a, b);
๐Ÿ”’ Onchain merkle tree root not synced with offchain merkle root
๐Ÿ”’ Use on-chain values without checking them both at verification and proving time
๐Ÿ”’ Circumventing 01js security features should be avoided
๐Ÿ”’ Possible race conditions when many users read/write the state concurrently
๐Ÿ”’ The reduce() method breaks if more than the hard-coded number (default: 32) of actions are pending
๐Ÿ”’ Be careful when creating Account Updates from a reducer
๐Ÿ”’ Always extend the official TokenContract standard instead of building a custom token from scratch + mina-fungible-token repo (built on top of TokenContract)

Permissions related issues:
๐Ÿ”’ Explicitly setting Permissions to default is unnecessary if no other permissions are modified in the init() function
๐Ÿ”’ Permissions not locked down enough + advices for setting permissions
๐Ÿ”’ Calling external contracts with permissions not locked down enough
๐Ÿ”’ editState permission set to none
๐Ÿ”’ send permission set to none
๐Ÿ”’ if access and receive permissions are not set to none a deadlock may occur while doing concurrent state updates + safe way of doing an airdrop
๐Ÿ”’ smart contract interactions are limited to signature instead of proof
๐Ÿ”’ restrictive permissions can be circumvented if setPermissions is not set to impossible
๐Ÿ”’ lack of access controls
๐Ÿ”’ Minting unlimited tokens to himself is possile for an attacker if a custom token contract does not change access permission from none to at least proof

Development best practices

  • Do not assume that the fact that someone has to pay transaction fees doesn't have incentives to attack your zkApp
  • Work with the compiler, don't try to get round the way that 01js works
  • Be very aware of what is part of the proof and what is not
  • Make sure that your code is not under constrained - all the necessary checks are part of the proof.
  • Don't make assumptions about the caller
  • Be aware of pre conditions for the update
  • Restrict the permissions as much as you can.
  • Be careful when calling external contracts and accounts, you need to be sure your call will succeed.
  • Make sure the access control is accurate and enforced
  • Have a test suite, don't just test the 'happy path'
  • Put yourself in an adversarial mindset and try to break your code
  • Get your code audited
  • Have a plan to react to attacks
  • Keep up to date, we are at a very early stage.

Resources:

Documentation:

Tools & Frameworks:

News:

Projects on Mina:


Old Links

This section is a WIP

awesome-mina-security's People

Contributors

extropycoder avatar fontanellag avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

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