-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(crypto): strengthen signature length validation #6776
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
base: release_v4.8.2
Are you sure you want to change the base?
Changes from all commits
bc74d53
6d5fcce
9150745
3fa9b53
815ac06
ac7889a
85cb8f0
15bc00f
3938fc3
e4a6642
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -505,6 +505,16 @@ public GrpcAPI.Return broadcastTransaction(Transaction signedTransaction) { | |
| trx.setTime(System.currentTimeMillis()); | ||
| Sha256Hash txID = trx.getTransactionId(); | ||
| try { | ||
| for (ByteString sig : signedTransaction.getSignatureList()) { | ||
| if (!SignUtils.isValidLength(sig.size(), true)) { | ||
| String info = "Signature size is " + sig.size(); | ||
| logger.warn("Broadcast transaction {} has failed, {}.", txID, info); | ||
| return builder.setResult(false).setCode(response_code.SIGERROR) | ||
|
Comment on lines
+508
to
+512
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [DISCUSS] Now, if a node upgrades before VERSION_4_8_2 is activated, the networking layer will immediately and unconditionally reject oversized-signature transactions, while the consensus layer will only start rejecting them after VERSION_4_8_2 is activated. Was this inconsistency between the networking-layer and consensus-layer rejection conditions intentional by design?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes — this is intentional. The asymmetry follows from what each path actually sees:
Net effect on an upgraded-but-not-yet-activated node: it stops accepting freshly-broadcast oversized signatures, but still replays historical blocks correctly. This is documented in the "Compatibility" section of the PR description; happy to fold a shorter version into the code comment near the admission check if that would make the intent more discoverable. |
||
| .setMessage(ByteString.copyFromUtf8("Validate signature error: " + info)) | ||
| .build(); | ||
| } | ||
| } | ||
|
|
||
| if (tronNetDelegate.isBlockUnsolidified()) { | ||
| logger.warn("Broadcast transaction {} has failed, block unsolidified.", txID); | ||
| return builder.setResult(false).setCode(response_code.BLOCK_UNSOLIDIFIED) | ||
|
|
@@ -644,7 +654,8 @@ public TransactionApprovedList getTransactionApprovedList(Transaction trx) { | |
| byte[] hash = Sha256Hash.hash(CommonParameter | ||
| .getInstance().isECKeyCryptoEngine(), trx.getRawData().toByteArray()); | ||
| for (ByteString sig : trx.getSignatureList()) { | ||
| if (sig.size() < 65) { | ||
| // Read-only path: skip the upper bound so historical txs stay resolvable. | ||
| if (!SignUtils.isValidLength(sig.size(), false)) { | ||
| throw new SignatureFormatException( | ||
| "Signature size is " + sig.size()); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.