-
Notifications
You must be signed in to change notification settings - Fork 169
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
Clarification needed for SWC-123 #119
Comments
I'm not quite sure I fully understand the question. The case where the external input is provided by a contract is the only case we care about here. If users provide invalid inputs it's clearly their fault. Is this what you would like to be clarified (e.g., by changing the title to "requirement violation by contract")? |
Yep, to me the title "Requirement Violation" would indicate that requirement violations are always "wrong". However, the way I understand it, IMO if the The distinction here is whose fault it is that an invalid input was provided?
As what do we refer to them in the latter case? |
For clarification:
In this case, we report a weakness in Would SWC-123 also apply if doubleBaz was changed to:
|
I would say requirement violations are always "wrong". However, it's more challenging to determine who is to blame (see the two cases in the description about how to fix them). Usually, the external entity (contract or user) is to blame (e.g., precondition violation), but it might also be that the requirement is overly strong. I don't think there is a standard name for referring to cases where the callee returns invalid outputs (maybe postcondition violation although here the check happens in the caller which is a bit unusual). But I don't think the naming is that important here since I suspect this case is much less common. About your example: Yes, in your modified example I would argue that |
Hmm, yeah in a sense requirement violations are always "wrong" when happening during runtime, but the use of a Compare this with SWC-110 - Assert Violation. An assert violation necessarily shows that either there's something wrong with the contract or I think using the title from CWE would make this clearer. Maybe split this up into 2 SWCs:
|
Yes, using I can see why one might want to split the two cases up. However, I feel like it might complicate things for tools without making the description much simpler. In particular, I'm afraid that tools won't be able to automatically decide which weakness ID (between the two cases) to assign. Obviously, this is easy for some cases (e.g., without calls before the violation), but there can be cases where (caller) arguments are validated even after calls to other contracts and then things can get much more complicated. What do you think? |
So, what's the conclusion here? |
The description & sample for SWC-123 - Requirement Violation doesn't make sense to me.
Generally,
require()
is used for input validation and it the condition being violated is expected behavior.The description seems to refer to a special case where "a contract provides the external input". I assume that the point of this is that if somebody creates a system that contains multiple contracts, the system should be consistent such that no contract calls another contract with invalid inputs?
This should be reflected in the SWC title and could also use a clearer description.
The text was updated successfully, but these errors were encountered: