Attackathon _ Fuel Network 32937 - [Smart Contract - Insight] Fallback function can be directly call
Description
Brief/Intro
Vulnerability Details
// ... ommited
// <- lines 12-13 compile with no errors resulting incorrect abi's
abi RunExternalTest {
#[fallback(arg1)] // the compiler doesn't prevent this invalid syntax
fn fallback(foo: u64) -> u64;
fn double_value(foo: u64) -> u64;
fn large_value() -> b256;
}
// <- lines 19-22 compile with no errors resulting incorrect abi's
impl RunExternalTest for Contract {
#[fallback(arg1)] // the compiler doesn't prevent this invalid syntax
fn fallback(foo: u64) -> u64 {
foo * 10
}
// ...omitted
// ANCHOR: fallback
#[fallback, storage(read, write)] // fallback(arg1) will also be compiled
fn fallback() -> u64 {
use std::call_frames::*;
let foo = called_args::<u64>();
storage.simple_value.write(foo);
foo
// ANCHOR_END: fallback
`functions` from `run_external_target-abi.json`:
"functions": [
{
... // omitted
"name": "fallback", // should never be present in ABI
"output": {
"name": "",
"type": 1,
"typeArguments": null
},
"attributes": [
{
"name": "fallback",
"arguments": [
"arg1" // should never has arguments defined
]
}
]
},
... // omitted
],Impact Details
References
Proof of concept
Proof of Concept
PreviousAttackathon _ Fuel Network 32935 - [Smart Contract - Insight] Insufficient trait duplication checkNextAttackathon _ Fuel Network 32938 - [Smart Contract - Insight] Insufficient declaration shadowing che
Last updated
Was this helpful?