#46702 [SC-Insight] `executeMinting()` Enables Cross-Contract Reentrancy to Manipulate Collateral Pool Pricing
Description
Description
function executeMinting(
IPayment.Proof calldata _payment,
uint64 _crtId,
)
internal
{
.........................................
uint256 mintValueUBA = Conversion.convertAmgToUBA(crt.valueAMG);
require(_payment.data.responseBody.receivedAmount >= SafeCast.toInt256(mintValueUBA + crt.underlyingFeeUBA),
"minting payment too small");
// we do not allow payments before the underlying block at requests, because the payer should have guessed
// the payment reference, which is good for nothing except attack attempts
require(_payment.data.responseBody.blockNumber >= crt.firstUnderlyingBlock,
"minting payment too old");
// mark payment used
AssetManagerState.get().paymentConfirmations.confirmIncomingPayment(_payment);
// execute minting
@>> _performMinting(agent, MintingType.PUBLIC, _crtId, crt.minter, crt.valueAMG,
uint256(_payment.data.responseBody.receivedAmount), calculatePoolFeeUBA(agent, crt));
// pay to executor if they called this method
uint256 unclaimedExecutorFee = crt.executorFeeNatGWei * Conversion.GWEI;
if (msg.sender == crt.executor) {
// safe - 1) guarded by nonReentrant in AssetManager.executeMinting, 2) recipient is msg.sender
@>> Transfers.transferNAT(crt.executor, unclaimedExecutorFee);
unclaimedExecutorFee = 0;
}
// pay the collateral reservation fee (guarded against reentrancy in AssetManager.executeMinting)
CollateralReservations.distributeCollateralReservationFee(agent,
crt.reservationFeeNatWei + unclaimedExecutorFee);
// cleanup
@>> CollateralReservations.releaseCollateralReservation(crt, _crtId); // crt can't be used after this
}Impact
Recommendation
References
Proof of Concept
Proof of Concept
Previous#46688 [SC-High] `claimAirdropDistribution()` Allows Arbitrary Inflation of `totalCollateral`Next#46714 [SC-Medium] Agent can frontrun executor to steal unclaimed executor fee in minting process
Was this helpful?