Skip to content

fix: validate bytesN length and intN/uintN bit width in ABI parameter inputs - #122

Open
mzf11125 wants to merge 1 commit into
paradigmxyz:mainfrom
mzf11125:fix/abi-parameter-validation
Open

mzf11125 wants to merge 1 commit into
paradigmxyz:mainfrom
mzf11125:fix/abi-parameter-validation

Conversation

@mzf11125

Copy link
Copy Markdown

The AbiParametersInputs component used two loose regex patterns that accepted invalid values:

For bytesN types (e.g. bytes32): the regex /^0x[0-9a-fA-F]*$/ accepted any hex length. This replaces it with an exact-length pattern (e.g. 64 hex chars for bytes32).

For intN/uintN types: the regex /^[0-9]+$/ accepted any decimal digit string regardless of bit width, and rejected negative integers for intN types entirely. This replaces it with a BigInt range validator that checks the value fits within the declared bit width, and accepts negative values for signed intN.

Both gaps were marked with TODO comments in the source.

Verified: biome check, tsc --noEmit, and bun run build all pass.

Closes #121

… inputs

The AbiParametersInputs component used a loose regex for bytesN
types that accepted any hex length, and a loose regex for intN/uintN
types that accepted any decimal value regardless of bit width.

Replace the bytesN pattern with an exact-length regex that enforces
2N hex characters for a bytesN type. Replace the intN/uintN pattern
with a BigInt range validator that checks the parsed value fits within
the declared bit width, and also accepts negative integers for signed
intN types.

Closes paradigmxyz#121
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.

ABI parameter inputs accept invalid values for bytesN and intN/uintN types

1 participant