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

v0.7.0 #157

Merged
merged 71 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
c894abe
Initialized balancer detector
Oct 18, 2023
63f413a
working version
Yhtiyar Oct 19, 2023
3bd7b04
updated severity
Yhtiyar Oct 19, 2023
e33037a
fixed docs
Yhtiyar Oct 19, 2023
e3a0cf9
output_result_typo
Oct 19, 2023
18ac522
Merge branch 'master' into detector_balancer
Yhtiyar Oct 19, 2023
ebf96ae
Merge branch 'detector_balancer' of github.com:pessimistic-io/custom_…
Yhtiyar Oct 19, 2023
13ef10d
bench updates&workflow google sheet upload
nikolay19 Feb 12, 2024
67a88c5
bench 8000 contracts limit
nikolay19 Feb 12, 2024
417e866
Update benchmark.yml
nikolay19 Feb 13, 2024
98921ea
workflow for old version bench
nikolay19 Feb 15, 2024
318605c
Merge pull request #130 from pessimistic-io/submodule_benchmark
nikolay19 Feb 15, 2024
94218f1
Update old_version.yml
nikolay19 Feb 15, 2024
53ef547
bench updates
nikolay19 Feb 15, 2024
dc6210d
Update benchmark.yml
nikolay19 Feb 15, 2024
32b4e0c
Create benchmark_old.yml
nikolay19 Feb 19, 2024
60487a9
Merge pull request #136 from pessimistic-io/nikolay19-patch-1
nikolay19 Feb 19, 2024
ae60974
Merge branch 'develop' of https://github.com/pessimistic-io/slitherin…
nikolay19 Feb 19, 2024
e1cb898
remove action
nikolay19 Feb 19, 2024
115cd26
add napalm integration
JoranHonig Feb 22, 2024
f4f0c5a
removed arbitrum solidity version detector
Yhtiyar Feb 26, 2024
b4ba7f3
bench updates
nikolay19 Feb 26, 2024
a9e7635
Merge branch 'benchmark_updates' of https://github.com/pessimistic-io…
nikolay19 Feb 26, 2024
53038d9
Merge pull request #140 from pessimistic-io/remove-arbsol-verion
Yhtiyar Feb 28, 2024
2fe2cb3
Merge pull request #133 from pessimistic-io/benchmark_updates
nikolay19 Feb 28, 2024
21a5ea6
added detector
Yhtiyar Mar 4, 2024
5b3a52c
tets for arb-chainlink detector
Yhtiyar Mar 4, 2024
f5769a3
docs for arb-chainlink detector
Yhtiyar Mar 4, 2024
e8e79e8
Merge branch 'develop' into chainlink-arbitrum
Yhtiyar Mar 4, 2024
b4eafaa
removing uniswap v3 folder, as it was accidentally added
Yhtiyar Mar 4, 2024
fea92e4
added curve readonly detector
Yhtiyar Mar 5, 2024
5f5555a
added docs for curve detector
Yhtiyar Mar 6, 2024
06d3ed8
Merge pull request #141 from pessimistic-io/chainlink-arbitrum
ndkirillov Mar 7, 2024
b13e34a
Merge pull request #142 from pessimistic-io/curve-readonly-reentrancy
ndkirillov Mar 7, 2024
709548a
PR&slither version to sheet
nikolay19 Mar 7, 2024
597794c
Merge pull request #144 from pessimistic-io/benchmark_updates
nikolay19 Mar 8, 2024
6bd5782
add erc1155 support
olegggatttor Feb 12, 2024
982b7ff
add SafeERC20 support
olegggatttor Feb 12, 2024
ada5f71
Merge branch 'develop' into detector_balancer
Mar 22, 2024
c1b067d
corrected_readme
Mar 22, 2024
a01fdbc
readme_from_master
Mar 22, 2024
fb08e52
replaced_balancer_detector
Mar 22, 2024
d613692
add_init_balancer
Mar 22, 2024
bee7127
package_name update
Mar 22, 2024
52aa8ec
updated_detectors_table
Mar 22, 2024
6bf933f
Merge pull request #146 from pessimistic-io/nft_approve_support_erc1155
ndkirillov Apr 9, 2024
539e746
remove relative imports
JoranHonig Feb 22, 2024
76d0afa
update napalm entry point to restrict inclusions
JoranHonig Feb 22, 2024
f9c8ac5
revert undesired changes to setup
JoranHonig Feb 22, 2024
3581c9a
removed arbitrum solidity version detector
Yhtiyar Feb 26, 2024
1d10755
Merge pull request #150 from pessimistic-io/master
olegggatttor Apr 12, 2024
d9a684c
add recursive check for base constructors | strange setter
olegggatttor Apr 12, 2024
93f49f2
typo
olegggatttor Apr 12, 2024
a2862f3
fix: PotentialArithmOverflow detector fail
shortdoom Apr 12, 2024
3870d21
fix starge setter fail on new contract creations
olegggatttor Apr 12, 2024
49a7ef6
Merge pull request #153 from shortdoom/fix-detector-fail-develop
olegggatttor Apr 15, 2024
fdec81b
add vyper version detector
olegggatttor Apr 16, 2024
7669e67
add file
olegggatttor Apr 16, 2024
9650c18
rm comment
olegggatttor Apr 16, 2024
9028442
add detector
olegggatttor Apr 16, 2024
a96c304
add native support
olegggatttor Apr 16, 2024
1c6881f
update bench submodule in branch
nikolay19 Apr 18, 2024
9a6c889
Merge pull request #152 from pessimistic-io/147-strange-setter-detect…
ndkirillov Apr 18, 2024
c476f26
Merge pull request #155 from pessimistic-io/price_manipulation_detector
ndkirillov Apr 18, 2024
9cf2a55
Merge branch 'develop' into curve-vyper-version-detector
ndkirillov Apr 18, 2024
95c35b5
Merge pull request #154 from pessimistic-io/curve-vyper-version-detector
ndkirillov Apr 18, 2024
d37342a
Merge branch 'develop' into detector_balancer
olegggatttor Apr 18, 2024
da6ca8c
add comma
olegggatttor Apr 18, 2024
91562ba
Merge pull request #91 from pessimistic-io/detector_balancer
olegggatttor Apr 18, 2024
2d386c8
Merge pull request #139 from JoranHonig/master
ndkirillov May 6, 2024
8659ab2
version update
May 7, 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
27 changes: 25 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
- name: Configure
run: |
cd slitherin-benchmark/
ls
mv example.config.py config.py
- name: Install node dependencies
run: npm ci
Expand All @@ -44,12 +45,26 @@ jobs:
- name: Run Benchmark
run: |
cd slitherin-benchmark/
python runner.py -i contracts/mainnet -o mainnet.csv --limit 7000
python runner.py -i contracts/mainnet -o mainnet.csv -eo mainnet_extra.csv --limit 8000 --skip-duplicates --skip-libs
- name: Upload sheet
run: |
cd slitherin-benchmark/
echo $GOOGLE_JWT > service_account.json
python save_sheet.py -i mainnet.csv -sa service_account.json -si $GOOGLE_SHEET_ID -ln mainnet -pr $PR_NUMBER
env:
GOOGLE_JWT : ${{secrets.SERVICE_ACCOUNT}}
GOOGLE_SHEET_ID : ${{ secrets.GOOGLE_SHEET_ID }}
PR_NUMBER: ${{ github.event.number }}
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: mainnet
path: slitherin-benchmark/mainnet.csv
- name: 'Upload Artifact Extra'
uses: actions/upload-artifact@v3
with:
name: mainnet
path: slitherin-benchmark/mainnet_extra.csv
RunBenchmarkOZ:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -89,6 +104,15 @@ jobs:
run: |
cd slitherin-benchmark/
python runner.py -i contracts/openzeppelin -o oz.csv -eo oz_extra.csv
- name: Upload sheet
run: |
cd slitherin-benchmark/
echo $GOOGLE_JWT > service_account.json
python save_sheet.py -i oz.csv -sa service_account.json -si $GOOGLE_SHEET_ID -ln OZ -pr $PR_NUMBER
env:
GOOGLE_JWT : ${{secrets.SERVICE_ACCOUNT}}
GOOGLE_SHEET_ID : ${{ secrets.GOOGLE_SHEET_ID }}
PR_NUMBER: ${{ github.event.number }}
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
Expand All @@ -99,4 +123,3 @@ jobs:
with:
name: oz_extra
path: slitherin-benchmark/oz_extra.csv

118 changes: 118 additions & 0 deletions .github/workflows/old_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Run Benchmark

on:
workflow_dispatch: # Ручной запуск через UI Гитхаба
jobs:
RunBenchmarkOld:
runs-on: ubuntu-latest
env:
slitherin_version: 0.1.0
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install solc-select
run: python -m pip install solc-select
- name: Install Slither
run: python -m pip install slither-analyzer
- name: Install Setuptools
run: python -m pip install setuptools
- name: Install Slitherin
run: python -m pip install slitherin==$slitherin_version
- name: Configure
run: |
cd slitherin-benchmark/
mv example.config.py config.py
- name: Install benchmark requirements
run: |
cd slitherin-benchmark/
python -m pip install -r requirements.txt
- name: Run Benchmark
run: |
cd slitherin-benchmark/
python runner.py -i contracts/mainnet -o mainnet.csv --limit 8000 --skip-duplicates --skip-libs --use-slither
- name: Upload sheet
run: |
cd slitherin-benchmark/
echo $GOOGLE_JWT > service_account.json
python save_sheet.py -i mainnet.csv -sa service_account.json -si $GOOGLE_SHEET_ID -ln mainnet -sv "slitherin $slitherin_version"
env:
GOOGLE_JWT : ${{secrets.SERVICE_ACCOUNT}}
GOOGLE_SHEET_ID : ${{ secrets.GOOGLE_SHEET_ID }}
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: mainnet
path: slitherin-benchmark/mainnet.csv
RunBenchmarkOZOld:
runs-on: ubuntu-latest
env:
slitherin_version: 0.1.0
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install solc-select
run: python -m pip install solc-select
- name: Install Slither
run: python -m pip install slither-analyzer
- name: Install Setuptools
run: python -m pip install setuptools
- name: Install Slitherin
run: python -m pip install slitherin==$slitherin_version
- name: Configure
run: |
cd slitherin-benchmark/
mv example.config.py config.py
- name: Install node dependencies
run: npm ci
- name: Install benchmark requirements
run: |
cd slitherin-benchmark/
python -m pip install -r requirements.txt
- name: Run Benchmark
run: |
cd slitherin-benchmark/
python runner.py -i contracts/openzeppelin -o oz.csv -eo oz_extra.csv --use-slither
- name: Upload sheet
run: |
cd slitherin-benchmark/
echo $GOOGLE_JWT > service_account.json
ls
python save_sheet.py -i oz.csv -sa service_account.json -si $GOOGLE_SHEET_ID -ln OZ -sv "slitherin $slitherin_version"
env:
GOOGLE_JWT : ${{secrets.SERVICE_ACCOUNT}}
GOOGLE_SHEET_ID : ${{ secrets.GOOGLE_SHEET_ID }}
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: oz
path: slitherin-benchmark/oz.csv
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: oz_extra
path: slitherin-benchmark/oz_extra.csv

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Slitherin by Pessimistic.io
# Slitherin by Pessimistic.io

[![Blog](https://img.shields.io/badge/Blog-Link-blue?style=flat-square&logo=appveyor?logo=data:https://pessimistic.io/favicon.ico)](https://blog.pessimistic.io/)
[![Our Website](https://img.shields.io/badge/By-pessimistic.io-green?style=flat-square&logo=appveyor?logo=data:https://pessimistic.io/favicon.ico)](https://pessimistic.io/)
Expand Down Expand Up @@ -99,6 +99,7 @@ Slitherin detectors are included into original Slither after the installation. Y
| [Arbitrary Call](https://github.com/pessimistic-io/slitherin/blob/master/slitherin/detectors/arbitrary_call/arbitrary_call.py) | [Explore](https://github.com/pessimistic-io/slitherin/blob/master/docs/arbitrary_call.md) | [Test](https://github.com/pessimistic-io/slitherin/blob/master/tests/arbitrary_call_test.sol) | 0 |
| [Elliptic Curve Recover](https://github.com/pessimistic-io/slitherin/blob/master/slitherin/detectors/ecrecover.py) | [Explore](https://github.com/pessimistic-io/slitherin/blob/master/docs/ecrecover.md) | [Test](https://github.com/pessimistic-io/slitherin/blob/master/tests/ecrecover.sol) | 0 |
| [Public vs External](https://github.com/pessimistic-io/slitherin/blob/master/slitherin/detectors/public_vs_external.py) | [Explore](https://github.com/pessimistic-io/slitherin/blob/master/docs/public_vs_external.md) | [Test](https://github.com/pessimistic-io/slitherin/blob/master/tests/public_vs_external_test.sol) | 0 |
| [Balancer Read-only Reentrancy](https://github.com/pessimistic-io/slitherin/blob/master/slitherin/detectors/balancer/balancer_readonly_reentrancy.py) | [Explore](https://github.com/pessimistic-io/slitherin/blob/master/docs/balancer/readonly_reentrancy.md) | [Test](https://github.com/pessimistic-io/slitherin/blob/master/tests/balancer/readonly_reentrancy_test.sol) | 0 |

**Please note:**

Expand Down
18 changes: 18 additions & 0 deletions docs/arb_chainlink_price_feed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Arbitrum chainlink sequencer uptime
## Configuration

- Check: `pess-arb-chainlink-price-feed`
- Severity: `Medium`
- Confidence: `Medium`

## Description

Sequencer uptime status should be checked. For details: [chainlink docs](https://docs.chain.link/data-feeds/l2-sequencer-feeds)

## Vulnerable Scenario

[test scenarios](../tests/arbitrum_chainlink_pricefeed_test.sol)

## Recommendation

Verify, sequencer uptmie
24 changes: 24 additions & 0 deletions docs/balancer/readonly_reentrancy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Balancer Readonly Reentrancy

## Configuration

- Check: `pess-balancer-readonly-reentrancy`
- Severity: `High`
- Confidence: `Medium`

## Description

Highlights the use of Balancer getter functions `getRate` and `getPoolTokens` (which are not checked for readonly reentrancy via `VaultReentrancyLib.ensureNotInVaultContext` or `IVault.manageUserBalance`), which return values that theoretically could be manipulated during the execution.

## Vulnerable Scenario

[test scenarios](../../tests/balancer/readonly_reentrancy_test.sol)

## Related Attacks

- [Sentimentxyz Exploit](https://quillaudits.medium.com/decoding-sentiment-protocols-1-million-exploit-quillaudits-f36bee77d376)
- [Sturdy Exploit](https://blog.solidityscan.com/sturdy-finance-hack-analysis-bd8605cd2956)

## Recommendation

- [Official Balancer recomendation](https://docs.balancer.fi/concepts/advanced/valuing-bpt/valuing-bpt.html#on-chain-price-evaluation)
24 changes: 24 additions & 0 deletions docs/curve_readonly_reentrancy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Curve Readonly Reentrancy

## Configuration

- Check: `pess-curve-readonly-reentrancy`
- Severity: `High`
- Confidence: `Medium`

## Description

Highlights the use of Curve getter functions `get_virtual_price` and `lp_price` (which are not checked for readonly reentrancy `withdraw_admin_fee`), which return values that theoretically could be manipulated during the execution. Details: [Curve LP Oracle Manipulation](https://chainsecurity.com/curve-lp-oracle-manipulation-post-mortem/)

## Vulnerable Scenario

[test scenarios](../../tests/curve_readonly_reentrancy_test.sol)

## Related Attacks

- [Jarvis Exploit](https://www.google.com/url?q=https://blog.solidityscan.com/jarvis-polygon-pool-hack-analysis-read-only-re-entrancy-af0607e4585a&sa=D&source=editors&ust=1709713964156907&usg=AOvVaw1Oess2f9Z_UCD6vLM2hN26)
- [Market.xyz Exploit](https://quillaudits.medium.com/decoding-220k-read-only-reentrancy-exploit-quillaudits-30871d728ad5)

## Recomendations

- Verify by calling `withdraw_admin_fee` and checking for fail of call
26 changes: 26 additions & 0 deletions docs/curve_vyper_reentrancy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Curve Readonly Reentrancy

## Configuration

- Check: `pess-curve-vyper-reentrancy`
- Severity: `High`
- Confidence: `High`

## Description

Finds if the code is compiled with vulnerable Vyper compiler version and contains non-reentrant modifiers.
Details:
- [Curve exploit postmortem](https://hackmd.io/@LlamaRisk/BJzSKHNjn)
- [Postmortem from Vyper team](https://hackmd.io/@vyperlang/HJUgNMhs2)

## Vulnerable Scenario

[test scenarios](../../tests/vyper/curve_vyper_reentrancy_test.vy)

## Related Attacks

- [Vyper compiler exploits](https://www.halborn.com/blog/post/explained-the-vyper-bug-hack-july-2023)

## Recomendations

- Upgrade the version of your Vyper compiler.
4 changes: 2 additions & 2 deletions docs/nft_approve_warning.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Confidence: `Low`

## Description
The detector sees if a contract contains `erc721.[safe]TransferFrom(from, ...)` where `from` parameter is not related to `msg.sender`.
The detector sees if a contract contains `erc721.[safe]TransferFrom(from, ...)` or `erc1155.safe[Batch]TransferFrom(from, ...)` where `from` parameter is not related to `msg.sender`.
An attacker can steal any approved NFTs because `transferFrom` function does NOT check that the call is made by its owner.

## Vulnerable Scenario
Expand All @@ -17,4 +17,4 @@ An attacker can steal any approved NFTs because `transferFrom` function does NOT
[Unauthorized transfer_from Vulnerability](https://ventral.digital/posts/2022/8/18/sznsdaos-bountyboard-unauthorized-transferfrom-vulnerability)

## Recommendation
Make sure that in `erc721.[safe]TransferFrom(from, ...)` functions `from` parameter is related to `msg.sender`.
Make sure that in `erc721.[safe]TransferFrom(from, ...)` and `erc1155.safe[Batch]TransferFrom(from, ...)` functions `from` parameter is related to `msg.sender`.
15 changes: 15 additions & 0 deletions docs/price_manipulation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Price Manipulation through token transfers

## Configuration
* Check: `pess-price-manipulation`
* Severity: `High`
* Confidence: `Low`

## Description
The detector finds calculations that depend on the balance and supply of some token. Such calculations could be manipulated through direct transfers to the contract, increasing its balance.

## Vulnerable Scenario
[test scenario](../tests/price_manipulation_test.sol)

## Recommendation
Avoid possible manipulations of calculations because of external transfers.
46 changes: 46 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"dependencies": {
"@openzeppelin/contracts": "^4.9.3"
"@openzeppelin/contracts": "^4.9.3",
"@balancer-labs/v2-interfaces": "^0.4.0",
"@balancer-labs/v2-pool-utils": "^4.0.0"

}
}
Loading
Loading