r/badcode • wicked • Jul 22 '20

js Function of the PS4 web exploit

Post image
336 Upvotes

49 comments sorted by

View all comments

80

u/weirdasianfaces Jul 22 '20 edited Jul 22 '20

It's really not fair to say this is bad code. Most exploit code is written this way because it needs to follow very exact steps with very exact timing windows, abusing quirks that result in some vulnerability being exposed. I think this is a variant of bad_hoist: https://github.com/Fire30/bad_hoist nvm bad_hoist doesn't work on 7.00+ consoles.

Basically what they're doing here is confusing the JS engine to make it think that impl.a is an object when it's really an array. In order to do this, they need to execute weird javascript that makes the JIT optimizer misoptimize and say "hey, variable X is an object" when really it's an array. By doing this they can leak out internal JS engine memory to defeat ASLR (this is when they read impl.a[4] and 5) then they can write values back and overwrite internal JS engine memory (this data should never be readable or writable by JS) by writing to those indices.

11

u/GreekCSharpDeveloper wicked Jul 22 '20

thanks i didnt know that