feat(crypto): shielded transaction API security enhancement#6694
feat(crypto): shielded transaction API security enhancement#6694Federico2014 wants to merge 1 commit intotronprotocol:developfrom
Conversation
The default value of After the upgrade, approximately 26 Wallet/gRPC/HTTP endpoints are disabled. However, many of these endpoints do not involve private key handling, for example:
Additionally, several read-only / scanning APIs are implicitly disabled, including:
Disabling these endpoints has significant side effects:
The TRON developer documentation already recommends constructing shielded transaction parameters locally. The ecosystem tool wallet-cli also provides local shielded key derivation that does not depend on node APIs and is therefore unaffected by this flag. However, when
Suggestions
Overall, the current change improves security posture, but the all-or-nothing behavior introduces usability and decentralization trade-offs that could be mitigated with finer-grained controls and better local tooling support. |
|
class request { |
|
@3for Thanks for the thorough analysis. A few points in response: On the breaking change: The On the API categorization: Your observation that some APIs under this flag (e.g., On centralization risk: We acknowledge the concern, but in practice shielded transaction activity on TRON is extremely limited. On-chain data shows very low usage for shielded TRC20 contracts (e.g., contract 1, contract 2), suggesting the real-world impact on users is minimal. Operators who specifically support shielded use cases can explicitly set We're open to revisiting granular controls if shielded transaction usage grows significantly, but at this stage the added complexity isn't warranted. |
f301e6f to
8d20e0e
Compare
What does this PR do?
Enhances the security of shielded transaction APIs by adding overflow protection, tightening default configuration, and cleaning up unused artifacts.
ZenTransactionBuilderandShieldedTRC20ParametersBuilder: replaced raw+=/-=onvalueBalancewithStrictMathWrapper.addExact()/subtractExact(), which throwArithmeticExceptionon overflow. Overflow validation is performed before mutating builder state (spends/receiveslists), ensuring the builder remains consistent if an overflow is detected.createShieldedTransaction,createShieldedTransactionWithoutSpendAuthSig,createShieldedContractParameters, andcreateShieldedContractParametersWithoutAskintry/catch ArithmeticExceptionto convert overflow toZksnarkException("shielded amount overflow")allowShieldedTransactionApifromtruetofalseto reduce exposure by default, since some shielded transaction APIs require passing private keys as parametersconfig.confwith an explicit warning advising users to only invoke these APIs locallysprout-verifying.keyfrom the repository root — the file was not referenced by any codeallowShieldedTransactionApiand properly save/restore the flagWhy are these changes required?
valueBalancewas accumulated via raw+=/-=without overflow checks, allowing crafted inputs to silently wrap aroundlongrange and produce invalid balancessprout-verifying.keywas an unreferenced artifact that added unnecessary repository bloatallowShieldedTransactionApidefault changed fromtruetofalse— nodes that previously relied on the default will find shielded transaction APIs disabled after upgrade. Fix: explicitly setallowShieldedTransactionApi = trueinconfig.conf.This PR has been tested by:
ShieldedTransferActuatorTest,ArgsTest,ShieldedTRC20BuilderTest,CreateSpendAuthSigServletTest,MerkleContainerTestFollow up
No consensus logic or on-chain state transitions affected.
Extra details
Close #6616