You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: not-so-smart-contracts/solidity/bad_randomness/README.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Pseudorandom number generation on the blockchain is generally unsafe. There are
10
10
11
11
A common workaround for the lack of on-chain randomness is using a commit and reveal scheme. Here, each user submits the hash of their secret number.
12
12
When the time comes for the random number to be generated, each user sends their secret number to the contract
13
-
which then verifies it matches the hash submitted earlier and xors them together. Therefore no participant can observe how their contribution
13
+
which then verifies it matches the hash submitted earlier and XORs them together. Therefore no participant can observe how their contribution
14
14
will affect the end result until after everyone has already committed to a value. However, this is also vulnerable to DoS attacks,
15
15
since the last person to reveal can choose to never submit their secret. Even if the contract is allowed to move forward without
16
16
everyone's secrets, this gives them influence over the end result. In general, we do not recommend commit and reveal schemes.
@@ -20,7 +20,7 @@ everyone's secrets, this gives them influence over the end result. In general, w
20
20
- A lottery where people bet on whether the hash of the current block is even or odd. A miner that bets on even can throw out blocks whose
21
21
hash are even.
22
22
- A commit-reveal scheme where users don't necessarily have to reveal their secret (to prevent DoS). A user has money riding on the outcome
23
-
of the PRG and submits a large number of commits, allowing them to choose the one they want to reveal at the end.
23
+
of the PRNG and submits a large number of commits, allowing them to choose the one they want to reveal at the end.
24
24
25
25
## Mitigations
26
26
@@ -30,13 +30,13 @@ In the future, however, these approaches show promise
30
30
31
31
-[Verifiable delay functions](https://eprint.iacr.org/2018/601.pdf): functions which produce a pseudorandom number
32
32
and take a fixed amount of sequential time to evaluate
33
-
-[Randao](https://github.com/randao/randao): A commit reveal scheme where users must stake wei to participate
33
+
-[RANDAO](https://github.com/randao/randao): A commit reveal scheme where users must stake wei to participate
34
34
35
35
## Examples
36
36
37
37
- The `random` function in [theRun](theRun_source_code/theRun.sol) was vulnerable to this attack. It used the blockhash, timestamp and block number to generate numbers in a range to determine winners of the lottery. To exploit this, an attacker could set up a smart contract that generates numbers in the same way and submits entries when it would win. As well, the miner of the block has some control over the blockhash and timestamp and would also be able to influence the lottery in their favor.
Copy file name to clipboardExpand all lines: not-so-smart-contracts/solidity/denial_of_service/README.md
+2-4
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,6 @@
1
1
# Denial of Service
2
2
3
-
A malicious contract can permanently stall another contract by failing
4
-
in a strategic way. In particular, contracts that bulk perform transactions or updates using
5
-
a `for` loop can be DoS'd if a call to another contract or `transfer` fails during the loop.
3
+
A malicious contract can permanently stall another contract by failing in a strategic way. In particular, contracts that bulk perform transactions or updates using a `for` loop can be DoS'd if a call to another contract or `transfer` fails during the loop.
6
4
7
5
## Attack Scenarios
8
6
@@ -19,7 +17,7 @@ might run out of gas and revert.
19
17
20
18
- Both [insecure](auction.sol#L4) and [secure](auction.sol#L26) versions of the auction contract mentioned above
21
19
22
-
- Bulk refund functionality that is [suceptible to DoS](list_dos.sol#L3), and a [secure](list_dos.sol#L29) version
20
+
- Bulk refund functionality that is [susceptible to DoS](list_dos.sol#L3), and a [secure](list_dos.sol#L29) version
Copy file name to clipboardExpand all lines: not-so-smart-contracts/solidity/forced_ether_reception/README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Contracts can be forced to receive ether
2
2
3
-
In certain circunstances, contracts can be forced to receive ether without triggering any code. This should be considered by the contract developers in order to avoid breaking important invariants in their code.
3
+
In certain circumstances, contracts can be forced to receive ether without triggering any code. This should be considered by the contract developers in order to avoid breaking important invariants in their code.
Copy file name to clipboardExpand all lines: not-so-smart-contracts/solidity/honeypots/README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ The contract takes advantage of the fact that the global variable balance on the
23
23
24
24
The contract appears vulnerable to a constructor mismatch, allowing anyone to call the public method `Test1()` and double any ether they send to the function. The calculation involves a while loop which is strange, but the bounds conditions seem correct enough.
25
25
26
-
One of the features of Solidity is that it seeks to mimic JavaScript in its language syntax and style. This is ostensibly to ease onboarding of developers with something familiar. In this case, the contract takes advantage of different semantics between Solidity and JavaScript to create type confusion. The var keyword allows the compiler to infer the type of the assignment when declaring a variable. In this instance, `i1` and `i2` are resolved to fact be `uint8`. As such, their maximum value will be 255 before overflow -- causing the loop condition `if(i1<i2)` to fail, sending at most 255 wei to the caller before terminating.
26
+
One of the features of Solidity is that it seeks to mimic JavaScript in its language syntax and style. This is ostensibly to ease on-boarding of developers with something familiar. In this case, the contract takes advantage of different semantics between Solidity and JavaScript to create type confusion. The var keyword allows the compiler to infer the type of the assignment when declaring a variable. In this instance, `i1` and `i2` are resolved to fact be `uint8`. As such, their maximum value will be 255 before overflow -- causing the loop condition `if(i1<i2)` to fail, sending at most 255 wei to the caller before terminating.
27
27
28
28
Fortunately the var keyword has been deprecated by the Solidity authors.
Copy file name to clipboardExpand all lines: not-so-smart-contracts/solidity/incorrect_erc20_interface/README.md
+2-4
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
## Incorrect erc20 interface
1
+
## Incorrect ERC20 interface
2
2
3
3
### Description
4
4
Incorrect return values for ERC20 functions. A contract compiled with solidity > 0.4.22 interacting with these functions will fail to execute them, as the return value is missing.
@@ -16,6 +16,4 @@ contract Token{
16
16
### Recommendation
17
17
- Set the appropriate return values and value-types for the defined ERC20 functions.
18
18
- Use [Slither](https://github.com/crytic/slither/) or [crytic.io](https://crytic.io/) to detect the issue
19
-
- Use `slither-check-erc` to ensure ERC's conformance
20
-
21
-
19
+
- Use `slither-check-erc` to ensure ERC conformance
Copy file name to clipboardExpand all lines: not-so-smart-contracts/solidity/incorrect_erc721_interface/README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
## Incorrect erc721 interface
1
+
## Incorrect ERC721 interface
2
2
3
3
### Description
4
4
Incorrect return values for ERC721 functions. A contract compiled with solidity > 0.4.22 interacting with these functions will fail to execute them, as the return value is missing.
Copy file name to clipboardExpand all lines: not-so-smart-contracts/solidity/incorrect_interface/README.md
+3-4
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
# Incorrect interface
2
2
A contract interface defines functions with a different type signature than the implementation, causing two different method id's to be created.
3
-
As a result, when the interfact is called, the fallback method will be executed.
3
+
As a result, when the interface is called, the fallback method will be executed.
4
4
5
5
## Attack Scenario
6
6
7
-
- The interface is incorrectly defined. `Alice.set(uint)` takes an `uint` in `Bob.sol` but `Alice.set(int)` a `int` in `Alice.sol`. The two interfaces will produce two differents method IDs. As a result, Bob will call the fallback function of Alice rather than of `set`.
7
+
- The interface is incorrectly defined. `Alice.set(uint)` takes an `uint` in `Bob.sol` but `Alice.set(int)` a `int` in `Alice.sol`. The two interfaces will produce two different method IDs. As a result, Bob will call the fallback function of Alice rather than of `set`.
8
8
9
9
## Mitigations
10
10
11
-
Verify that type signatures are identical between inferfaces and implementations.
11
+
Verify that type signatures are identical between interfaces and implementations.
0 commit comments