Closed mandalabhash closed 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:
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
Thank you sir!
Contract: 3.sol
setReward
FunctionEthTxOrderDependenceMinimal.setReward()
(3.sol#12-18)setReward()
function updates the state variable reward
(3.sol#17) but does not emit an event for this action.claimReward
EthTxOrderDependenceMinimal.claimReward(uint256)
(3.sol#20-25)msg.sender.transfer(reward)
(3.sol#23), followed by writing to the state variable claimed = true
(3.sol#24). This opens the contract to a reentrancy attack, where an attacker could potentially re-enter the contract and manipulate the contract’s state before the transfer is completed.setReward
EthTxOrderDependenceMinimal.setReward()
(3.sol#12-18)owner.transfer(reward)
(3.sol#16), followed by updating the state variable reward = msg.value
(3.sol#17). This sequence makes the contract vulnerable to reentrancy attacks.The smart contract contains several critical issues:
setReward()
function.claimReward()
and setReward()
functions.
got the following error:
""" (albert㉿aimmore)-[~/Desktop/lpu_presentation/Supplement/Slither Myth] └─$ slither ./3.sol
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:
'solc --version' running Traceback (most recent call last): File "/home/albert/.local/bin/slither", line 8, in
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] └─$ """