Vulnerability Database

405,491

Total vulnerabilities in the database

Vyper interfaces returning integer types less than 256 bits can be manipulated if uint256 is used — vyper

VVE-2020-0001

Earlier today, we received a responsible disclosure of a potential issue from @montyly (security researcher at @trailofbits) for Vyper users who make assumptions about what values certain interface types can return.

Impact

We determined the issue to be mild and unlikely to be exploited, with an easy workaround while the correct resolution is in process. The issue stems from a number of things, which we will detail here.

(1) The ABI Specification is under-defined such that function return type is not always reflected in how you use it

This means that a function which returns uint8 under the hood actually returns a 32 byte integer, making it identical to a function that returns uint256. This allows users to read an interface that returns a uint8 value to be stored into a uint256 variable without any explicit casting or input validation.

(2) Vyper doesn't have uint8 types

When Vyper was originally created, it only had one numeric type, but we added just enough types to be able to work with the majority of ERC interfaces that exist.

Unfortunately, we never added uint8, because it's only majority usage was for ERC20.decimals() as the return type, which isn't reflected in the method ID. Because of (1), it didn't matter that we didn't have these types implemented because you could capture the return value as uint256 and use it just fine.

(3) ERC20.decimals() returns uint8

ERC20.decimal() (which is an optional function) returns a uint8 type. While it was never intentioned to be used directly within a smart contract (hence being optional), someone could easily make the decision to rely on it to perform important functionality within their Vyper smart contract. This might lead to a scenario where an unexpectedly large value (> 255) returned by calling this function (which a malicious contract writer might write) would allow an attacker to manipulate or bypass certain logic depending on this value.

In summary, because of (1), it isn't necessary to have to cast the return value of a function that returns uint8 to uint256, and because of (2) it isn't possible to have the type system protect against this type of error. This could lead to scenarios like (3) where this behavior can be exploited.

Patches

We are currently refactoring our typing system so we can implement all ABI-compliant integer types, but no currently patched version is available that gives users access to the uint8 type.

Workarounds

There is an easy workaround where you should check that the value returned by an interface which specifies uint8 should be checked to be within the bounds of a uint8 integer. As an example:

... # returns uint8, but we implicitly cast to uint256 without checking decimals: uint256 = ERC20(_token).decimal() # FIX: Insert this line assert decimals < 256 ...

Depending on how you use this value, it may not be necessary to insert this check.

References

For more information

If you have any questions or comments about this advisory:

  • Published: Mar 25, 2020
  • Updated: Apr 14, 2023
  • GHSA: GHSA-mr6r-mvw4-736g
  • Severity: Low
  • Exploit:
  • CISA KEV:

No technical information available.

No CWE or OWASP classifications available.

Is vyper exposed on your perimeter?

A vulnerability database tells you what is broken. Attack surface management tells you where it is running: it discovers your internet-facing assets and flags the ones affected by issues like this one.

What is attack surface management? →

Frequently Asked Questions

A security vulnerability is a weakness in software, hardware, or configuration that can be exploited to compromise confidentiality, integrity, or availability. Many vulnerabilities are tracked as CVEs (Common Vulnerabilities and Exposures), which provide a standardized identifier so teams can coordinate patching, mitigation, and risk assessment across tools and vendors.

CVSS (Common Vulnerability Scoring System) estimates technical severity, but it doesn't automatically equal business risk. Prioritize using context like internet exposure, affected asset criticality, known exploitation (proof-of-concept or in-the-wild), and whether compensating controls exist. A "Medium" CVSS on an exposed, production system can be more urgent than a "Critical" on an isolated, non-production host.

A vulnerability is the underlying weakness. An exploit is the method or code used to take advantage of it. A zero-day is a vulnerability that is unknown to the vendor or has no publicly available fix when attackers begin using it. In practice, risk increases sharply when exploitation becomes reliable or widespread.

Recurring findings usually come from incomplete Asset Discovery, inconsistent patch management, inherited images, and configuration drift. In modern environments, you also need to watch the software supply chain: dependencies, containers, build pipelines, and third-party services can reintroduce the same weakness even after you patch a single host. Unknown or unmanaged assets (often called Shadow IT) are a common reason the same issues resurface.

Use a simple, repeatable triage model: focus first on externally exposed assets, high-value systems (identity, VPN, email, production), vulnerabilities with known exploits, and issues that enable remote code execution or privilege escalation. Then enforce patch SLAs and track progress using consistent metrics so remediation is steady, not reactive.

SynScan combines attack surface monitoring and continuous security auditing to keep your inventory current, flag high-impact vulnerabilities early, and help you turn raw findings into a practical remediation plan.