question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect result when accessing mapping of a remote contract

See original GitHub issue

Description

I’ve ran into unexpected Mythril behavior which can be simplified to the following example. Consider the contract:

pragma solidity ^0.4.20;
contract Killable {
    mapping (uint => uint) map;
    function kill(uint key) public
    {
        map[key] = 1;
        if (map[0xdeadbeef] > 0) suicide(msg.sender);
    }
}

When deploying this contract (via ganache) and analyzing via the AccidentallyKillable module, the vulnerability is successfully detected:

Transaction Sequence:

Caller: [ATTACKER], function: kill(uint256), txdata: 0xd29a0025, value: 0x0
Caller: [ATTACKER], function: kill(uint256), txdata: 0xd29a002500000000000000000000000000000000000000000000000000000000deadbeef, value: 0x0

(although the first call seems unnecessary). However if we use a public mapping of another contract (rather than a local private one):

pragma solidity ^0.4.20;
contract RemoteMap {
    mapping (uint => uint) public map;
    function setVal(uint key, uint val) public
    {
        map[key] = val;
    }
}
pragma solidity ^0.4.20;
import "./remote_map_uint.sol";
contract Killable {
    RemoteMap constant remoteMap = RemoteMap(<address of RemoteMap>);
    function kill(uint key) public
    {
        remoteMap.setVal(key, 1);
        if (remoteMap.map(0xdeadbeef) > 0) suicide(msg.sender);
    }
}

and similarly analyze the latter contract on-chain, only the first “unnecessary” transaction is produced (which by itself does not cause a call to suicide):

Transaction Sequence:

Caller: [ATTACKER], function: kill(uint256), txdata: 0xd29a0025, value: 0x0

How to Reproduce

I deploy all contracts via ganache and analyze on-chain via myth analyze -m AccidentallyKillable --rpc localhost:8547 -a <address> I am on Mythril v0.22.30.

Expected behavior

I expected the call kill(0xdeadbeef) to be detected as a vulnerability in the second case as well.

Additional Environment or Context

I am not sure if this is the same problem as discussed in #1494 (symbolic storage locations). However it seems strange that analysis succeeds when the mapping is in local storage but fails when it is external to the contract. Additionally, analysis fails in the same way (prints transaction without any function argument) when analyzing from source or when --unconstrained-storage is specified (I thought this option would help circumvent the symbolic location issue).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
norhhcommented, Nov 17, 2021

@loki3451 , your local client is returning “0x” for storage information, which is invalid for json-rpc. I’ll handle this case.

0reactions
norhhcommented, Nov 18, 2021

@loki3451 , thanks for detecting this error, can you create a separate issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect result when accessing mapping of a remote contract
I am on Mythril v0.22.30. Expected behavior. I expected the call kill(0xdeadbeef) to be detected as a vulnerability in the second case as...
Read more >
Solidity by Example — Solidity 0.8.17 documentation
The following contract solves this problem by accepting any value that is larger than the highest bid. Since this can of course only...
Read more >
Consensus Steps - Reach docs
A Reach consensus step occurs in the continuation of a consensus transfer statement. It represents the actions taken by the consensus network contract...
Read more >
Salesforce Response Mapping - Qualtrics
About Response Mapping. Response Mapping is used to take the answers provided in a Qualtrics survey and map them back to a Salesforce...
Read more >
There was no endpoint listening at (url) that could accept the ...
This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. The inner exception says: Unable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found