#47299 [SC-Insight] The `is_risky` check is improper.
Description
Brief/Intro
Vulnerability Details
fn is_risky(
self: @AccountState,
position_size_before: felt252,
position_size_after: felt252,
trade_fee: i128,
) -> bool {
let asset_value = self.get_asset_value();
let (margin_requirement, total_upnl) = self
.margin_requirement_and_total_upnl(MARGIN_CHECK_INITIAL);
let account_value: i128 = asset_value + total_upnl;
let free_balance = account_value - margin_requirement - trade_fee;
if free_balance >= 0 {
return false;
}
let abs_pos_before = abs_128(position_size_before.try_into().unwrap());
let abs_pos_after = abs_128(position_size_after.try_into().unwrap());
let position_decrease = abs_pos_before - abs_pos_after;
if position_decrease >= 0 && account_value >= 0 {
return false;
}Impact Details
References
Proof of Concept
Proof of Concept
Previous#47295 [SC-Insight] Configurator Can Manipulate Critical Parameters to Force Mass Liquidations and Drain Protocol FundsNext#47309 [SC-Medium] Type mishandling allows for users to withdraw FAST from vault instead of STANDARD
Was this helpful?