Reject oversized JSON submit batches before verify - #424
Open
sausagee wants to merge 2 commits into
Open
Conversation
JSON POST /transactions/batch used to run VerifyInput on every item before enforcing max_submit_transaction_batch_size. Cap JSON array length first; keep the existing post-decode check for BCS. Co-authored-by: Young Yang Liauw <sausagee@users.noreply.github.com>
Co-authored-by: Young Yang Liauw <sausagee@users.noreply.github.com>
sausagee
marked this pull request as ready for review
September 6, 2026 05:15
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.
Description
Clean-room rewrite of the intent of aptos-labs/aptos-core@fe434ebe (early JSON batch size check). No aptos-labs code was cherry-picked or copied. This change was written from scratch against the m1 handler.
Problem:
POST /transactions/batchaccepted a JSON array, then ranVerifyInput(and later signed-txn conversion) on every item before enforcingmax_submit_transaction_batch_size. An oversized JSON batch could burn CPU on payload/signature checks that would be discarded.Invariant: If a JSON submit-batch array is already longer than
max_submit_transaction_batch_size, the handler returns400/invalid_inputbeforeverify()and beforeget_signed_transactions_batch. BCS cannot be counted until it is decoded, so the existing post-parse cap stays as the BCS path (and as a backstop).What changed (crate
apionly):reject_json_batch_if_over_configured_limitruns first onSubmitTransactionsBatchPost::Json.How Has This Been Tested?
Ran locally:
3 passed; 0 failedtest_submit_batch_rejects_oversized_json_before_verify— two expired-but-parseable JSON items with limit1fail on the count cap, not expiration (proves verify is skipped).test_submit_batch_json_at_limit_still_verifies_items— two expired items with limit2still fail verify (cap is>, not>=).test_submit_batch_rejects_oversized_bcs_after_decode— two signed txns as BCS with limit1still 400 after decode.Key Areas to Review
submit_transactions_batch: JSON length gate, thenverify(), then decode, then BCS backstop.Aikido / security notes (new code only)
Content-Lengthis still handled by existingPostSizeLimit.submitted > limitonusize; no wrapping math, nounwrapon user input.InvalidInput+ message shape as the existing late check. Early JSON path usesbad_request_with_code_no_infobecause ledger headers are not fetched yet.Type of Change
Which Components or Systems Does This Change Impact?
Checklist
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.