Skip to content

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
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.

}

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
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.

3 participants