Skip to content

audit I07 — variable-length logic opcodes asymmetric input clamp between integrity() and run() #492

Description

@thedavidmeister

From the March 2026 audit (commit `13917ea1`):

`LibOpAny`, `LibOpEvery`, and `LibOpConditions` clamp minimum inputs in `integrity()` to prevent zero-length processing:

```solidity
inputs = inputs > 0 ? inputs : 1;
```

The corresponding `run()` functions calculate stack lengths strictly from the raw operand bits without duplicating this clamp.

The central `integrityCheck2` loop prevents mismatch from reaching execution via `BadOpInputsLength`, but the safety guarantee is in a distant generic location rather than co-located with the opcode logic. Latent structural fragility: if the central check were relaxed, a `run()` executing with zero inputs would shift the stack top down without popping items, pushing uninitialized EVM memory as output.

Path: `src/lib/op/logic/LibOpAny.sol`, `src/lib/op/logic/LibOpEvery.sol`, `src/lib/op/logic/LibOpConditions.sol`

Fix: duplicate the minimum-input clamp inside each `run()` before computing the stack-length variable. Execution then respects the same validation bounds independent of any external check loop.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions