Understanding Overflow and Underflow Attacks on Smart Contracts

One of the best outcomes of blockchain is smart contracts, a computer protocol that facilitates, verifies, and sometimes implements a contract or negotiation. Smart contracts’ exciting uses are record keeping in healthcare, real estate, property ownership, insurance, and voting systems

Despite the preference for smart contracts, one cannot claim that it is a fully secure system. Any unexpected and unwanted elements in a smart contract can have enormous consequences. For example, a bug in a smart contract may trigger it to perform unintended tasks. This may lead to huge losses for the parties under the agreement and unwanted penalties. 

Some of the most discussed attacks on smart contracts are the Parity Wallet and DAO attacks. This article explains how overflows and underflows occur and how smart contracts are vulnerable to them.

Objects of a Smart Contract

  • Signatories 

These are the two or more parties using the smart contract. They use digital signatures to either agree or disagree with the terms of the agreement. 

  • The subject of the contract 

This refers to the object that the negotiating parties are agreeing upon. These terms could be, for instance, a house, digital assets, cryptocurrency, and so on. 

  • Terms of the contract 

These are the requirements and terms expected from each party. Additionally, this segment outlines the rules of conduct, rewards, and penalties for any misconduct while executing the agreement. 

Smart contracts are majorly associated with cryptocurrencies such as Bitcoin and Ethereum. Banks and major financial organizations have been slow and cautious to accept the use of blockchain. With inventions like Quorum – from the Ethereum blockchain – which uses smart contracts while providing privacy, they are slowly becoming prominent. 

When a smart contract is set in the blockchain and deployed, it cannot be altered or updated with security patches. As a result, developers are encouraged to ensure that the contract has robust security strategies before deployment. This, in turn, prevents any potential exploitation of vulnerabilities at a later time. 

Overflow and Underflow Attacks

Overflow and underflow attacks are often classified as integer overflows. Simply put, these are errors that allow a program to revert to the start or recalibrate. 

For instance, when we turned over the new millennium, a lot of programs experienced recalibration. They were set to represent years with the prefix of 19-, such as 1994 was represented as 94. When it turned to 2000, many of these programs reverted to 1900 rather than go up to 2000. 

Underflow attacks are more likely to occur as opposed to overflow. This is because underflow attacks are simpler to carry out, and achieving the tokens required for an overflow is too difficult. 

Overflow Error Attacks

An overflow error attack on a smart contract occurs when more value is provided than the maximum value. When this happens, it circles back to zero, and this feature can be exploited by repeatedly invoking the feature that increases the value. 

Underflow Error Attacks

This error attack operates in the exact opposite of the overflow error. Instead of exceeding the maximum value, an underflow error occurs when you go below the minimum amount. This triggers the system to bring you right back up to maximum value instead of reverting to zero. 

Impact of Overflow and Underflow Attacks

Underflow errors are more likely to occur as opposed to overflows, and the outcome can be disastrous. If a program lacks the feature that checks for underflow and overflow, an attacker can get more tokens than they own. They can also get a maxed-out balance, which is essentially stealing. 

These error attacks can cause the whole system to break because the amount of tokens being maxed out is not the same as the tokens in the system. 

An excellent example of underflow attacks is the Proof of Weak Hands Coin, a Ponzi scheme that grew into over a million dollars. The developers failed to secure the system with defenses against overflow and underflow attacks. This then allowed a hacker to access 2000 Ether, which was valued at 2.3 million dollars. 

Mitigation of Overflow and Underflow Attacks

The most recommended method of mitigating overflow and underflow attacks is the use of Open Zeppelin SafeMath Library. This checks for overflow and underflow and throws an error if any such activity is spotted on a contract. 


Bitcoin live price
price change

Smart contract technology has been beneficial for parties forming agreements without the need for a middleman. It has been used in business, finance, gaming, insurance, among other sectors. Since these sectors involve money and currency flows, technology has also attracted hackers to exploit their weaknesses. Analysts predict that smart contracts will revolutionize what we consider normal, like banking. They even have the potential to make voting fair and secure, but the security issue cannot be ignored. Underflows and overflows constitute a significant threat to smart contracts, and their mitigation will help build trust in the use of smart contracts.

Stay up to date with our latest articles

More posts

What Is CBDC In Crypto?

