Normal assembly error handling should preserve existing scratch space data or use dedicated memory regions. The Token-0x implementation unconditionally writes error data to scratch space (0x00-0x3f) without checking for prior usage, causing data corruption in derived contracts that use scratch space for custom validation logic.
The _allowance() function uses generic revert(0, 0) while other functions like _approve() write specific error selectors to scratch space .
Likelihood:
Every internal function that validates parameters may overwrite scratch space
Derived contracts performing custom validation before calling internal functions will experience data corruption
Any function chain that includes validation checks triggers this vulnerability
Impact:
Custom error data in derived contracts gets silently overwritten
Debugging and error diagnosis becomes impossible due to data loss
Potential for incorrect error handling logic based on corrupted scratch space data
The test demonstrates that custom data written to scratch space gets overwritten when internal functions revert. A derived contract writing custom error signatures to scratch space will lose that data when the base contract's validation functions execute their own error handling
Preserve existing scratch space data before writing error information, or use a dedicated memory region for error encoding. The fix should check if scratch space is in use and preserve that data.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.
The contest is complete and the rewards are being distributed.