4 ms·
I'm curious, can anyone recommend any techniques (or companies providing solutions) for attempting something similar with javascript in a browser calling an API
by hn_throwaway_99 6y ago
I'm curious, can anyone recommend any techniques (or companies providing solutions) for attempting something similar with javascript in a browser calling an API? Obviously it's much more difficult to obfuscate an algorithm for generating a client token in JS than it would be in assembly, but I'm just curious if anyone has tried any form of "lock down my API so it's only callable from the web front end I provide" obfuscation.
- nerdbaggy 6y agoWASM would be a good option I believe
- londons_explore 6y agoRecaptcha tries to do this. Their approach is to make a blob of code which collects all kinds of details about its environment (for example, Object.keys(window) ). It then uses a hash/concat of those details (with some random too) to decode data to decide what else to collect, hashes or concatenates those in too. Repeat a few times. Then send the final data blob back to the server. The server can then run a tiny emulator to run the code with the same seed random to check the results are the same on a whitelist of allowed environments.
- zelly 6y ago>"lock down my API so it's only callable from the web front end I provide" Generate secret tokens that the server can validate using some heavily obfuscated process. Compile the JS to WASM. If you can use HTTP3 or WebSockets that's a bonus, because you can create a custom protocol that does some secret handshake before sending the goods.
- the_duke 6y agoYou can study the Instagram or TikTok web versions for inspiration. Both use some wacky methods for request signing that include encrypted code, obfuscated control flow, hashing the browser environment, ... Assembly obviously allows for much more powerful obfuscation than Javascript. Webassembly is somewhere inbetween, but a viable path since it is pretty universally supported by now. Networks requests can be inspected trivially in the browser though, which makes things a lot easier.
- historyremade 6y agoOther methods out there to hide network requests in-browser.
- the_duke 6y agoSure, you could do all kinds of things. Using GET requests with a encrypted payload in the URL, websockets with some wacky custom protocol on top, WebRTC shenanigans, ... I haven't seen anything like that in the wild, though.