The cryptocurrency trading revolution exploded more than ten years ago and led to an almost unprecedented economic and financial earthquake. As a result, people are learning to change their approach to payment and investment systems, pushing up the price of many cryptocurrencies. Such a rapid change has not gone unnoticed on the boards of the world's major central banks. In fact, in an increasing number of countries, central banks are working on launching centralized digital currencies, known as CBDC. This…

How Social Leaders on Shrimpy help Investors Maximize Profits from Crypto Trading

The emerging trend of social trading allows millions of investors to interact with their peers and learn from accomplished traders in the crypto market. Every market participant wants to become a profitable crypto trader and maximize earnings from the ongoing crypto boom. Unfortunately, navigating the highly volatile space while grasping the complex learning curve that involves fundamental/technical analysis can be rather daunting. Becoming successful in the crypto market requires time to develop a working strategy that empowers investors to execute…

Decentralized Exchanges 2022: Which is the Best Crypto DEX to Trade on?

Market experts believe that the survival and growth of crypto largely depend on decentralization. The good news is that decentralized exchanges or DEXs have become highly popular, and the crypto market sees this as an opportunity to save the essence of traditional blockchain. Each decentralized exchange platform has the potential to revive and thrive crypto market. Moreover, each new DEX platform comes with its own set of features. There are several methods to use DEXs and make money.  Decentralized exchange…

Top Crypto Exchanges for Beginners in 2022

Investing in crypto is not as complex as most people think. So if you’re curious and optimistic about the rise of crypto, there is no reason to hold back and dive into it. Remember, it is normal for beginner investors to get caught in the cobweb of endless crypto exchanges. As a beginner investor, your objective should focus on the best crypto exchanges to make the right investment decisions. Whether it’s Bitcoin or Ethereum, cryptocurrencies continue to be at the…

Top 10 Cryptocurrencies in January 2022

Cryptocurrencies had a great year in 2021. In this period, we have seen the market go from being classified as a billion-dollar economy into a trillion-dollar economy. Aside from that, cryptocurrencies are gaining visibility in the mainstream world with, for example, El Salvador's adoption of Bitcoin as the official digital currency. As a result, investors are looking for the "new Bitcoin" on the market, hoping to find a great alternative in so-called altcoins. Unfortunately, many traders value an altcoin exclusively…

The Story Of Bitcoin And Ethereum’s Reversed Blockchains

Decentralization is the primary selling point of the three worlds of Bitcoin, crypto, and the web. There are several reasons for this. Some are related to the increased transactional efficiency that decentralization can provide. Others are related to creating permissionless, censorship-resistant digital networks. The most important is that decentralization weakens any single-point-of-failure, hence bolstering network security. This not only keeps a network as close to unbiased and ‘neutral’ as possible but almost guarantees its immutability. Yet the crypto world hasn’t…

What Are the Best Crypto Prediction Sites?

There are now several websites that provide, besides crypto live prices, some forecasts on the future of the leading cryptocurrencies. However, considering the market’s high volatility and the few analysis tools available to the public for formulating these forecasts, it must monitor these portals carefully. This article will report some of the primary sources of price forecasts in the crypto industry. However, we remind you that the information contained in the text does not constitute financial advice, and we invite…

Why Do the Cryptocurrency Prices Go Down on the Weekends?

If you have been in the crypto world for a while, you will probably have noticed a typical behaviour of the market during weekends. With some exceptions, we are used to seeing the price of significant cryptocurrencies drop over the weekend. The phenomenon is known to those who operate in this market, but understanding precisely the causes seems to be rather complex. Therefore, this article will discuss a definitive answer by analyzing the various main factors involved in this market…

How to Track and Stay Updated with Cryptocurrency News

Cryptocurrency is a young market and, as such, very fast-moving. If we exclude the phenomenon of stablecoins, the prices of cryptocurrencies change continuously, with sometimes very high volatility. Since a volatile investment is, by definition, a risky operation, traders usually look for ways to reduce the possibility of incurring significant money losses. In this context, it is vital to stay up to date with market events, even if this can be complex. As seen in the past, a single tweet…

Keeping Consensus: Explaining Ethereum’s Difficulty Bomb

Ethereum’s difficulty bomb is a tool for maintaining network consensus between all classes of participants. This is a challenging task for Ethereum compared to Bitcoin, which performs frequent backwards-incompatible hard-forks. The most significant of these – Ethereum 2.0 – is yet to come. When it does, the difficulty bomb will be crucial in ensuring the community’s smooth transition to the new protocol. Review: Ethereum 2.0 and Proof Of Stake To understand the necessity of the bomb, we must review some…