Submitted by Eeyore, also found by LokiThe5th, Trust (1, 2), pontifex, oakcobalt, and Brenzee
https://github.com/code-423n4/2023-07-basin/blob/9403cf973e95ef7219622dbbe2a08396af90b64c/src/Well.sol#L352-L377 https://github.com/code-423n4/2023-07-basin/blob/9403cf973e95ef7219622dbbe2a08396af90b64c/src/Well.sol#L590-L598
The Well contract mandates that the Pumps should be updated with the previous blocks reserves in case reserves are changed in the current block to reflect the price change accurately.
However, this doesnt happen in the shift() and sync() functions, providing an opportunity for any user to manipulate the reserves in the current block before updating the Pumps with new manipulated reserves values.
The Pumps (oracles) can be manipulated. This can affect any contract/protocol that utilizes Pumps as on-chain oracles.
Note: The sync() function can also manipulate reserves in the current block, but its less useful than shift() from an attackers perspective.
This test illustrates how to use shift() to manipulate Pumps data.
Create test/pumps/Pump.Manipulation.t.sol and run forge test --match-test manipulatePump.
Foundry
Update Pumps in the shift() and sync() function.
publiuss (Basin) confirmed and commented:
