Skip to content

fix: security hardening — amount validation, address validation, chain ID rejection#26

Open
livingproofdev25 wants to merge 1 commit intomcpdotdirect:mainfrom
livingproofdev25:main
Open

fix: security hardening — amount validation, address validation, chain ID rejection#26
livingproofdev25 wants to merge 1 commit intomcpdotdirect:mainfrom
livingproofdev25:main

Conversation

@livingproofdev25
Copy link
Copy Markdown

@livingproofdev25 livingproofdev25 commented Feb 22, 2026

Summary

  • Transfer amount validation — Added validateAmount() that rejects non-numeric, negative, zero, and excessively large amounts before parseEther()/parseUnits()/BigInt(). Applied to transferETH, transferERC20, approveERC20, and transferERC1155.
  • Ethereum address validation — Added validateAddressOrEns() that validates 0x + 40 hex char format while allowing ENS names (containing .) to pass through. Applied to read_contract, write_contract, transfer_native, and transfer_erc20 tool handlers.
  • Reject unknown chain IDsresolveChainId() and getChain() now throw errors for unrecognized networks instead of silently falling back to Ethereum mainnet, preventing accidental transactions on the wrong chain.

Test plan

  • Verify npx tsc --noEmit passes
  • Verify transfer_native rejects negative amounts (e.g., "-1")
  • Verify read_contract rejects malformed addresses (e.g., "0xinvalid")
  • Verify ENS names like "vitalik.eth" still work
  • Verify unknown network name (e.g., "typo") throws instead of defaulting to mainnet

[XaX] https://XautomateX.com

…ion, chain ID rejection

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants