fix(transaction-controller): reject transactions that would deploy an empty contract#8744
Merged
matthewwalsh0 merged 1 commit intomainfrom May 8, 2026
Merged
Conversation
41d7192 to
bf27407
Compare
bf27407 to
0ac0c13
Compare
When a transaction has no recipient (`to` is empty string, `'0x'`, or `undefined`) and no real bytecode (`data` is empty or `'0x'`), the TransactionController would silently classify it as a contract deployment and broadcast it. Two places contributed: - `validateParamRecipient` treated `data === '0x'` as real bytecode because `'0x'` is a non-empty string and therefore truthy. - `determineTransactionType` had the same `'0x'` truthiness bug. Now: - `validateParamRecipient` requires `data.length > 2` for the bytecode to count as real, treats `to === ''` as missing alongside `'0x'` and `undefined`, and rejects with a more descriptive error message. - `determineTransactionType` only returns `deployContract` when there is real bytecode.
0ac0c13 to
7154b2f
Compare
OGPoyraz
approved these changes
May 8, 2026
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.
Explanation
TransactionControllerwould silently classify a transaction with no recipient and no real bytecode as a contract deployment and broadcast it, creating an empty contract on-chain with anyvaluepermanently locked inside.The root cause is that
'0x'is a non-empty string, soif (data)truthiness checks invalidateParamRecipientanddetermineTransactionTypetreated it as real deployment bytecode.validateParamRecipientalso didn't recognizeto === ''as missing.Validation now treats
to === ''as missing alongside'0x'/undefined, and both the validator and the type classifier requiredata.length > 2before accepting a missing recipient as a legitimate deployment.References
Checklist
Note
Medium Risk
Tightens core transaction validation/type inference around contract deployments; could cause some previously-accepted malformed transactions to be rejected or reclassified, but the change is narrowly scoped and well-covered by tests.
Overview
Prevents accidental empty contract deployments by treating missing recipients (
toof'','0x', orundefined) as invalid unlessdatacontains real deployment bytecode (more than just'0x').Updates both
validateTxParams/validateParamRecipientanddetermineTransactionTypeto require non-empty bytecode before allowing a missingto, adds targeted unit tests for the new edge cases, and records the fix in thetransaction-controllerchangelog.Reviewed by Cursor Bugbot for commit 7154b2f. Bugbot is set up for automated code reviews on this repo. Configure here.