Tweak location info for SWC-128#212
Merged
muellerberndt merged 2 commits intoSmartContractSecurity:masterfrom Oct 23, 2019
Merged
Tweak location info for SWC-128#212muellerberndt merged 2 commits intoSmartContractSecurity:masterfrom
muellerberndt merged 2 commits intoSmartContractSecurity:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In SWC-128 a data structure may grow very large over a series of successful transactions to a point where some function that iterates over that data structure requires too much gas, causing a DoS. There are 2 general places where you can fix this issue:
Prevent the datastructure from growing unboundedly
Re-write all functions that iterate over the data structure to be able to do so over multiple transactions.
The text of SWC-128, and especially the remediation parts focus on (2). E.g.
"Caution is advised when you expect to have large arrays that grow over time. Actions that require looping across the entire data structure should be avoided.
If you absolutely must loop over an array of unknown size, then you should plan for it to potentially take multiple blocks, and therefore require multiple transactions."
2 of the 3 examples however(dos_number.sol and dos_simple.sol) point out the location where the data structure grows instead of the location that iterates and causes the DoS.
This PR proposes to change the location of these two samples.
Note: A more complete solution would be to report both locations as contributing to the issue, however doing this cleanly requires support for multiple tagged locations associated with a single issue. After this has been implemented we can expand the source location for these issues.