feat: Introduce core database and blockchain state manager, alongside… #6513
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
… PoC tests for integer overflow and exception handling.
Executive Summary
The java-tron blockchain implementation contains incomplete exception handling in the fork switching logic (
Manager.javalines 1133 and 1171). This vulnerability could lead to blockchain state inconsistencies when fork switches fail, potentially enabling consensus attacks, double-spend scenarios, or network splits.Vulnerability Details
Location
framework/src/main/java/org/tron/core/db/Manager.javaswitchFork(BlockCapsule newHead)Description
During blockchain fork switching operations, exceptions that occur while applying blocks are caught but not properly handled. The code contains TODO comments indicating this is known but unresolved:
Impact
Proof of Concept
Running the PoC
Expected Output
The PoC demonstrates:
PoC Files
framework/src/test/java/org/tron/poc/M1_IntegerOverflowPoC.java- Demonstrates M-1 protectionframework/src/test/java/org/tron/poc/M2_ExceptionHandlingPoC.java- Demonstrates M-2 vulnerabilityReproduction Steps
Recommended Fix
See
implementation_plan.mdfor complete fix details. Key improvements:Additional Finding: M-1 Integer Overflow
Status: ✅ Already Protected
The codebase properly uses
Maths.addExact()andMaths.multiplyExact()throughout to prevent integer overflow. This is a positive security finding.Evidence:
TransferActuator.java: Lines 60, 158, 166TransferAssetActuator.java: Line 180VMUtils.java: Lines 173, 234AccountCapsule.java: Lines 728, 748, 749PoC:
M1_IntegerOverflowPoC.javademonstrates the protection works correctly.Timeline
References
3 Files Changed
M1_IntegerOverflowPoC.java- PoC for M-1 (positive finding)M2_ExceptionHandlingPoC.java- PoC for M-2 vulnerabilityManager.java.patch- Proposed fix