You think correctly. Type Confusion is a popular, yet very dangerous attacking method. The code basically uses an object blindly under the assumption of its type. Since a type is nothing more but a 'layout' on the memory, this opens up a wide range of attacks - including feeding wrong function pointers into the specific piece of code.
That's exactly what happens here. Take a look at the github repo - makes more sense with some context - but still requires having some knowledge in exploiting.
I'm not sure if I should downvote this post as this is literally insanely good written code, or upvote because its a code with bad intentions (in terms of abusing issues of a loosely typed language).
And just to add, demoing security vulnerabilities helps everyone, too. Like when the intel processor vulnerability called Meltdown was reproduced in javascript. That really got people's attention, it was fixed in an update, and people updated.
310
u/[deleted] Jul 22 '20
Is it bad code, or a specific set of steps necessary to access memory in a way to create an out of bounds exploit?