Data corruption in NFTFloorOracle ; Denial of Service
The NFTFloorOracle contract's feeder removal logic fails to update the index mapping after swapping and popping, causing corrupted data and out-of-bounds reverts. This prevents removal of some feeders, potentially leading to denial of service.
Submitted by Englave, also found by Trust, Josiah, minhquanym, Jeiwan, kaliberpoziomka8552, 9svR6w, unforgiven, csanuragjain, RaymondFam, and Lambda
During _removeFeeder operation in NFTFloorOracle contract, the feeder is removed from feeders array, and linking in feederPositionMap for the specific feeder is removed. Deletion logic is implemented in “Swap + Pop” way, so indexes changes, but existing code doesn’t update indexes in feederPositionMap after feeder removal, which causes the issue of Denial of Service for further removals. As a result:
- Impossible to remove some
feedersfrom the contract due to Out of Bounds array access. Removal fails because of transaction revert. - Data in
feederPositionMapis corrupted after somefeedersremoval. Data linking fromfeederPositionMap.indextofeedersarray is broken.
Proof of Concept
address internal feederA = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
address internal feederB = 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2;
address internal feederC = 0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db;
function corruptFeedersMapping() external {
console.log("Starting from empty feeders array. Array size: %s", feeders.length);
address[] memory initialFeeders = new address[](3);
initialFeeders[0] = feederA;
initialFeeders[1] = feederB;
initialFeeders[2] = feederC;
this.addFeeders(initialFeeders);
console.log("Feeders array: [%s, %s, %s]", initialFeeders[0], initialFeeders[1], initialFeeders[2]);
console.log("Remove feeder B");
this.removeFeeder(feederB);
console.log("feederPositionMap[A] = %s, feederPositionMap[C] = %s", feederPositionMap[feederA].index, feederPositionMap[feederC].index);
console.log("Mapping for Feeder C store index 2, which was not updated after removal of B. Feeders array length is : %s", feeders.length);
console.log("Try remove Feeder C. Transaction will be reverted because of access out of bounds of array. Data is corrupted");
this.removeFeeder(feederC);
}
Snippet execution result:
Tools Used
Visual inspection; Solidity snippet for PoC
Recommended Mitigation Steps
Update index in feederPositionMap after feeders swap and pop.
feeders[feederIndex] = feeders[feeders.length - 1];
feederPositionMap[feeders[feederIndex]].index = feederIndex; //Index update added as a recommendation
feeders.pop();
yubo-ruan (Paraspace) confirmed
I’ve submitted this report as well. However, I believe it does not meet the high criteria set for HIGH severity finding. For HIGH, warden must show a direct loss of funds or damage to the protocol that stems from the specific issue. Here, there are clearly several conditionals that must occur in order for actual damage to take place. Regardless, will respect judge’s views on the matter.
I’ve submitted this report as well. However, I believe it does not meet the high criteria set for HIGH severity finding. For HIGH, warden must show a direct loss of funds or damage to the protocol that stems from the specific issue. Here, there are clearly several conditionals that must occur in order for actual damage to take place. Regardless, will respect judge’s views on the matter.
I respectfully disagree. The scenario is likely to occur at some point during normal operation of the protocol. The inability to remove dead or malfunctioning feeders can easily lead to the complete breakdown of the protocol and significant funds loss, the “data corruption” mentioned in the report. The severity of this issue, when it occurs, justifies the high risk rating.
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 removal function swaps the last feeder into the removed feeder's slot and pops the array, but does not update the position map for the moved feeder.
Impact
Some feeders cannot be removed, and the position map becomes corrupted, which could lead to a denial of service for feeder management and potentially protocol breakdown.
What the attacker needed
At least three feeders added; Removal of a feeder that is not the last
The fix
Update the index in feederPositionMap after swapping and popping, as shown in the recommended mitigation.
How it was found
- Start with an empty feeders array and add three feeders (A, B, C).
- Remove feeder B.
- Observe that the position map for feeder C still stores index 2, which is now out of bounds.
- Attempt to remove feeder C; the transaction reverts due to out-of-bounds array access.
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.
The contract keeps a list of feeders (addresses allowed to update prices) and a map that records each feeder's position in that list. When a feeder is removed, the code swaps it with the last feeder and shrinks the list, but forgets to update the map for the feeder that was moved. Later, trying to remove that moved feeder fails because the map points to an index that no longer exists, so the transaction reverts.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.