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.

Bytecode Becomes Contract Address In Exploit Output

See original GitHub issue

Description

Okay, really weird bug here. Runnnig mythril over the address 0xD99b6e04d6911f032d2e9139Bd3309D2641Dc706 causes the final exploit found to be an address not of its own (i.e., “0xD99b…”). Instead, it is part of the bytecode with a 0x thrown in front of it.

...
==== Exception State ====
SWC ID: 110
Severity: Low
Contract: 0x6012c8cf97bead5deae237070f9587f8e7a266d
Function name: giveBirth(uint256)
PC address: 6528
Estimated Gas Usage: 1932 - 2687
A reachable exception has been detected.
It is possible to trigger an exception (opcode 0xfe). Exceptions can be caused by type errors, division by zero, out-of-bounds array access, or assert violations. Note that explicit `assert()` should only be used to check invariants. Use `require()` for regular input checking.
--------------------
Initial State:

Account: [ATTACKER], balance: 0x0, nonce:0, storage:{}
Account: [SOMEGUY], balance: 0x0, nonce:0, storage:{}

Transaction Sequence:

Caller: [SOMEGUY], function: unknown, txdata: 0x3030303000303030303030303030303030303030303030303030303030903030, value: 0x0

How to Reproduce

myth -v4 analyze -1 --execution-timeout 3600 -a 0xD99b6e04d6911f032d2e9139Bd3309D2641Dc706

Expected behavior

All exploits should have the address of the contract, not a subsection of the bytecode.

Other examples

The contract 0x1c764a70797DeB7100037581e679684Cc5C9CA42 produces the same problem. However, in this contract the output that is incorrectly put at the end as an exploit from a bug that grabs the bytecode IS a contract (e.g., 0x8d12a197cb00d4747a1fe03395095ce2a5cc6819), which can be easily confusing to people looking at output. I am fairly certain it is not a dependency of this contract, because it would be too coincidental that the bytecode also matched a contract address of a dependency.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
norhhcommented, Jan 8, 2020

@Danc2050 , It was some python error. The contract should be 0x06012c8cf97bead5deae237070f9587f8e7a266d . Python skips a leading zero while printing hex, so while searching just add a bunch of leading zeros if the length is != 40, I should correct this in mythril.

0reactions
Danc2050commented, Jan 8, 2020

Great! Thank you for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exploiting Smart Contract Bytecode for Classification on ...
[22] into classifying contracts according to having a code vulnerability. They translate the opcode of the smart contracts into one-hot vector sequences which....
Read more >
A Bytecode-based Approach for Smart Contract Classification
The process can be divided into three steps: first, use a high-level language like Solidity to write the smart contract source code; second,...
Read more >
Smart Contract Defense Through Bytecode Rewriting
This addresses a wave of smart contract vulnerabilities that have been exploited by cybercriminals in recent years to steal millions of dollars from...
Read more >
Multi-Label Vulnerability Detection of Smart Contracts Based ...
Section 3 describes five smart contract vulnerabilities and analyzes the relationship between contract source code, bytecode, and opcode.
Read more >
HackPedia: 16 Solidity Hacks/Vulnerabilities, their Fixes and ...
The Vulnerability. This attack can occur when a contract sends ether to an unknown address. An attacker can carefully construct a contract at...
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