-
Notifications
You must be signed in to change notification settings - Fork 148
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
TON Static Analysis based on Symbolic Execution #489
Comments
This is an absolutely fantastic proposal based on state-of-the-art research! Compared to the one in #436 it works at the level of TVM which makes it suitable for any language that compiler down to TVM. @korifey I'm wondering in case some bugs are found at the level of TVM instructions, how do you report the error to the programmer so they would understand where to look for it in the source code which is FunC or Tact at the moment? |
happy to see more dev tool guys! (also support in Tact plz) |
Thanks for you good words. How to properly render in source code errors found by bytecode analyzer? So, if we get such kind of support from Tact/FuncC compiler, analyzer will return nice SARIF traces. Another option is to generate test that lead to error. This is an ultimate power of symbolic execution - not only show error but create test (exploit) that demonstrate error behavior. |
This is a nice solution and is certainly doable. I have one more concern, though. Symbolic execution can be quite slow, so it could be challenging to integrate analyzers based on it into some interactive dev tools like IDEs like Intellij IDEA or programmer's editors like VS Code. How do you solve this issue? |
In fact for traditional programming languages programs can be very large (millions lines of code) so symbolic execution alone is too slow. In this case we use primary filter of vulnerabilities by dataflow (IFDS) + point-to. Then symbolic execution comes to play, filtering out false positives of previous stage. But smart contract are relatively small programs and highly optimized summary-based symbolic execution seems like enough for small contracts. I'm not sure compilation phase for Tact is fast enough for real interactive mode. Our combined dataflow & symbolic execution engine allows different tradeoffs between precision and speed. We could implement source code level analysis but it requires another bounty and more R&D. |
Hi guys, what is your opinion about the proposal? Do you need more clarification or not? |
Hi @anton-trunov. Is there any progress on the remaining debug information (especially line numbers) during compilation? |
Hi @Damtev, no progress so far from our side, unfortunately. I opened an issue tact-lang/tact#296, so you can subscribe to it and track progress. We have an upcoming Tact v1.3.0 release this week or next week tops. We'll try our best to get line number information in Tact v1.4.0 |
Hi, we finished first milestone and prepared some video and script for you to show capabilities of proposed approach. Here is video report: https://youtu.be/0r5TbLAXF9o P.S. We are ready to continue evolve our engine for TON static analysis, property based testing and beyond |
Summary
Static analysis tool for TON offers following advantages:
Context
TON requires advanced tools for testing smart contracts so we'd like to implement the best possible bunch of tools on the same symbolic execution core. We want to start with Static Analysis but a single core will enormously reduce development costs for other tools like Property-based testing and Automated test generation in future.
From a business perspective, we believe we can create a unique selling point for TON. Our tool will not only find bugs and vulnerabilities but will also significantly automate smart contracts audit and reduce costs for users.
Scenarios
Static analyzer usually takes source/bytecode of a smart contract as input and provides analysis results as output verifying some rules. Contemporary static analysis tool provides output in SARIF format supported by many tools.
There are several forms how user can run the tool:
Typically static analysis can have predefined and custom rules. Some predefined examples:
It's extremely important to provide flexible API to define user-defined checks for certain classes of analysis such as:
Technical advantages of the proposed approach
The core of analyzer is built upon a cutting-edge symbolic execution engine for TVM bytecode. It uses symbolic execution with SMT solving and taint analysis to find bugs, vulnerabilities, and automatically generate unit tests with mathematical precision.
Team
We are a team of professionals with a rich industry and academic background: 10+ years in developer tools, 7+ years in code analysis and symbolic execution.
We’ve been delivering precise and scalable symbolic execution engines for C/C++, Java and .NET Core into industrial settings. We gained awards in acknowledged academic competitions:
Plan for milestone 1
Since we've already spent 1 month on R&D How to implement symbolic execution for TVM based on USVM, we need additional 6 weeks to deliver a demo of our static analysis capabilities.
Sprint 0 (already done)
Symbolic interpreter supporting bytecode instructions:
Sprint 1 (2 weeks)
Support bytecode instructions to verify some exiting real smart contracts:
Sprint 2 (2 weeks)
Try to interpret some real contracts.
Support base checks for demo:
Sprint 3 (2 weeks)
Polish checks on real contracts, maybe support additional instructions.
Provide CLI that takes a contract and returns check results in SARIF format.
Provide documentation and report how it works.
References
Similar engines have been successfully applied for the analysis of Ethereum smart contracts on EVM bytecode level. Among them are mythril, manticore, and oyente.
Some of mentioned links above:
Estimate suggested reward
💰 9000 USD
🕑 6 weeks (3 sprints)
The text was updated successfully, but these errors were encountered: