Epilogue_gas_payer Silently Drops Excess Storage Fee Refunds Under Governed Gas Pool
When the governed gas pool feature is enabled, the epilogue_gas_payer function fails to refund the excess storage fee to the gas payer. This causes users to silently lose funds that should have been returned to them.
- Disclosed after under an hour
#43135 [BC-High] `epilogue_gas_payer` Silently Drops Excess Storage Fee Refunds Under Governed Gas Pool
Submitted on Apr 2nd 2025 at 15:36:07 UTC by @jovi for Attackathon | Movement Labs
- Report ID: #43135
- Report Type: Blockchain/DLT
- Report severity: High
- Target: https://github.com/immunefi-team/attackathon-movement-aptos-core/tree/main
- Impacts:
- Direct loss of funds
- Modification of transaction fees outside of design parameters
Description
Summary
When governed_gas_pool_enabled() is active, epilogue_gas_payer fails to refund excess storage fees (storage_fee_refunded - amount_to_burn), resulting in silent, unavoidable loss of user funds.
Vulnerability Details
Location
-
File:
aptos_framework::transaction_validation::sources::transaction_validation.move -
Function:
epilogue_gas_payer -
Relevant Code:
MOVE } else if (amount_to_burn < storage_fee_refunded) { let mint_amount = storage_fee_refunded - amount_to_burn; if (!features::governed_gas_pool_enabled()) { transaction_fee::mint_and_refund(gas_payer, mint_amount); } // No refund when governed_gas_pool_enabled() is true };
Description
The epilogue_gas_payer function finalizes transaction fee accounting. When storage_fee_refunded exceeds amount_to_burn, the surplus (mint_amount) should be returned to the gas_payer. This works when governed_gas_pool_enabled() is false, but when true, the surplus is discarded due to the missing else branch. Users lose entitled funds without notification.
Impact
- Significant Fund Loss: Users lose all excess refunds in a widespread fashion, whenever the condition triggers, potentially affecting thousands of transactions .
- Economic Instability: Cumulative losses disrupt the fee model, deterring users/dApps that would be expecting refunds.
- Exploitable Harm: Attackers may maximize losses via storage-heavy transactions targeting refunds.
Recommended Mitigation
} else if (amount_to_burn < storage_fee_refunded) {
let mint_amount = storage_fee_refunded - amount_to_burn;
if (!features::governed_gas_pool_enabled()) {
transaction_fee::mint_and_refund(gas_payer, mint_amount);
} else {
transaction_fee::mint_and_refund(gas_payer, mint_amount); // Direct refund
// OR: coin::deposit(governed_gas_pool_address, mint_amount); // Pool redirect
}
};
Proof of Concept
- Setup: Deploy with
governed_gas_pool_enabled()set totrue. - Transaction: Execute storage cleanup:
storage_fee_refunded = 100 APTamount_to_burn = 60 APT- Expected Refund: 40 APT (not issued).
- Observation: Toggling the flag to
falserestores refunds.
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 a missing else branch in the refund logic when the governed gas pool feature is enabled, causing the surplus to be discarded instead of refunded.
Impact
Users could lose excess storage fee refunds silently, potentially affecting many transactions and causing economic instability.
What the attacker needed
Governed_gas_pool_enabled() is true; storage_fee_refunded > amount_to_burn
The fix
The code should be fixed to refund the surplus even when governed_gas_pool_enabled() is true, either directly or by depositing into the governed gas pool.
How it was found
- Deploy with governed_gas_pool_enabled() set to true.
- Execute a storage cleanup transaction where storage_fee_refunded exceeds amount_to_burn.
- Observe that the expected refund is not issued.
- Toggle the flag to false and see refunds restored.
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.
In blockchain transactions, users sometimes pay more than needed for storage and should get the extra back. Here, a setting called 'governed gas pool' caused the code to skip returning that extra money, so users lost it without any warning.
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.