4 ms·
Code compiled to WASM typically also have a stack in the linear memory for storing the program's data structures and values that would need to be dereferenced,
by Findecanor 3y ago
Code compiled to WASM typically also have a stack in the linear memory for storing the program's data structures and values that would need to be dereferenced, thus without any protection.
Only the "local" variables and the operand stack are protected.
"Control-Flow Integrity" can have a general sense, or a specific sense.
In the general sense, it means that function pointers and return addresses are protected — and WASM protects the raw function pointers.
In code compiled to WASM, a function pointer is represented as an integer indexing into a single global list with all functions. The "call_indirect" op checks only that the index is within bounds and that the function type signature of the function you look up matches.
In the specific sense, as in the 2005 paper titled "Control-Flow Integrity: Principles, Implementations, and Applications", it refers to the code also enforcing that a right function pointer is used at each indirect call site. Each site has a list of allowed function pointers. WASM does not do this.
(Sorry for the long post but I just don't want people to get confused and believe that WASM is safer than it is)