Not AI but poorly designed programming languages ignoring integer overflows.
I don’t know any systems programming language that doesn’t ignore integer overflow/underflow in release builds. IMHO this is a CPU design flaw - integer operations should carry a flag indicating if the operation is allowed to wrap or if it should generate a trap. Then there wouldn’t be a performance penalty for this and languages like Rust could have it be trapped by default.
No. Memory safe languages still have integer handling issues, but the consequences are different. In a memory-unsafe language, integer mishandling often nets out to bad copies and memory corruption.
I wouldn’t be sure that a Rust equivalent would be immune because it’s not hard to imagine an underflow/overflow from reaching an unsafe block that’s used for performance (the implicated TLS path would be a hotspot worthy of such a choice).
This is the thing about `unsafe` blocks: they're not memory safe. It's right there in the name.
I'm not making a Rust advocacy argument. I'm just saying: it's true that integer handling issues are endemic to mainstream programming languages, but the integer handling itself is almost never the actual sharp end of the vulnerability.
Android had an integer overflow vulnerability where it could be tricked into verifying the signing of one file but install another for execution. Boeing 787 Dreamliner had a bug where after 248 it's 32-bit counter overflowed triggering a "fail-safe" mode that shut down all electrical power to the aircraft.
You're right it's more rare but the results can still be catastrophic.
Isn't "memory corruption" typically the fast path to RCE? The attacker gets to overwrite a function pointer, or a regular pointer that then lets them overwrite something else, or the length field that will then cause a buffer overrun even in a "safe" language because the run-time length is now different than the one in the compile-time check, etc.
Memory corruption -> RCE.
Integer handling mistake -> memory corruption -> RCE.
That's the pattern. In a memory-safe language, the integer handling error has no link to memory corruption (though it will to other logic bugs!).
Zig traps arithmetic overflow/underflow when compiling in ReleaseSafe.
X86 had the INTO instruction to trigger a fault if the Overflow flag is set, so not quite a per-instruction bit but more of a suffix. JO is also fairly straightforward for compilers to add on important arithmetic operations. We can probably blame C entirely for this; only in C23 are there intrinsics for overflow detection on arithmetic.
C23 intrinsics are so ugly that nobody is going to use them. They should have made ordinary "+" to trap on overflow, and an ugly instirnsic to wrap around.
Lisp or Python have a proper numeric tower and don't default to machine types. Keyword being default, fast is still possible in CL.
"I don't know any decent language so let's continue using poorly designed languages". Please look at Swift, Javascript, Python.
Why would CPU designers make a trap if languages do not require it?
JavaScript and Python aren’t systems languages. Swift often pays the performance penalty for trapping everywhere and hasn’t seen adoption as a systems language for that reason.
How does that saying go?
"Go fast and get your things broken into"
We're after a way to go fast without having your things broken into. "Language allows you to specify whether you want wrap around or an exception and hardware makes implementing that efficient" is better than both inefficient runtime checks and silent data corruption.