You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the Vyper doc (see ref 1) a small Python reference implementation for conversion logic is maintained as part of Vyper’s test suite (see ref 2)
However behavior of the compiler does not match the reference when it comes to BytesM to Bytes[] conversion
Vulnerability Details
The reference specifies the BytesM_T -> Bytes_T conversion should be possible if the size of the output type is at least as big as the in type (see ref 3)
But the compiler does not implement that behavior correctly, this is done in vyper/builtins/_convert.py(see ref 4) which does not allow bytesM as an input type for to_bytes()
Impact Details
Conversions that should work according to the reference are throwing an error at compile time.
#pragma version ^0.4.0def test(test: bytes1) -> Bytes[1]:
x: Bytes[1] =convert(test, Bytes[1])
return x
Fails with vyper.exceptions.TypeMismatch: Can't convert bytes1 to Bytes[1] even though both _bits_of_type() are equal so the conversion should be doable according to the reference
The text was updated successfully, but these errors were encountered:
credits: @impermanentW (Whitehat) for Attackathon | Ethereum Protocol
reportid: #38693
According to the Vyper doc (see ref 1) a small Python reference implementation for conversion logic is maintained as part of Vyper’s test suite (see ref 2)
However behavior of the compiler does not match the reference when it comes to BytesM to Bytes[] conversion
Vulnerability Details
The reference specifies the BytesM_T -> Bytes_T conversion should be possible if the size of the output type is at least as big as the in type (see ref 3)
But the compiler does not implement that behavior correctly, this is done in vyper/builtins/_convert.py(see ref 4) which does not allow bytesM as an input type for to_bytes()
Impact Details
Conversions that should work according to the reference are throwing an error at compile time.
Proof of concept
Compile the following code using Vyper v0.4.0
Fails with vyper.exceptions.TypeMismatch: Can't convert bytes1 to Bytes[1] even though both _bits_of_type() are equal so the conversion should be doable according to the reference
The text was updated successfully, but these errors were encountered: