Fund loss possibility when bridge refunds to compromised owner account
Summary
The bridgePool() function uses owner() as a _refundRecipient, which might represent compromised account. In the event of bridge refund, the funds might be lost as sent to account under attacker control.
Vulnerability Detail
The SophonFarming has the bridgePool() function that can be called by anyone. This function calls the bridge.deposit() with owner() set as a _refundRecipient. However, the SophonFarming implements Ownable2Step, thus the owner transfer can be initiated in any moment, e.g. in the event of emergency as current owner priv keys were compromised. Assuming that solution owner initiated the owner transfer and set the pendingOwner, anyone can trigger the bridgePool() function before ownership transfer is ended. When the bridge deposit finish unsuccessfully, the _refundRecipient will still point to previous, compromised account.
Impact
Possible loss of pool's fund when refunded to compromised account.
It is recommended to either disallow usage of bridgePool() function when ownership transfer is in progress, or limit access to this function only for current owner.
cocacola
medium
Fund loss possibility when bridge refunds to compromised owner account
Summary
The
bridgePool()
function usesowner()
as a_refundRecipient
, which might represent compromised account. In the event of bridge refund, the funds might be lost as sent to account under attacker control.Vulnerability Detail
The
SophonFarming
has thebridgePool()
function that can be called by anyone. This function calls thebridge.deposit()
withowner()
set as a_refundRecipient
. However, theSophonFarming
implementsOwnable2Step
, thus the owner transfer can be initiated in any moment, e.g. in the event of emergency as current owner priv keys were compromised. Assuming that solution owner initiated the owner transfer and set thependingOwner
, anyone can trigger thebridgePool()
function before ownership transfer is ended. When the bridge deposit finish unsuccessfully, the_refundRecipient
will still point to previous, compromised account.Impact
Possible loss of pool's fund when refunded to compromised account.
Code Snippet
https://github.com/sherlock-audit/2024-05-sophon/blob/main/farming-contracts/contracts/farm/SophonFarming.sol#L772
Tool used
Manual Review
Recommendation
It is recommended to either disallow usage of
bridgePool()
function when ownership transfer is in progress, or limit access to this function only for current owner.