Agents can game the system by ensuring they always have msg.value > transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE when CoreVault::transferToCoreVault() is called.
The transferToCoreVault function refunds the entire amount above the transfer fee when the agent sends more than the fee plus gas allowance, instead of keeping the gas allowance. An agent can send a dust amount extra to always receive the gas allowance back, causing the protocol to lose that allowance on each transfer.
Originally disclosed on Immunefi
- Disclosed after under an hour
#46826 [SC-Medium] transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE` when `CoreVault::transferToCoreVault()` is called.
Submitted on Jun 5th 2025 at 00:18:03 UTC by @OxSCSamurai for Audit Comp | Flare | FAssets
- Report ID: #46826
- Report Type: Smart Contract
- Report severity: Medium
- Target: https://github.com/flare-foundation/fassets/blob/main/contracts/assetManager/library/CoreVault.sol
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Agents can game the system by ensuring they always have msg.value > transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE when CoreVault::transferToCoreVault() is called.
Summary:
- Instead of paying the full fee of
transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE, agents can get a gas refund equivalent tomsg.value - transferFeeWeiwhich refunds them theTransfers.TRANSFER_GAS_ALLOWANCE+ any surplus, instead of refunding them only the surplus or dust amount. - The fact that the agent only needs his
msg.valueto be a dust amount more thantransferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCEin order to get this incorrect refund and pay less gas than the protocol intended, should draw some scrutiny to the implementation of this mechanism in this instance. - In fact, an agent would be able to ensure 100% of the time that they pay less gas/fees than intended, by simply sending a dust amount of gas more the fee + gas allowance total.
- Yet, if
msg.valueis exactly fee + gas allowance total, the fullmsg.valueis sent tostate.nativeAddress.
Problem section:
// set the active request
_agent.activeTransferToCoreVault = redemptionRequestId;
// pay the transfer fee and return overpaid transfer fee when the difference is larger than gas use
// (all transfers are guarded by nonReentrant in the facet)
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);
}
// send event
uint256 transferredUBA = Conversion.convertAmgToUBA(transferredAMG);
emit ICoreVault.TransferToCoreVaultStarted(agentVault, redemptionRequestId, transferredUBA);
}
To demonstrate what I mean:
Current code's issue:
if (msg.value > transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE) {
Transfers.transferNAT(state.nativeAddress, transferFeeWei); // Takes only fee
Transfers.transferNATAllowFailure(payable(msg.sender), msg.value - transferFeeWei); // Returns too much
}
- Condition checks for
fee + allowance - But only takes
fee - Returns everything above
fee - Protocol loses intended
allowance
Correct implementation:
if (msg.value > transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE) {
Transfers.transferNAT(state.nativeAddress, transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE); // Takes both
Transfers.transferNATAllowFailure(payable(msg.sender), msg.value - (transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE)); // Returns true excess
}
- Takes both
fee + allowance - Returns only true excess
- Matches intended behavior
- Protocol keeps what it should
Impacts:
The ramifications are limited but notable:
- Easy to exploit by sending slightly more than fee + allowance
- The protocol keeps only the
transferFeeWeiinstead oftransferFeeWei + TRANSFER_GAS_ALLOWANCE - Agents get back more than they should
- Protocol loses the intended gas allowance on each transaction, i.e. Protocol accumulates less gas than intended
- Economic impact is bounded by
TRANSFER_GAS_ALLOWANCE * number of transactions, i.e. (Protocol losesTRANSFER_GAS_ALLOWANCEamount per transfer) - Violates the intended economic design
- If
TRANSFER_GAS_ALLOWANCEis small (e.g., 100k gas), impact is minimal - Could affect protocol's ability to perform operations
Impact: medium Likelihood: high Severity: medium
Impacts in scope:
- Low: Contract fails to deliver promised returns, but doesn't lose value
Proof of Concept
Proof of Concept (PoC):
Step by step PoC:
// 1. Set up
transferFeeWei (e.g., 0.01 ETH)
TRANSFER_GAS_ALLOWANCE (0.001 ETH)
Add a small amount to trigger the bug (e.g., 0.0001 ETH)
// 2. Send transfer with excess
msg.value = 0.0111 ETH // This is > (0.01 + 0.001) ETH
// 3. Expected behavior:
Protocol keeps: 0.011 ETH (fee + allowance)
Refund: 0.0001 ETH
// 4. Actual behavior:
Protocol keeps: 0.01 ETH (only fee)
Refund: 0.0011 ETH (0.001 ETH extra returned)
- This demonstrates how the protocol loses the gas allowance amount in every transfer where
msg.value > transferFeeWei + TRANSFER_GAS_ALLOWANCE.
Recommended Fix:
- This ensures the protocol keeps both the fee and the gas allowance as intended, while only returning the true excess amount to the user.
if (msg.value > transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE) {
uint256 totalToKeep = transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE;
Transfers.transferNAT(state.nativeAddress, totalToKeep);
Transfers.transferNATAllowFailure(payable(msg.sender), msg.value - totalToKeep);
}
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
The condition checks if msg.value exceeds fee plus gas allowance, but the code only transfers the fee to the protocol and refunds the rest, failing to retain the gas allowance.
Impact
The protocol loses the gas allowance on each transfer where msg.value exceeds fee plus allowance, accumulating a small economic loss bounded by the allowance times the number of transactions.
What the attacker needed
Agent role in the protocol; Ability to call transferToCoreVault; Send msg.value > fee + gas allowance
The fix
The code should transfer fee plus gas allowance to the protocol and refund only the excess above that total.
How it was found
- Set transferFeeWei and TRANSFER_GAS_ALLOWANCE values.
- Send a transfer with msg.value greater than fee + allowance (e.g., by a dust amount).
- Observe that the protocol keeps only the fee, and the agent receives a refund that includes the gas allowance.
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.
When you send money to a smart contract, you can include extra to cover fees. Here, the contract is supposed to keep a small gas allowance from that extra, but it mistakenly refunds the whole extra amount above the base fee. So an agent can send a tiny bit more than needed and always get the gas allowance back, making the protocol lose that small amount each time.
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.