Giter Site home page Giter Site logo

kadenzipfel / smart-contract-vulnerabilities Goto Github PK

View Code? Open in Web Editor NEW
1.5K 37.0 200.0 1.4 MB

A collection of smart contract vulnerabilities along with prevention methods

Home Page: https://kadenzipfel.github.io/smart-contract-vulnerabilities/

blockchain ethereum security solidity

smart-contract-vulnerabilities's Introduction

smart-contract-vulnerabilities's People

Contributors

agusvelez5 avatar hassty avatar kadenzipfel avatar mayowaolatunji avatar nirban256 avatar omahs avatar xplo8e avatar zeroknots 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  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  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  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

smart-contract-vulnerabilities's Issues

Generalize repo to smart contract security

Instead of just having attack vectors, lets put those in a folder and include other folders for security considerations.

Folders can include:

  • Known attacks
  • Best practices
  • Historical attacks

Faulty Contract Detection

Some contracts do not want other contracts to interact with them (very common in gambling contracts using sub-par RNG).

A common way to prevent this is to check whether the calling account has any code stored in it, however contract accounts initiating calls during their construction will not yet show that they store code.

An example of this is the FOMO3D bug.

[Suggestion] Section for off-chain attacks

Some non-Solidity attacks such as honeypots, short address attack, mis-characterizing code using ascii tricks, making failed transactions appear successful on explorers, injections, unsafe/unreliable oracle sources, etc. may deserve their own section.

[Attack] Contract Replication?

Not sure what to call this but just the general idea of using a contract to take advantage of variables that will be known by the time the transaction hits the chain (e.g. taking advantage of on-chain randomization).

how to start

please create a blog how to start smart contract bug bounty.

Unclogged Blockchain Reliance

Many contracts rely on calls happening within certain period of time, but Ethereum can be spammed with very high Gwei transactions for a decent amount of time relatively cheaply.

For example, FOMO3D (a countdown game where the last investor wins the jackpot, but each investment adds time to the countdown) was won by a user who completely clogged the blockchain for a small period of time, disallowing others from investing until the timer ran out and he won.

There are many "croupier" gambling contracts nowadays that rely on past blockhashes to provide RNG. This is not a terrible source of RNG for the most part, and they even account for the pruning of hashes that happens after 256 blocks, but at that point many of them simply null the bet. This would allow someone to make bets on many of these similarly-functioning contracts with a certain result as the winner for them all, check the croupier's submission while it's still pending, and, if it's unfavorable, simply clog the blockchain until pruning occurs and you can get your bets returned.

Unencrypted Secrets

Ethereum smart contract code can always be read. Treat it as such. Even if your code is not verified on Etherscan, attackers can still decompile or even just check transactions to and from it to analyze it.

One example of a problem here would be having a "guessing game" where the user has to guess a stored private variable to win the Ether in the contract. This is, of course, extremely trivial to exploit (to the point that you shouldn't try it because it's almost certainly a honeypot contract that's much trickier).

Another common problem here is using unencrypted off-chain secrets, such as API keys, with Oracle calls. If your API key can be determined, malicious actors can either simply use it for themselves, or take advantage of other vectors such as exhausting your allowed API calls and forcing the Oracle to return an error page which may or may not lead to problems depending on the structure of the contract.

Separate attacks and vectors

"Forcibly Sending Ether" and "Unexpected Ether Balance" are both in the same list but it's an example of a vulnerability and attack based on the same underlying functionality.

[Attack/Vulnerability] Dependence on Gas Calculations

Not sure exactly what to call this but some contracts may have functionality such as rewarding the caller for the amount of gas they spend. This would typically take the form of recording gasleft() at the beginning of the function and gasleft() at the end of the function, although if there are calls in-between where the attacker could call their own contract, they have the ability to spend a lot of gas on a fodder contract by deleting, have the full amount spent on deletes rewarded to them, but only end up paying a partial amount of gas.

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.