[web3] Low bug in Nomad found by Nikita Stupin
The TypedMemView library's isValid function used the Yul not instruction instead of iszero, causing it to always return true regardless of the input. This could break memory safety guarantees for projects using the library.
nikitastupin.com
Published on nikitastupin.com
To start the blog I would like to share how the not and iszero instructions differ in Yul. This have led to discovery of two interesting low-severity bugs one of which is public so I am going to use it as an example to spread the knowledge about the difference.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The developer used the bitwise NOT instruction (not) instead of the logical negation instruction (iszero) when converting a comparison result to a boolean, so the function always returned true.
Impact
The bug could potentially break memory safety guarantees in projects using the library, though the exact impact was not fully explored.
What the attacker needed
Library used in a project
The fix
The not instruction was replaced with iszero.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A library for handling memory in smart contracts had a function meant to check if a memory view is valid. Due to a mistake in a low-level instruction, the check always said 'valid' even when it shouldn't. This could let programs use invalid memory views, potentially causing unexpected behaviour.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.