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

Spot price detector #2447

Closed
wants to merge 59 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
38cc41a
Update installation instrucitons
0xalpharush Oct 18, 2023
f0f1200
Update Dockerfile
0xalpharush Oct 18, 2023
a9e52aa
Bump actions/setup-node from 3 to 4
dependabot[bot] Oct 23, 2023
c316a81
Error when a missing contract is specified to read-storage. Previousl…
UsmannK Nov 16, 2023
4bfb61e
Bump cachix/install-nix-action from 23 to 24
dependabot[bot] Dec 4, 2023
72a8e4b
Bump actions/configure-pages from 3 to 4
dependabot[bot] Dec 4, 2023
a2c5206
Bump actions/deploy-pages from 2 to 3
dependabot[bot] Dec 4, 2023
6d5def6
Bump pypa/gh-action-pypi-publish from 1.8.10 to 1.8.11
dependabot[bot] Dec 4, 2023
12ac369
remove unused files
0xalpharush Oct 20, 2023
435871f
fix is_reentrant for internal vyper functions
0xalpharush Nov 1, 2023
c225727
Substituted the letter 'z' with 'x' in pre-declaration
ATREAY Dec 7, 2023
a3dd9b1
updated mutator
vishnuram1999 Jan 2, 2024
7984ad3
Updated replace string logic
vishnuram1999 Jan 3, 2024
4eba366
Added new mutant generators
vishnuram1999 Jan 6, 2024
40305bb
Added new mutators
vishnuram1999 Jan 9, 2024
107c42b
Updated mutators
vishnuram1999 Jan 15, 2024
f001bad
Updated run_test_cmd
vishnuram1999 Jan 16, 2024
dfed543
updated create patch
vishnuram1999 Jan 17, 2024
25ed527
Added contract_names arg
vishnuram1999 Jan 18, 2024
6ae8579
updated quick
vishnuram1999 Jan 20, 2024
9ce98f4
Added README
vishnuram1999 Jan 21, 2024
3db8da2
Updated arguments
vishnuram1999 Jan 24, 2024
a51fd70
Updated mutators
vishnuram1999 Jan 24, 2024
6f584ec
Updated files
vishnuram1999 Jan 25, 2024
89e90b7
Updated with formatting
vishnuram1999 Jan 26, 2024
5c88d6e
Formatted mutators
vishnuram1999 Jan 26, 2024
31ef3f1
Formatted test_patch
vishnuram1999 Jan 26, 2024
114e864
Bump cachix/cachix-action from 12 to 14 (#2275)
dependabot[bot] Jan 29, 2024
e944173
Bump actions/upload-artifact from 3 to 4 (#2265)
dependabot[bot] Jan 29, 2024
8e4e634
Bump actions/setup-python from 4 to 5 (#2259)
dependabot[bot] Jan 29, 2024
d0761a3
Detect also in modifiers (#2280)
smonicas Jan 29, 2024
04426e0
Fix/iterative update (#2206)
0xalpharush Jan 29, 2024
cda9a9d
fix: detect selfdestruct in internal calls (#2232)
0xalpharush Jan 29, 2024
5a8b636
Bump actions/deploy-pages from 3 to 4 (#2285)
dependabot[bot] Jan 30, 2024
9c2110e
Bump cachix/install-nix-action from 24 to 25 (#2286)
dependabot[bot] Jan 30, 2024
2e089b6
Bump sigstore/gh-action-sigstore-python from 2.1.0 to 2.1.1 (#2293)
dependabot[bot] Feb 6, 2024
565fa7c
Bump actions/upload-pages-artifact from 2 to 3 (#2294)
dependabot[bot] Feb 6, 2024
0ded68d
Fix using for when used with "this" (#2224)
smonicas Feb 6, 2024
6449529
fix: broken doc links (#2299)
mds1 Feb 8, 2024
2450fbc
feat: First version of Uniswap spot price detection
talfao Mar 12, 2024
20843df
feat: Test data with getReserves
talfao Mar 12, 2024
ee7055b
feat: balanceOF spot price detection
talfao Mar 12, 2024
fac7b33
feat: Add comments
talfao Mar 29, 2024
947e447
feat: making analysis faster
talfao Apr 8, 2024
2e5e4bc
fix: remove files which should be in different branch
talfao Apr 15, 2024
f640165
fix: balanceOf check
talfao Apr 15, 2024
1fa07aa
fix: balanceOf issue
talfao Apr 15, 2024
51a58bf
fix: pylint issues
talfao Apr 15, 2024
89a6d75
feat: improvement for detecting correct balanceOF scenario
talfao Apr 16, 2024
a21fc91
feat: getAmountOut add as problem + tainting vars
talfao Apr 16, 2024
784d0e4
feat: break loop earlier in tracking
talfao Apr 16, 2024
ead9998
feat: remove cumulativePrice and case when slot0 does not return price
talfao Apr 17, 2024
921f6cb
fix: slot0 must return price
talfao Apr 17, 2024
9e0d446
feat: get calculate functions
talfao Apr 21, 2024
f042e6c
fix: pure and view evaluating
talfao Apr 21, 2024
70c187e
fix: reformating
talfao Apr 21, 2024
0d1e276
Swap detection
talfao Apr 23, 2024
070b785
feat: add more comments before merge
talfao Apr 26, 2024
a8a7722
fix: rebase branch
talfao Apr 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
fetch-depth: 0

- name: Set up Python 3.8
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
Expand All @@ -67,11 +67,11 @@ jobs:

- name: Set up nix
if: matrix.type == 'dapp'
uses: cachix/install-nix-action@v23
uses: cachix/install-nix-action@v25

- name: Set up cachix
if: matrix.type == 'dapp'
uses: cachix/cachix-action@v12
uses: cachix/cachix-action@v14
with:
name: dapp

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v3
- uses: actions/setup-python@v4
uses: actions/configure-pages@v4
- uses: actions/setup-python@v5
with:
python-version: '3.8'
- run: pip install -e ".[doc]"
- run: pdoc -o html/ slither '!slither.tools' #TODO fix import errors on pdoc run
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
# Upload the doc
path: './html/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion .github/workflows/doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
fetch-depth: 0

- name: Set up Python 3.8
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pip-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'

Expand All @@ -23,7 +23,7 @@ jobs:
python -m pip install build
python -m build
- name: Upload distributions
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: slither-dists
path: dist/
Expand All @@ -44,10 +44,10 @@ jobs:
path: dist/

- name: publish
uses: pypa/[email protected].10
uses: pypa/[email protected].11

- name: sign
uses: sigstore/[email protected].0
uses: sigstore/[email protected].1
with:
inputs: ./dist/*.tar.gz ./dist/*.whl
release-signing-artifacts: true
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
fetch-depth: 0

- name: Set up Python 3.8
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: "pip"
Expand All @@ -40,7 +40,7 @@ jobs:
pip install ".[test]"

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16'
cache: 'npm'
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ ENV PATH="/home/slither/.local/bin:${PATH}"
RUN --mount=type=bind,target=/mnt,source=/wheels,from=python-wheels \
pip3 install --user --no-cache-dir --upgrade --no-index --find-links /mnt --no-deps /mnt/*.whl

RUN solc-select install 0.4.25 && solc-select use 0.4.25
RUN solc-select use latest --always-install

CMD /bin/bash
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Slither - Read the Docs](https://img.shields.io/badge/Slither-Read_the_Docs-2ea44f)](https://crytic.github.io/slither/slither.html)
[![Slither - Wiki](https://img.shields.io/badge/Slither-Wiki-2ea44f)](https://github.com/crytic/slither/wiki/SlithIR)

> Join the Empire Hacking Slack
> Join the Empire Hacking Slack
>
> [![Slack Status](https://slack.empirehacking.nyc/badge.svg)](https://slack.empirehacking.nyc/)
> > <sub><i>- Discussions and Support </i></sub>
Expand Down Expand Up @@ -73,14 +73,14 @@ If you're **not** going to use one of the [supported compilation frameworks](htt
### Using Pip

```console
pip3 install slither-analyzer
python3 -m pip install slither-analyzer
```

### Using Git

```bash
git clone https://github.com/crytic/slither.git && cd slither
python3 setup.py install
python3 -m pip install .
```

We recommend using a Python virtual environment, as detailed in the [Developer Installation Instructions](https://github.com/trailofbits/slither/wiki/Developer-installation), if you prefer to install Slither via git.
Expand Down Expand Up @@ -131,10 +131,10 @@ Num | Detector | What it Detects | Impact | Confidence
20 | `controlled-delegatecall` | [Controlled delegatecall destination](https://github.com/crytic/slither/wiki/Detector-Documentation#controlled-delegatecall) | High | Medium
21 | `delegatecall-loop` | [Payable functions using `delegatecall` inside a loop](https://github.com/crytic/slither/wiki/Detector-Documentation/#payable-functions-using-delegatecall-inside-a-loop) | High | Medium
22 | `incorrect-exp` | [Incorrect exponentiation](https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-exponentiation) | High | Medium
23 | `incorrect-return` | [If a `return` is incorrectly used in assembly mode.](https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-assembly-return) | High | Medium
23 | `incorrect-return` | [If a `return` is incorrectly used in assembly mode.](https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-return-in-assembly) | High | Medium
24 | `msg-value-loop` | [msg.value inside a loop](https://github.com/crytic/slither/wiki/Detector-Documentation/#msgvalue-inside-a-loop) | High | Medium
25 | `reentrancy-eth` | [Reentrancy vulnerabilities (theft of ethers)](https://github.com/crytic/slither/wiki/Detector-Documentation#reentrancy-vulnerabilities) | High | Medium
26 | `return-leave` | [If a `return` is used instead of a `leave`.](https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-assembly-return) | High | Medium
26 | `return-leave` | [If a `return` is used instead of a `leave`.](https://github.com/crytic/slither/wiki/Detector-Documentation#return-instead-of-leave-in-assembly) | High | Medium
27 | `storage-array` | [Signed storage integer array compiler bug](https://github.com/crytic/slither/wiki/Detector-Documentation#storage-signed-integer-array) | High | Medium
28 | `unchecked-transfer` | [Unchecked tokens transfer](https://github.com/crytic/slither/wiki/Detector-Documentation#unchecked-transfer) | High | Medium
29 | `weak-prng` | [Weak PRNG](https://github.com/crytic/slither/wiki/Detector-Documentation#weak-PRNG) | High | Medium
Expand Down
Empty file.
Empty file.
13 changes: 9 additions & 4 deletions slither/core/declarations/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1500,10 +1500,13 @@ def is_reentrant(self) -> bool:
"""
Determine if the function can be re-entered
"""
reentrancy_modifier = "nonReentrant"

if self.function_language == FunctionLanguage.Vyper:
reentrancy_modifier = "nonreentrant(lock)"

# TODO: compare with hash of known nonReentrant modifier instead of the name
if "nonReentrant" in [m.name for m in self.modifiers] or "nonreentrant(lock)" in [
m.name for m in self.modifiers
]:
if reentrancy_modifier in [m.name for m in self.modifiers]:
return False

if self.visibility in ["public", "external"]:
Expand All @@ -1515,7 +1518,9 @@ def is_reentrant(self) -> bool:
]
if not all_entry_points:
return True
return not all(("nonReentrant" in [m.name for m in f.modifiers] for f in all_entry_points))
return not all(
(reentrancy_modifier in [m.name for m in f.modifiers] for f in all_entry_points)
)

# endregion
###################################################################################
Expand Down
1 change: 1 addition & 0 deletions slither/detectors/all_detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,4 @@
from .operations.incorrect_exp import IncorrectOperatorExponentiation
from .statements.tautological_compare import TautologicalCompare
from .statements.return_bomb import ReturnBomb
from .oracles.spot_price import SpotPriceDetector
4 changes: 3 additions & 1 deletion slither/detectors/assembly/incorrect_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class IncorrectReturn(AbstractDetector):
IMPACT = DetectorClassification.HIGH
CONFIDENCE = DetectorClassification.MEDIUM

WIKI = "https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-assembly-return"
WIKI = (
"https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-return-in-assembly"
)

WIKI_TITLE = "Incorrect return in assembly"
WIKI_DESCRIPTION = "Detect if `return` in an assembly block halts unexpectedly the execution."
Expand Down
2 changes: 1 addition & 1 deletion slither/detectors/assembly/return_instead_of_leave.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ReturnInsteadOfLeave(AbstractDetector):
IMPACT = DetectorClassification.HIGH
CONFIDENCE = DetectorClassification.MEDIUM

WIKI = "https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-assembly-return"
WIKI = "https://github.com/crytic/slither/wiki/Detector-Documentation#return-instead-of-leave-in-assembly"

WIKI_TITLE = "Return instead of leave in assembly"
WIKI_DESCRIPTION = "Detect if a `return` is used where a `leave` should be used."
Expand Down
2 changes: 1 addition & 1 deletion slither/detectors/functions/suicidal.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def detect_suicidal_func(func: FunctionContract) -> bool:
if func.visibility not in ["public", "external"]:
return False

calls = [c.name for c in func.internal_calls]
calls = [c.name for c in func.all_internal_calls()]
if not ("suicide(address)" in calls or "selfdestruct(address)" in calls):
return False

Expand Down
Loading