Cyber Risks · Trail of Bits Blog

Look out! Divergent representations are everywhere!

Summary: Trail of Bits found that compiler optimizations can represent a single C source variable with different semantics in different parts of a compiled program, a phenomenon it calls "divergent representations," and that these are common in compiled C code. The team first noticed the issue while building a proof-of-concept for CVE-2022-35737, a signed integer overflow in SQLite's sqlite3_str_vappendf function, where Clang at -O1 and above tracks the index variable i as a signed 32-bit value in one loop and a 64-bit unsigned value in another, and its Binary Ninja and CodeQL scans found further candidates in SQLite and libxml2, including 20 CodeQL patterns in libxml2.

What you should know: The same SQLite overflow behaved differently in an unoptimized debug build than in the optimized release build, so an integer overflow you dismiss as benign may compile into an exploitable vulnerability depending on optimization level. The researchers state they cannot make a blanket risk assessment: some divergences are unreachable curiosities, others turn benign overflows into exploitable flaws.

Read the original at Trail of Bits Blog ↗

Topics
Endpoint & Network Security
Related