Attackathon _ Fuel Network 32706 - [Smart Contract - High] the function subtract in signed libs like
Description
Brief/Intro
Vulnerability Details
impl core::ops::Subtract for I8 {
/// Subtract a I8 from a I8. Panics of overflow.
fn subtract(self, other: Self) -> Self {
let mut res = Self::new();
if self.underlying >= Self::indent()
&& other.underlying >= Self::indent()
{
if self.underlying > other.underlying {
res = Self::from_uint(self.underlying - other.underlying + Self::indent());
} else {
res = Self::from_uint(self.underlying - (other.underlying - Self::indent()));
}
} else if self.underlying >= Self::indent()
&& other.underlying < Self::indent()
{
res = Self::from_uint(self.underlying - Self::indent() + other.underlying);
} else if self.underlying < Self::indent()
&& other.underlying >= Self::indent()
{ //@audit
res = Self::from_uint(self.underlying - (other.underlying - Self::indent())); // PANIC
} else if self.underlying < Self::indent()
&& other.underlying < Self::indent()
{
if self.underlying < other.underlying {
res = Self::from_uint(other.underlying - self.underlying + Self::indent());
} else {
res = Self::from_uint(self.underlying + other.underlying - Self::indent());
}
}
res
}
}
Impact Details
References
Proof of concept
Proof of Concept
PreviousAttackathon _ Fuel Network 32703 - [Smart Contract - Low] Unexpected variable shadowing during ir geNextAttackathon _ Fuel Network 32728 - [Smart Contract - Low] Incorrect literal type inference
Last updated
Was this helpful?