Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Results in embark-mythx console are different than in the MythX portal #10

Open
emizzle opened this issue Mar 16, 2020 · 0 comments
Open

Comments

@emizzle
Copy link
Contributor

emizzle commented Mar 16, 2020

  1. Create a contract reentrancy.sol with source:
pragma solidity ^0.4.15;

contract Reentrance {
    mapping(address => uint256) userBalance;

    function getBalance(address u) constant returns (uint256) {
        return userBalance[u];
    }

    function addToBalance() payable {
        userBalance[msg.sender] += msg.value;
    }

    function withdrawBalance() {
        // send userBalance[msg.sender] ethers to msg.sender
        // if mgs.sender is a contract, it will call its fallback function
        if (!(msg.sender.call.value(userBalance[msg.sender])())) {
            throw;
        }
        userBalance[msg.sender] = 0;
    }

    function withdrawBalance_fixed() {
        // to protect against re-entrancy, the state variable
        // has to be change before the call
        uint256 amount = userBalance[msg.sender];
        userBalance[msg.sender] = 0;
        if (!(msg.sender.call.value(amount)())) {
            throw;
        }
    }

    function withdrawBalance_fixed_2() {
        // send() and transfer() are safe against reentrancy
        // they do not transfer the remaining gas
        // and they give just enough gas to execute few instructions
        // in the fallback function (no further call possible)
        msg.sender.transfer(userBalance[msg.sender]);
        userBalance[msg.sender] = 0;
    }

}

embark-mythx reports the following errors:
embark-mythx output

However looking at the results in the MythX portal, we see slightly different results:
MythX Portal results

Expected: The results in the embark-mythx output should match the results in the MythX portal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant