Faulty logic in transferToCoreVault makes users pay more for the refund transaction than the amount being refunded.
The refund check in transferToCoreVault compares an amount in wei against a constant that is measured in gas units, so the threshold is effectively tiny. Almost any overpayment then triggers a refund whose gas cost exceeds the amount refunded, leaving users worse off.
- Disclosed after under an hour
#46486 [SC-Low] Faulty logic in `transferToCoreVault` makes users pay more for the refund transaction than the amount being refunded.
Submitted on May 31st 2025 at 14:38:20 UTC by @ni8mare for Audit Comp | Flare | FAssets
- Report ID: #46486
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/flare-foundation/fassets/blob/main/contracts/assetManager/library/CoreVault.sol
- Impacts:
- Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)
Description
Brief/Intro
transferToCoreVault in CoreVault.sol incorrectly compares msg.value (wei) with TRANSFER_GAS_ALLOWANCE (gas units) in the refund threshold check. This creates a meaningless threshold of 100,000 wei (≈0.0000000000001 NAT).
Almost any overpayment triggers a refund that costs users more in gas than they receive back, causing a loss to them.
Vulnerability Details
In the transferToCoreVault function, there is the following logic to refund any excess amount back to the user:
if (msg.value > transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE) {
Transfers.transferNAT(state.nativeAddress, transferFeeWei);
Transfers.transferNATAllowFailure(payable(msg.sender), msg.value - transferFeeWei);
} else {
Transfers.transferNAT(state.nativeAddress, msg.value);
}
If (msg.value > transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE) , you refund, otherwise you don't. The comparison with TRANSFER_GAS_ALLOWANCE is attempting to ensure there's enough excess value to justify spending the caller's gas on a refund. The logic probably is: "only refund if the amount is large enough that it's worth the caller paying gas to get it back."
But the comparison is incorrect. msg.value and transferFeeWei are in wei, but Transfers.TRANSFER_GAS_ALLOWANCE is in gas units. This is apparent from how it's being used:
function transferNATAllowFailure(address payable _recipient, uint256 _amount)
internal
requireReentrancyGuard
returns (bool)
{
if (_amount > 0) {
/* solhint-disable avoid-low-level-calls */
//slither-disable-next-line arbitrary-send-eth
(bool success, ) = _recipient.call{value: _amount, gas: TRANSFER_GAS_ALLOWANCE}("");
/* solhint-enable avoid-low-level-calls */
return success;
}
return true;
}
So, we are comparing a value in wei with units of gas. This is incorrect and leads to a loss for the users. The TRANSFER_GAS_ALLOWANCE is just 100,000, which is a very small value in wei, and any excess amount will be easily more than this value. Therefore, any slightly excessive amount will end up triggering the refund, even if the gas cost to complete that refund transaction is more than the amount being refunded. So, users end up paying more in gas to support the refund transaction than the refund amount. This is the opposite of what the protocol intends to do.
The protocol needs to use an equivalent value of TRANSFER_GAS_ALLOWANCE in wei. Something like TRANSFER_GAS_ALLOWANCE * gas price in wei / gas unit. Then the above comparison becomes correct.
Impact Details
Every small overpayment triggers a refund call, wasting gas. Users will get refunds even for tiny amounts that cost more in gas than the refund value itself. Hence, users pay more in gas for unnecessary refund attempts than they get back.
Also, if the user believes that the excess amount they pay might be less than the gas cost for a refund, and hence, if they use gas just to complete their transaction, believing that the refund tx will not be included in the function call, will see their transactions being reverted because refund got executed for which they did not pay.
The protocol is harming its own users through economically irrational refund mechanisms. The protocol is essentially griefing its own users through faulty logic.
The likelihood becomes high because any excess payment triggers a refund. Instead of just those refunds which are economically viable. The impact is low to medium. Hence, this is a medium severity issue.
References
Proof of Concept
Proof of Concept
- User calls
transferToCoreVault. Let's say that thetransferFeeWeifor this transaction is 0.01 NAT (10,000,000,000,000,000 wei). User overpays by 0.00001 NAT (10,000,000,000,000 wei). So, the total value sent is equal to 0.01 NAT + 0.00001 NAT = 10010000000000000 wei. - Current threshold: 10,000,000,000,000,000 (
transferFeeWei) + 100,000 (TRANSFER_GAS_ALLOWANCE) = 10000000000100000 wei. - As the value being sent - 10010000000000000 wei is greater than the threshold 10000000000100000 wei, a refund is triggered. As the refund triggers for overpayment of just 100,001 wei.
- But, gas cost for refund: ~100,000 gas × gas_price (likely >> 0.00001 NAT), especially when gas prices are high in the network due to high traffic.
- Hence, the user actually loses value because of the refund. The protocol is griefing its own users due to faulty logic.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the refund threshold compares msg.value in wei against TRANSFER_GAS_ALLOWANCE, which is a gas-unit constant, instead of converting the gas allowance into a wei value first.
Impact
Users could lose value on small overpayments because the refund costs more in gas than it returns, and transactions may revert when the caller did not budget for the refund call.
What the attacker needed
User calls transferToCoreVault; small overpayment above the fee
The fix
The threshold should convert the gas allowance into a wei amount using the current gas price before comparing it with msg.value.
How it was found
- User calls transferToCoreVault with a small overpayment above the transfer fee.
- The contract compares the sent value against the fee plus the gas allowance constant.
- Because the constant is tiny in wei terms, the refund branch is taken.
- The refund is sent, costing more gas than the amount returned.
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 report has not been written yet. The Original tab links to the source.
On Ethereum-style chains, a transaction can carry extra money (called wei) to pay for a service. The contract tries to send any extra back, but only if the extra is big enough to be worth the gas fee. Here the 'big enough' number was written in gas units instead of money, so the check almost always passes and the user pays more in fees than they get back.
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.