nautical / lpu_presentation

0 stars 0 forks source link

Error while analysis #6

Closed mandalabhash closed 1 month ago

mandalabhash commented 1 month ago

got the following error:

""" (albert㉿aimmore)-[~/Desktop/lpu_presentation/Supplement/Slither Myth] └─$ slither ./3.sol
'solc --version' running Traceback (most recent call last): File "/home/albert/.local/bin/slither", line 8, in sys.exit(main()) ^^^^^^ File "/home/albert/.local/lib/python3.11/site-packages/slither/main.py", line 776, in main main_impl(all_detector_classes=detectors, all_printer_classes=printers) File "/home/albert/.local/lib/python3.11/site-packages/slither/main.py", line 882, in main_impl ) = process_all(filename, args, detector_classes, printer_classes) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/albert/.local/lib/python3.11/site-packages/slither/main.py", line 96, in process_all compilations = compile_all(target, vars(args)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/albert/.local/lib/python3.11/site-packages/crytic_compile/crytic_compile.py", line 722, in compile_all compilations.append(CryticCompile(target, kwargs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/albert/.local/lib/python3.11/site-packages/crytic_compile/crytic_compile.py", line 211, in init self._compile(kwargs) File "/home/albert/.local/lib/python3.11/site-packages/crytic_compile/crytic_compile.py", line 633, in _compile self._platform.compile(self, kwargs) File "/home/albert/.local/lib/python3.11/site-packages/crytic_compile/platform/solc.py", line 151, in compile targets_json = _get_targets_json(compilation_unit, self._target, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/albert/.local/lib/python3.11/site-packages/crytic_compile/platform/solc.py", line 280, in _get_targets_json return _run_solc( ^^^^^^^^^^ File "/home/albert/.local/lib/python3.11/site-packages/crytic_compile/platform/solc.py", line 497, in _run_solc compiler="solc", version=get_version(solc, env), optimized=is_optimized(solc_arguments) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/albert/.local/lib/python3.11/site-packages/crytic_compile/platform/solc.py", line 395, in get_version raise InvalidCompilation( crytic_compile.platform.exceptions.InvalidCompilation: Solidity version not found: STDOUT:

STDERR: Traceback (most recent call last): File "/home/albert/.local/bin/solc", line 8, in sys.exit(solc()) ^^^^^^ File "/home/albert/.local/lib/python3.11/site-packages/solc_select/main.py", line 87, in solc res = current_version() ^^^^^^^^^^^^^^^^^ File "/home/albert/.local/lib/python3.11/site-packages/solc_select/solc_select.py", line 67, in current_version raise argparse.ArgumentTypeError( argparse.ArgumentTypeError: No solc version set. Run solc-select use VERSION or set SOLC_VERSION environment variable.

┌──(albert㉿aimmore)-[~/Desktop/lpu_presentation/Supplement/Slither Myth] └─$ """

mandalabhash commented 1 month ago

Later with some chatgpt help 😆

┌──(albert㉿aimmore)-[~/Desktop/lpu_presentation/Supplement/Slither Myth] └─$ solc-select install 0.4.16
Installing solc '0.4.16'... Version '0.4.16' installed.

┌──(albert㉿aimmore)-[~/Desktop/lpu_presentation/Supplement/Slither Myth] └─$ solc-select use 0.4.16
Switched global version to 0.4.16

┌──(albert㉿aimmore)-[~/Desktop/lpu_presentation/Supplement/Slither Myth] └─$ slither ./3.sol --json audit3sol.json 'solc --version' running 'solc ./3.sol --combined-json abi,ast,bin,bin-runtime,srcmap,srcmap-runtime,userdoc,devdoc,hashes,compact-format --allow-paths .,/home/albert/Desktop/lpu_presentation/Supplement/Slither Myth' running

EthTxOrderDependenceMinimal.setReward() (3.sol#12-18) should emit an event for:

Version constraint ^0.4.16 contains known severe issues (https://solidity.readthedocs.io/en/latest/bugs.html)

Reentrancy in EthTxOrderDependenceMinimal.claimReward(uint256) (3.sol#20-25): External calls:

nautical commented 1 month ago

Good work ! As mentioned in error : argparse.ArgumentTypeError: No solc version set. Run solc-select use VERSION or set SOLC_VERSION environment variable.

Issue was installing and selecting correct solidity version

Here is the repo for solc-select : https://github.com/crytic/solc-select

mandalabhash commented 1 month ago

Thank you sir!

mandalabhash commented 1 month ago

Slither Audit Report

Contract: 3.sol


1. Missing Event for setReward Function


2. Use of Outdated Solidity Version


3. Reentrancy Vulnerability in claimReward


4. Reentrancy Vulnerability in setReward


Conclusion

The smart contract contains several critical issues:

  1. Missing events in the setReward() function.
  2. Use of an outdated Solidity version with known vulnerabilities.
  3. Reentrancy vulnerabilities in both claimReward() and setReward() functions.