Certain classes of contracts utilizing abi_decode crash the compiler.
Vulnerability Details
The compiler crashes with the following message:
2527 | pub trait AbiDecode {
2528 | fn abi_decode(ref mut buffer: BufferReader) -> Self;
| ^^^^^^^^^^ Internal compiler error: Method abi_decode_37 is a trait method dummy and was not properly replaced.
Please file an issue on the repository and include the code that triggered this error.
2529 | }
|
Impact Details
Certain classes of programs are not possible to compile due to a compiler bug.
Proof of concept
Proof of Concept
src/main.sw
contract;
use std::bytes::*;
abi MyAbi {
fn test() -> u64;
}
abi FakeAbi {
fn test() -> Bytes;
}
impl MyAbi for Contract {
fn test() -> u64 {
64
}
}
#[test]
fn test() {
let caller = abi(FakeAbi, CONTRACT_ID);
let res = caller.test();
assert(res.len() == 64);
let s: str[30] = abi_decode(res.as_raw_slice());
}