Port Finance Logic Error Bug Fix Review
A logic error in Port Finance's collateral withdrawal calculation allowed a user to withdraw all collateral without fully repaying their debt. An attacker could have exploited this to steal $20–25 million, but the bug was responsibly disclosed and fixed before any funds were lost.
immunefi.com
Published on immunefi.com
Whitehat nojob reported a critical vulnerability in Port Finance via Immunefi on March 29. If a malicious attacker had exploited the vulnerability, they could have stolen $20–25 million.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The max_withdraw_value function did not account for the loan-to-value ratio of the withdrawn collateral's reserve, allowing over-withdrawal when combined with a high liquidation bonus.
Impact
A malicious attacker could have stolen $20–25 million, but the bug was fixed before any funds were lost.
What the attacker needed
A Solana wallet with tokens; ability to create an obligation; reserves with suitable parameters
The fix
The max_withdraw_value function was fixed by introducing the withdraw_collateral_ltv parameter and recalculating the maximum withdraw value based on the reserve's LTV.
How it was found
- Find a reserve with high liquidation bonus and another with high LTV such that their sum exceeds 100%.
- Create an obligation and deposit a small amount of token T1 as collateral to the high-bonus reserve.
- Deposit a much larger amount of token T2 as collateral to the high-LTV reserve.
- Borrow token T2 from the high-LTV reserve, with borrow value similar to the T1 deposit.
- Withdraw the entire T2 deposit, making the obligation liquidatable.
- Liquidate the obligation, draining the T1 deposit before repaying the borrow in full.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Port Finance is a lending platform where you deposit collateral to borrow other tokens. A mistake in the code that calculates how much collateral you can withdraw let someone take back all their collateral while still owing borrowed tokens, effectively stealing from the platform. The bug was found and fixed before anyone could exploit it.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.