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

[Bug]: heimdall cfg produces empty cfg.dot file #53

Closed
2 tasks done
0xharold opened this issue Feb 2, 2023 · 5 comments · Fixed by #59
Closed
2 tasks done

[Bug]: heimdall cfg produces empty cfg.dot file #53

0xharold opened this issue Feb 2, 2023 · 5 comments · Fixed by #59
Assignees

Comments

@0xharold
Copy link

0xharold commented Feb 2, 2023

Component

Heimdall Modules

Version

heimdall 0.3.0

Please check the following

  • This is not a duplicate issue
  • I have checked the wiki and tried troubleshooting the issue

Operating System

Windows

Describe the issue you are facing

I have been trying to generate a CFG file from a bytecode directly but cfg.dot file is empty. bytecode.evm file is generated as well as a disassembled.asm file. What am I doing wrong?

I run:

heimdall cfg "608060405234801561001057600080fd5b5060405160208061021783398101604090815290516000818155338152600160205291909120556101d1806100466000396000f3006080604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166318160ddd811461005b57806370a0823114610082578063a9059cbb146100b0575b600080fd5b34801561006757600080fd5b506100706100f5565b60408051918252519081900360200190f35b34801561008e57600080fd5b5061007073ffffffffffffffffffffffffffffffffffffffff600435166100fb565b3480156100bc57600080fd5b506100e173ffffffffffffffffffffffffffffffffffffffff60043516602435610123565b604080519115158252519081900360200190f35b60005490565b73ffffffffffffffffffffffffffffffffffffffff1660009081526001602052604090205490565b600073ffffffffffffffffffffffffffffffffffffffff8316151561014757600080fd5b3360009081526001602052604090205482111561016357600080fd5b503360009081526001602081905260408083208054859003905573ffffffffffffffffffffffffffffffffffffffff85168352909120805483019055929150505600a165627a7a723058200a524f675439c5c0b2c59c531c7791e0eba97dcd3ab5afd2ca878971b0a7a96600290000000000000000000000000000000000000000000000000000000000002710" -vvv

I get:

info: disassembled 567 bytes successfully.
success: wrote disassembled bytecode to '/home/haraslub/output/disassembled.asm' .
debug: disassembly completed in 0 ms.
debug: detected compiler solc 0.4.22+.
info: found 4 possible function selectors.
info: performing symbolic execution on '608060405234801561001057600080fd5b5060405160208061021783398101604090815290516000818155338152600160205291909120556101d1806100466000396000f3006080604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166318160ddd811461005b57806370a0823114610082578063a9059cbb146100b0575b600080fd5b34801561006757600080fd5b506100706100f5565b60408051918252519081900360200190f35b34801561008e57600080fd5b5061007073ffffffffffffffffffffffffffffffffffffffff600435166100fb565b3480156100bc57600080fd5b506100e173ffffffffffffffffffffffffffffffffffffffff60043516602435610123565b604080519115158252519081900360200190f35b60005490565b73ffffffffffffffffffffffffffffffffffffffff1660009081526001602052604090205490565b600073ffffffffffffffffffffffffffffffffffffffff8316151561014757600080fd5b3360009081526001602052604090205482111561016357600080fd5b503360009081526001602081905260408083208054859003905573ffffffffffffffffffffffffffffffffffffffff85168352909120805483019055929150505600a165627a7a723058200a524f675439c5c0b2c59c531c7791e0eba97dcd3ab5afd2ca878971b0a7a96600290000000000000000000000000000000000000000000000000000000000002710' .
info: symbolic execution completed.
success: wrote generated dot to '/home/haraslub/output/cfg.dot' .
success: wrote generated svg to '/home/haraslub/output/cfg.svg' .
debug: Control flow graph generated in 71.276253ms.
trace:
  [83] heimdall::cfg(608060405234801561001057600080fd5b50604051602080610217833981016040...0000000000002710)
    ├─ [200] heimdall::disassemble(567 bytes)
    │   └─ ← ()
    ├─ [211] heimdall::detect_compiler(567 bytes)
    │   └─ ← (solc, 0.4.22+)
    ├─ [241] create → contract@608060405234801561001057600080fd5b50604051602080610217833981016040...0000000000002710
    │   └─ ← 567 bytes
    └─ ← ()

I am on WIN 11, WSL2, Ubuntu 20.4;

Thanks is advance!

@0xharold 0xharold added the bug label Feb 2, 2023
@Jon-Becker
Copy link
Owner

I'll investigate!

@Jon-Becker Jon-Becker self-assigned this Feb 2, 2023
@Jon-Becker
Copy link
Owner

This contract has a non-standard function dispatcher. I'll make a patch for this in 3.0.1. This fix should also allow for vyper contract decompilation and CFG generation.

@Jon-Becker Jon-Becker added T: Bug and removed bug labels Feb 2, 2023
@0xharold
Copy link
Author

0xharold commented Feb 3, 2023

FYI this bytecode is taken from Deconstructing a Solidity Contract by OZ.

@Jon-Becker
Copy link
Owner

Resolved in commit b0c41c6. The CFG module should now support any EVM contract, regardless of compiler.

I'll publish the release for this today or tomorrow, 0.3.1. Thank you!

@Jon-Becker Jon-Becker linked a pull request Feb 8, 2023 that will close this issue
@Jon-Becker
Copy link
Owner

Pushing release to tomorrow

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

Successfully merging a pull request may close this issue.

2 participants