#45604 [SC-Low] User Overpayment in `transferToCoreVault` Fee Handling
Description
// contracts/assetManager/library/CoreVault.sol
// ...
uint256 transferFeeWei = getTransferFee(transferredAMG);
require(msg.value >= transferFeeWei, "transfer fee payment too small"); // User must send at least the fee
// ...
// pay the transfer fee and return overpaid transfer fee when the difference is larger than gas use
if (msg.value > transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE) {
// Scenario 1: Significant overpayment
Transfers.transferNAT(state.nativeAddress, transferFeeWei); // Fee collector gets the exact calculated fee
Transfers.transferNATAllowFailure(payable(msg.sender), msg.value - transferFeeWei); // User gets the remainder refunded
} else {
// Scenario 2: msg.value is between transferFeeWei (inclusive)
// and transferFeeWei + Transfers.TRANSFER_GAS_ALLOWANCE (inclusive)
Transfers.transferNAT(state.nativeAddress, msg.value); // Fee collector gets the entire msg.value sent by the user
}
// ...Proof of Concept
Proof of Concept
Previous#45674 [SC-Insight] `executeMinting()` allows impersonation of minter during chain-reorg due to deterministic `crtId` and lack of minter bindingNext#45731 [SC-Insight] Off-by-One Logic in Escrow End Timestamp Calculation May Cause Unintended Escrow Delay
Was this helpful?