-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_checkDelay will not work properly for Arbitrum or Optimism due to block.number #419
Comments
That is changed after Nitro upgrade. |
TriHaz marked the issue as sponsor disputed |
@TriHaz I'd like to flag this issue with the following notes: Per the docs:
From a trusted Arbitrum Dev: So ultimately this is dependent on how big or small of a delay is required. For minutes to hours, there seems to be no risk, while for shorter timeframes, some risk is possible. In terms of impact, the main impact would be that a operation that would be expected to be executed 12 seconds later, could actually be executed as rapidly as 1 or 2 seconds after (if we assume that one L2 block goes from number A to B) I don't think the finding can be categorized High Severity due to the reliance on settings and intentions, but at this point I believe the finding is valid and am thinking it should be of Medium Severity as it may break expectations (e.g. being able to use the same oracle price in 2 separate blocks due to unexpectedly small timestamp differences), but this is reliant on an external condition |
GalloDaSballo changed the severity to 2 (Med Risk) |
I have also recently checked Optimism Docs, in anticipation of the Bedrock upgrade. Very notable warning Leading me to further agree with the risk involved with the finding, at this time I believe block.timestamp to be a better tool for all L2 integrations |
GalloDaSballo marked the issue as selected for report |
Mitigation: code-423n4/2022-12-tigris#2 (comment) |
GainsGoblin marked the issue as sponsor confirmed |
Lines of code
https://github.com/code-423n4/2022-12-tigris/blob/588c84b7bb354d20cbca6034544c4faa46e6a80e/contracts/Trading.sol#L857-L868
Vulnerability details
Impact
Trade delay will not work correctly on Arbitrum allowing users to exploit multiple valid prices
Proof of Concept
_checkDelay enforces a delay of a specific number of block between opening and closing a position. While this structure will work on mainnet, it is problematic for use on Arbitrum. According to Arbitrum Docs
block.number
returns the most recently synced L1 block number. Once per minute the block number in the Sequencer is synced to the actual L1 block number. This period could be abused to completely bypass this protection. The user would open their position 1 Arbitrum block before the sync happens, the close it the very next block. It would appear that there has been 5 block (60 / 12) since the last transaction but in reality it has only been 1 Arbitrum block. Given that Arbitrum has 2 seconds blocks I would be impossible to block this behavior through parameter changes.It also presents an issue for Optimism because each transaction is it's own block. No matter what value is used for the block delay, the user can pad enough tiny transactions to allow them to close the trade immediately.
Tools Used
Manual Review
Recommended Mitigation Steps
The delay should be measured using block.timestamp rather than block.number
The text was updated successfully, but these errors were encountered: