-
Notifications
You must be signed in to change notification settings - Fork 63
Description
I encountered a TypeError
while running slither
with slitherin
detectors on my Solidity project. The crash seems to originate from the slitherin
detector nft_approve_warning
(pess-nft-approve-warning), specifically when processing library calls.
Notably, I was attempting to exclude this specific detector using the --exclude pess-nft-approve-warning
flag in my Slither command. Despite this, the tool still crashed within this detector's logic.
Command Context:
The Slither command was structured similarly to:
slither --fail-none <path_to_contracts> --disable-color --json <output_json_path> --json-types console,detectors,list-detectors --exclude ...,pess-nft-approve-warning,...
Error and Traceback:
The analysis failed with the following traceback pointing to slitherin
:
Traceback (most recent call last):
File "/usr/local/bin/slitherin", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.10/dist-packages/slitherin/cli.py", line 189, in main
handle_parser(parsed, unknown)
File "/usr/local/lib/python3.10/dist-packages/slitherin/cli.py", line 115, in handle_parser
run(
File "/usr/local/lib/python3.10/dist-packages/slitherin/cli.py", line 82, in run
for r in [output.data for output in self._detect()]:
File "/usr/local/lib/python3.10/dist-packages/slitherin/detectors/nft_approve_warning.py", line 67, in _detect
for d in self._detect_arbitrary_from(f):
File "/usr/local/lib/python3.10/dist-packages/slitherin/detectors/nft_approve_warning.py", line 35, in _detect_arbitrary_from
all_library_calls = [f_called[1].solidity_signature for f_called in f.library_calls]
File "/usr/local/lib/python3.10/dist-packages/slitherin/detectors/nft_approve_warning.py", line 35, in <listcomp>
all_library_calls = [f_called[1].solidity_signature for f_called in f.library_calls]
TypeError: 'LibraryCall' object is not subscriptable
The process then indicated: Exception: Errored out with code: 1, while running slither
Expected Behavior:
- The excluded detector (
pess-nft-approve-warning
) should not run or cause a crash. - If the detector must be loaded for some reason despite exclusion, it should not raise a
TypeError
. - The analysis should complete without the tool itself crashing.
Actual Behavior:
slitherin
crashed due to a TypeError
in the nft_approve_warning.py
detector when trying to access f_called[1]
, where f_called
is a LibraryCall
object. This occurred even though the detector was specified in the --exclude
list.
More data:
Executed with --separated
INFO:slitherinLogger:'slither --fail-none /xxx/evm --disable-color --json /slithering-result-2.json --json-types console,detectors,list-detectors --exclude pess-arb-prevrandao-difficulty,pess-arb-block-number-timestamp,pess-arb-chainlink-price-feed,pess-double-entry-token-alert,pess-unprotected-setter,pess-nft-approve-warning,pess-inconsistent-nonreentrant,pess-strange-setter,pess-only-eoa-check,pess-magic-number,pess-dubious-typecast,pess-multiple-storage-read,pess-timelock-controller,pess-tx-gasprice,pess-unprotected-initialize,pess-event-setter,pess-before-token-transfer,pess-uni-v2,pess-token-fallback,pess-for-continue-increment,pess-arbitrary-call,pess-ecrecover,pess-public-vs-external,pess-aave-flashloan-callback,pess-potential-arithmetic-overflow,pess-curve-readonly-reentrancy,pess-balancer-readonly-reentrancy,pess-vyper-version-reentrancy,pess-price-manipulation' running (wd: /)
Last output
Only slitherin results:
00:10.841 error --ignore-compile used, if something goes wrong, consider removing the ignore compile flag
00:10.841 error Magic number 32 is used multiple times in:
00:10.841 error _addressBytes.length > 32 (node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/libs/AddressCast.sol#10)
00:10.841 error offset = 32 - _addressBytes.length (node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/libs/AddressCast.sol#13)
00:10.841 error mstore(uint256,uint256)(result + 32,_addressBytes32 << offset) (node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/libs/AddressCast.sol#28)
00:10.841 error Reference: https://github.com/pessimistic-io/slitherin/blob/master/docs/magic_number.md
00:10.841 error Traceback (most recent call last):
00:10.841 error File "/usr/local/bin/slither", line 8, in <module>
00:10.841 error sys.exit(main())
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slither/__main__.py", line 776, in main
00:10.841 error main_impl(all_detector_classes=detectors, all_printer_classes=printers)
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slither/__main__.py", line 882, in main_impl
00:10.841 error ) = process_all(filename, args, detector_classes, printer_classes)
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slither/__main__.py", line 107, in process_all
00:10.841 error ) = process_single(compilation, args, detector_classes, printer_classes)
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slither/__main__.py", line 87, in process_single
00:10.841 error return _process(slither, detector_classes, printer_classes)
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slither/__main__.py", line 137, in _process
00:10.841 error detector_resultss = slither.run_detectors()
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slither/slither.py", line 292, in run_detectors
00:10.841 error results = [d.detect() for d in self._detectors]
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slither/slither.py", line 292, in <listcomp>
00:10.841 error results = [d.detect() for d in self._detectors]
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slither/detectors/abstract_detector.py", line 203, in detect
00:10.841 error Traceback (most recent call last):
00:10.841 error File "/usr/local/bin/slitherin", line 8, in <module>
00:10.841 error sys.exit(main())
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slitherin/cli.py", line 189, in main
00:10.841 error handle_parser(parsed, unknown)
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slitherin/cli.py", line 115, in handle_parser
00:10.841 error run(
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slitherin/cli.py", line 82, in run
00:10.841 error for r in [output.data for output in self._detect()]:
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slitherin/detectors/nft_approve_warning.py", line 67, in _detect
00:10.841 error for d in self._detect_arbitrary_from(f):
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slitherin/detectors/nft_approve_warning.py", line 35, in _detect_arbitrary_from
00:10.841 error all_library_calls = [f_called[1].solidity_signature for f_called in f.library_calls]
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slitherin/detectors/nft_approve_warning.py", line 35, in <listcomp>
00:10.841 error all_library_calls = [f_called[1].solidity_signature for f_called in f.library_calls]
00:10.841 error TypeError: 'LibraryCall' object is not subscriptable
00:10.841 error Failed to run slither: Errored out with code: 1, while running slither
00:10.841 error raise e
00:10.841 error File "/usr/local/lib/python3.10/dist-packages/slitherin/cli.py", line 76, in run
00:10.841 error raise Exception(
00:10.841 error Exception: Errored out with code: 1, while running slither