#46119 [SC-Low] Incorrect `msg.Value` check in `CoreVault` Transfer
Submitted on May 25th 2025 at 06:53:02 UTC by @aman for Audit Comp | Flare | FAssets
Report ID: #46119
Report Type: Smart Contract
Report severity: Low
Target: https://github.com/flare-foundation/fassets/blob/main/contracts/assetManager/library/CoreVault.sol
Impacts:
Permanent freezing of funds
Description
Brief/Intro
The transferToCoreVault function in CoreVault.sol incorrectly assumes that the TRANSFER_GAS_ALLOWANCE should be retained by the contract, when in fact the gas costs are paid by the agent (msg.sender) directly. This leads to unnecessary retention of funds that should be returned to the agent.
Vulnerability Details
The vulnerable code is in CoreVault.sol:
if (msg.value > transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE) {
Transfers.transferNAT(state.nativeAddress, transferFeeWei);
Transfers.transferNATAllowFailure(payable(msg.sender), msg.value - transferFeeWei);
}The issue is that the code:
Checks if
msg.valueis greater thantransferFeeWei + TRANSFER_GAS_ALLOWANCEBut the
TRANSFER_GAS_ALLOWANCEis unnecessary because:Gas costs are paid by the agent (msg.sender) directly through the transaction
The contract doesn't need to retain any additional gas allowance
The only fee that should be retained is the
transferFeeWei
Impact Details
Severity: Medium
Impact: Unnecessarily retains funds that should be returned to the agent
Likelihood: High - Affects every transfer to core vault where
msg.value > transferFeeWeiandmsg.value <= transferFeeWei + TRANSFER_GAS_ALLOWANCE
References
File:
contracts/assetManager/library/CoreVault.solFunction:
transferToCoreVault
Recommendations
Remove the
TRANSFER_GAS_ALLOWANCEcheck since gas costs are paid by the msg.sender:
Proof of Concept
Proof of Concept
To proof my point I have added few changed to CoreVault.sol file :
And also update the Agent.ts:
And than add following test case to CoreVault.ts file:
Run with command yarn testHH console.logs of this test :
Was this helpful?