Skip to content
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

use taint mode #61

Merged
merged 8 commits into from
May 30, 2024
Merged

use taint mode #61

merged 8 commits into from
May 30, 2024

Conversation

Raz0r
Copy link
Collaborator

@Raz0r Raz0r commented May 17, 2024

No description provided.

@Raz0r Raz0r changed the title arbitrary-low-level-call: use taint mode use taint mode May 22, 2024
@@ -19,12 +19,23 @@ rules:
mode: taint
pattern-sinks:
- pattern: $Y - $X
- pattern: $Y -= $X
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we restrict this only to Solidity < 0.8 by matching pragma?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out not yet, pragma matching in semgrep needs enhancements

- focus-metavariable: $X
- patterns:
- pattern-inside: |
function $F(..., $TYPE $X, ...) { ... }
Copy link
Collaborator Author

@Raz0r Raz0r May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will match internal functions, should be removed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it matches the internal functions.
When I deleted it, semgrep stopped matching functions without visibility. This may be critical for contracts with pragma solidity prior to version 0.5.0, since visibility is public by default. This should be known when testing old contracts.

@@ -36,7 +36,7 @@ contract Test{

function sink(address _contract, uint256 _num) internal {
// intraprocedural tainting does not work for now...
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this comment too, because it works now

- pattern-either:
- pattern: $X == ...
- pattern: ... == $X
- pattern: $X >= ... && $X <= ...
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave only strict equality ==, other comparisons are not exact balance checks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -26 to -31
- pattern-not-inside: |
function $F(...) {
...
$VAR.withdraw_admin_fees(...);
...
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed duplicate, check pls

@Raz0r Raz0r merged commit 5484568 into master May 30, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants