Smart Contract / Assert Violation



Assert Violation is a vulnerability that occurs in smart contracts and is categorized as CWE-613. It occurs when an assertion is made in a smart contract and is not enforced. OWASP defines this type of vulnerability as "failure to properly enforce an assertion that has been made". This leads to a denial of service attack, which can result in the smart contract being unable to process transactions or being completely frozen.


Assert Violation is a high-risk vulnerability that can lead to a denial of service attack and the loss of funds or data stored in the smart contract. It is important to ensure that all assertions made in a smart contract are enforced in order to protect the system from malicious attacks.


The best way to prevent Assert Violation is to ensure that all assertions in a smart contract are enforced. This can be done by adding checks and balances to the code that ensure that the assertion is enforced before any transactions are made. Additionally, it is important to keep the code up to date and to audit it regularly to ensure that all assertions are enforced.

Example Below is an example of a code snippet with a vulnerable Assert Violation. The code is taken from the CVE-2020-15011 vulnerability.

contract Token {
    uint256 public totalSupply;

    function transfer(address to, uint256 amount) public {
        require(amount > 0);
        require(balanceOf[msg.sender] >= amount);
        balanceOf[msg.sender] -= amount;
        balanceOf[to] += amount;
        // This assertion is not enforced
        assert(balanceOf[msg.sender] + amount == balanceOf[to]);

Curious? Convinced? Interested?

Arrange a no-obligation consultation with one of our product experts today.