Comments (7)
Thanks for the contract, the PR #1812 will fix this
from mythril.
Looks like making this small change in the function extract_address_variable
present in the file features.py:226-231
fixes this temporarily:
elif isinstance(value, list):
for item in value:
if item != None:
transfer_vars.update(self.extract_address_variable(item))
return transfer_vars
(checking if item
is not None
instance and then updating)
from mythril.
It turns out that objects likestr
s (and int
s) are also passed to the the function leading to the same issue. Is it due to some changes in an upstream package?
With:
/*
* @author: Bernhard Mueller (ConsenSys / MythX)
*/
pragma solidity 0.6.4;
interface ICallable {
function callMe() external;
}
contract HardcodedNotGood {
address payable _callable = 0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa;
ICallable callable = ICallable(_callable);
constructor() public payable {
}
function doTransfer(uint256 amount) public {
_callable.transfer(amount);
}
function doSend(uint256 amount) public {
_callable.send(amount);
}
function callLowLevel() public {
_callable.call.value(0).gas(10000)("");
}
function callWithArgs() public {
callable.callMe{gas: 10000}();
}
}
I get:
mythril.interfaces.cli [ERROR]: Traceback (most recent call last):
File "~/venv/lib/python3.10/site-packages/mythril/interfaces/cli.py", line 966, in parse_args_and_execute
address = load_code(disassembler, args)
File "~/venv/lib/python3.10/site-packages/mythril/interfaces/cli.py", line 717, in load_code
address, _ = disassembler.load_from_solidity(
File "~/venv/lib/python3.10/site-packages/mythril/mythril/mythril_disassembler.py", line 291, in load_from_solidity
for contract in get_contracts_from_file(
File "~/venv/lib/python3.10/site-packages/mythril/solidity/soliditycontract.py", line 132, in get_contracts_from_file
yield SolidityContract(
File "~/venv/lib/python3.10/site-packages/mythril/solidity/soliditycontract.py", line 197, in __init__
).extract_features()
File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 28, in extract_features
ether_vars = self.extract_address_variable(node)
File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 224, in extract_address_variable
transfer_vars.update(self.extract_address_variable(value))
File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 228, in extract_address_variable
transfer_vars.update(self.extract_address_variable(item))
File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 224, in extract_address_variable
transfer_vars.update(self.extract_address_variable(value))
File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 224, in extract_address_variable
transfer_vars.update(self.extract_address_variable(value))
File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 228, in extract_address_variable
transfer_vars.update(self.extract_address_variable(item))
File "~/venv/lib/python3.10/site-packages/mythril/solidity/features.py", line 210, in extract_address_variable
node.get("nodeType", "") == "ExpressionStatement"
AttributeError: 'str' object has no attribute 'get'
Sorry for the delay in reporting this.
from mythril.
Does the current develop work for you? This example works for me on the develop.
Clone the develop and you can directly execute it using ./myth analyze <file_path>
from mythril.
Yes, surprisingly it did fix that issue. But I found a new one in a different file:
mythril.interfaces.cli [ERROR]: Traceback (most recent call last):
File "/home/parakeet/tests/mythril/mythril/interfaces/cli.py", line 966, in parse_args_and_execute
address = load_code(disassembler, args)
File "/home/parakeet/tests/mythril/mythril/interfaces/cli.py", line 717, in load_code
address, _ = disassembler.load_from_solidity(
File "/home/parakeet/tests/mythril/mythril/mythril/mythril_disassembler.py", line 272, in load_from_solidity
if self.check_run_integer_module(file) is False:
File "/home/parakeet/tests/mythril/mythril/mythril/mythril_disassembler.py", line 236, in check_run_integer_module
normalized_version = self.solc_version.lstrip("v")
AttributeError: 'NoneType' object has no attribute 'lstrip'
The contract in question does not specify the solidity version (which is wrong) but when I tested it with Mythril v0.23.19
the compilation works fine.
Looks like the source is this recent change:
a28d600
from mythril.
This mythril version tries to autofind the solidity version, Can you try to paste the first few lines at the top of the file (till contract <ContractName>
)? I'll try fixing this issue
from mythril.
Here is the contract:
contract MarketPlace {
address owner;
uint256 private cost = 100;
uint256 private inventory = 20;
event Purchase(address _buyer, uint256 _amt);
function increasePrice (uint256 increaseCost) public {
require(msg.sender == owner);
cost += increaseCost;
}
function buy() public payable returns (uint256) {
uint256 amt = msg.value / cost;
require(inventory > amt);
inventory -= amt;
emit Purchase(msg.sender, amt);
}
}
from mythril.
Related Issues (20)
- How to run custom plugin along with mythril? HOT 1
- Mythril cannot identify imported openzeppelin contracts in foundry project. HOT 5
- DeclarationError: Identifier already declared. HOT 8
- Does mythril have the following features HOT 4
- Mythril 0.24.4 raises an error on macOS HOT 2
- Inconsistency in the results of function seqeunce execution HOT 23
- Mythril is producing one liner success report without details. HOT 1
- External call does not change the storage of the callee contract.
- Solc experienced a fatal error while running myth on a Foundry-based project importing an OpenZeppelin library HOT 2
- Unchecked return value not flagged
- Missing support for transient storage opcodes HOT 1
- Mythril is very slow HOT 1
- Inconsistent results source vs bytecode HOT 3
- Misspelled Rootstock in the repository's about section
- Incoherent overflow detection HOT 3
- Mythril cannot properly detect remapped imports in dependencies
- How to get the selector in a analysis module HOT 7
- analyze with --graph or --statespace-json doesn't work HOT 3
- 🚩 Feature Request: NixOS Flake
- >> execution-timeout 300 >> Not working as expected HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mythril.