fix(net): enforce 65-byte signature length#6781
Closed
Federico2014 wants to merge 5 commits into
Closed
Conversation
* fix(config): remove redundant JSON-RPC config fields and consolidate parameter binding Remove maxBlockFilterNum, maxAddressSize, and maxRequestTimeout from NodeConfig/CommonParameter since they were superseded by the jsonRpcMaxBatchSize/jsonRpcMaxResponseSize parameters. Consolidate the config binding path so all JSON-RPC size limits flow through a single reference.conf entry, and clean up stale test-config fixtures. * fix bug of NodeConfigTest * remove allowShieldedTransactionApi from reference.conf * add testcase of external.ip is null * change comment * fix the bug of --es and 7 failed testcases
…onprotocol#6760) Pre-3.0.0(The previous event-plugin public release is 2.2.0) event-plugin builds still link against com.alibaba.fastjson, which was removed from java-tron in tronprotocol#6701. When such a plugin is loaded, the NoClassDefFoundError surfaces inside the plugin's own worker thread and is swallowed by its catch(Throwable) handler. The node keeps running while silently dropping every trigger, leaving operators with no signal that the event subscription is broken. Enforce a minimum Plugin-Version at startup in EventPluginLoader.startPlugin using pf4j's VersionManager (semver). When the descriptor version is below 3.0.0, log a clear upgrade hint and return false; the existing call chain in Manager.startEventSubscribing wraps that into TronError(EVENT_SUBSCRIBE_INIT) and aborts node startup instead of silently degrading.
…rs (tronprotocol#6761) - Add `rate.limiter.apiNonBlocking` switch (default false). When off, callers wait for a permit; when on, they reject immediately and shed load. - Wire the switch through `RateLimiterConfig` → `Args` → `CommonParameter`; update `reference.conf` / `config.conf`. - Add blocking `acquire()` paths on `IRateLimiter`, `GlobalRateLimiter`, and `QpsStrategy` / `IPQpsStrategy` / `GlobalPreemptibleStrategy`. Only the semaphore-based strategy is bounded (2s); the QPS-based paths use unbounded Guava `RateLimiter.acquire()`. - Introduce `acquirePermit()` dispatcher (default method on `IRateLimiter`; static on `GlobalRateLimiter`) that picks blocking vs non-blocking based on the switch. - Swap `tryAcquire` → `acquirePermit` at the `RateLimiterServlet` and `RateLimiterInterceptor` call sites; preserve per-endpoint-before-global ordering to avoid consuming global quota on per-endpoint rejection. - Extract `loadIpLimiter()` in `GlobalRateLimiter` and `loadLimiter()` in `IPQpsStrategy` to share cache+exception handling between `tryAcquire` and `acquire`. - Add unit tests covering dispatcher routing (both directions), acquire IP-before-global ordering, and IP-loader-failure fail-closed behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Adds a strict 65-byte length check on signatures received over the
network and the broadcast API, before any signature recovery work is
done:
Wallet.broadcastTransaction— rejects the transaction withSIGERRORwhen any signature in the list is not 65 bytes.TransactionsMsgHandler.check— throwsP2pException(BAD_TRX)whenany signature in a
TransactionsMessageis not 65 bytes, causing thepeer to be disconnected with
BAD_TX.RelayService.checkHelloMessage— returnsfalsewhen theHelloMessagesignature from a fast-forward peer is not 65 bytes.The constant
Constant.PER_SIGN_LENGTH(= 65) is reused everywhere.Why are these changes required?
A valid TRON ECDSA/SM2 signature is exactly 65 bytes (
r32 +s32 +v1). Today these entrypoints will still feed a malformed signatureinto
SignUtils.signatureToAddress/ signature recovery, which wastesCPU on payloads that can never validate, and lets a peer cheaply force
expensive work by sending arbitrary-length blobs. A fast length check
up front rejects the payload before any crypto runs and keeps the
failure mode uniform across the three entrypoints.
This PR has been tested by:
WalletMockTest#testBroadcastTxInvalidSigLength— 64 / 66 / emptysignatures return
SIGERROR; 65-byte signature falls through.TransactionsMsgHandlerTest#testInvalidSigLength— 64 / 66 / emptysignatures raise
P2pException(BAD_TRX)viaassertThrows.RelayServiceTest#testCheckHelloMessage— extended to assert that64 / 66 / empty
HelloMessagesignatures returnfalse; theexisting 65-byte case still returns
true../gradlew :framework:checkstyleMain :framework:checkstyleTest./gradlew :framework:test --tests "...RelayServiceTest"etc.Follow up
None.
Extra details
No protocol or storage change. Behavior change is observable only for
peers / clients that previously sent non-65-byte signatures, which
would have failed signature recovery downstream anyway — now they fail
faster and with a clearer error.