Skip to content

Commit 13078d4

Browse files
feat: update slither to 0.10.1 (#31)
Resolves: ENG-1055. Related: crytic/slither#2344
1 parent 1d03eb9 commit 13078d4

File tree

7 files changed

+73
-6
lines changed

7 files changed

+73
-6
lines changed

analyzers/slither/.deepsource/analyzer/analyzer.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ category = "lang"
33
name = "Slither"
44
shortcode = "slither"
55
status = "active"
6-
tool_latest_version = "0.10.0"
6+
tool_latest_version = "0.10.1"
77
description = "Slither is a Solidity & Vyper static analysis framework developed by Crytic, a blockchain security group by Trail of Bits."

analyzers/slither/.deepsource/issues/SLITHER-W1023.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ The function will return 6 bytes starting from offset 5, instead of returning a
3131
Use the `leave` statement.
3232
3333
## Learn more
34-
[incorrect-return](https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-assembly-return) on Slither's wiki.
34+
[incorrect-return](https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-return-in-assembly) on Slither's wiki.
3535
"""

analyzers/slither/.deepsource/issues/SLITHER-W1026.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ The function will halt the execution, instead of returning a two uint.
2626
Use the `leave` statement.
2727
2828
## Learn more
29-
[return-leave](https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-assembly-return) on Slither's wiki.
29+
[return-leave](https://github.com/crytic/slither/wiki/Detector-Documentation#return-instead-of-leave-in-assembly) on Slither's wiki.
3030
"""

analyzers/slither/.deepsource/issues/SLITHER-W1056.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Detects the possible usage of a variable before the declaration is stepped over
1313
```solidity
1414
contract C {
1515
function f(uint z) public returns (uint) {
16-
uint y = x + 9 + z; // 'z' is used pre-declaration
16+
uint y = x + 9 + z; // 'x' is used pre-declaration
1717
uint x = 7;
1818
1919
if (z % 2 == 0) {
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
title = "Out-of-order retryable transactions"
2+
verbose_name = "out-of-order-retryable"
3+
severity = "major"
4+
category = "antipattern"
5+
weight = 60
6+
description = """
7+
Out-of-order retryable transactions
8+
9+
<!--more-->
10+
11+
## Exploit Scenario
12+
13+
```solidity
14+
contract L1 {
15+
function doStuffOnL2() external {
16+
// Retryable A
17+
IInbox(inbox).createRetryableTicket({
18+
to: l2contract,
19+
l2CallValue: 0,
20+
maxSubmissionCost: maxSubmissionCost,
21+
excessFeeRefundAddress: msg.sender,
22+
callValueRefundAddress: msg.sender,
23+
gasLimit: gasLimit,
24+
maxFeePerGas: maxFeePerGas,
25+
data: abi.encodeCall(l2contract.claim_rewards, ())
26+
});
27+
// Retryable B
28+
IInbox(inbox).createRetryableTicket({
29+
to: l2contract,
30+
l2CallValue: 0,
31+
maxSubmissionCost: maxSubmissionCost,
32+
excessFeeRefundAddress: msg.sender,
33+
callValueRefundAddress: msg.sender,
34+
gasLimit: gas,
35+
maxFeePerGas: maxFeePerGas,
36+
data: abi.encodeCall(l2contract.unstake, ())
37+
});
38+
}
39+
}
40+
41+
contract L2 {
42+
function claim_rewards() public {
43+
// rewards is computed based on balance and staking period
44+
uint unclaimed_rewards = _compute_and_update_rewards();
45+
token.safeTransfer(msg.sender, unclaimed_rewards);
46+
}
47+
48+
// Call claim_rewards before unstaking, otherwise you lose your rewards
49+
function unstake() public {
50+
_free_rewards(); // clean up rewards related variables
51+
balance = balance[msg.sender];
52+
balance[msg.sender] = 0;
53+
staked_token.safeTransfer(msg.sender, balance);
54+
}
55+
}
56+
```
57+
Bob calls `doStuffOnL2` but the first retryable ticket calling `claim_rewards` fails. The second retryable ticket calling `unstake` is executed successfully. As a result, Bob loses his rewards.
58+
59+
## Recommendation
60+
Do not rely on the order or successful execution of retryable tickets.
61+
62+
## Learn more
63+
[out-of-order-retryable](https://github.com/crytic/slither/wiki/Detector-Documentation#out-of-order-retryable-transactions) on Slither's wiki.
64+
"""

analyzers/slither/utils/issue_map.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,5 +274,8 @@
274274
},
275275
"4-0-var-read-using-this": {
276276
"issue_code": "SLITHER-W1092"
277+
},
278+
"1-1-out-of-order-retryable": {
279+
"issue_code": "SLITHER-W1093"
277280
}
278281
}

analyzers/slither/utils/issue_map_gen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import itertools
22
import json
3-
from typing import Dict, Generator
3+
from typing import Dict, Iterator
44

55
from constants import ISSUE_MAP_FILE, ISSUE_PREFIX
66
from detectors import get_all_detector_json
77

88
__all__ = ["get_issue_map", "generate_mapping"]
99

1010

11-
def _get_next_code(mapping: Dict[str, Dict[str, str]]) -> Generator[int]:
11+
def _get_next_code(mapping: Dict[str, Dict[str, str]]) -> Iterator[int]:
1212
"""Return the next available issue code."""
1313
num_issues = len(mapping.keys()) # get the number of issues already in the mapping
1414
next_code = 1001 + num_issues # issue code series starts from `1001`

0 commit comments

Comments
 (0)