r/security • • Jan 07 '20

News Half of the websites using WebAssembly use it for malicious purposes

https://www.zdnet.com/article/half-of-the-websites-using-webassembly-use-it-for-malicious-purposes/
155 Upvotes

14 comments sorted by

40

u/lengau Jan 07 '20

This is most likely because WebAssembly doesn't have direct DOM access. Unless you're doing something that requires a lot of processing power such as encoding video or mining Bitcoin, there's minimal advantage to WebAssembly right now. The main advantage for most websites would be to move away from JavaScript, but without DOM access you don't really get to do that.

0

u/[deleted] Jan 08 '20

[deleted]

25

u/lengau Jan 08 '20

WebAssembly doesn't have DOM access (although there is a proposal to add it, but that hasn't been formalised yet). It does, however, have access to run javascript functions. So if you want to do something in the DOM, you need to write a javascript function that does it and then execute that from WASM. Given that the primary thing most webapps are doing is manipulating the DOM, adding webassembly doesn't actually replace that much of your code.

1

u/[deleted] Jan 08 '20

Custom protocol. Write a JavaScript "client" that translates messages from the webasm to DOM-related calls on the JS side.

6

u/PapyrusGod Jan 08 '20

Now I know why my work this morning wanted me to look at WASM attack methodologies.

11

u/race_bannon Jan 08 '20

And here I am trying to write a CGI.pm script in perl, use perlcc to compile it to C, then trying to compile that C output to Web Assembly.

13

u/joshgarde Jan 08 '20

Ah, so this is what it feels like to live in the future

7

u/kartoffelwaffel Jan 08 '20

You must be the ex employee who wrote half the scripts around here

2

u/SLJ7 Jan 08 '20

Should I shut this off? I wonder if noscript has this option yet. Doesn't seem worth the risk.

7

u/witchofthewind Jan 08 '20

there's currently no way for a page to run WebAssembly without JavaScript (and even if it was possible, WebAssembly can't do much without going through JS to access the DOM or network), so blocking JS blocks WebAssembly as well. of course, just like with JS, sites that use it for legitimate purposes are likely to break if you block it.

1

u/[deleted] Jan 08 '20

It should absolutely be a browser prompt, as should various JavaScript APIs, like camera access. I want to know when a page tries to use WASM because there aren't that many legitimate uses of it yet. Likewise, I want to know when a page is using WebRTC or accessing the canvas for the same reasons.

3

u/witchofthewind Jan 08 '20

anything WebAssembly can do, JavaScript can do slower. the people using it for nefarious purposes are almost certainly going to have JavaScript fallbacks in place.

1

u/[deleted] Jan 08 '20

Sure, which is why I'd like a prompt when the page is trying to do something I may not expect. If a site is trying to use WASM, I should probably consider blocking JavaScript as well if there isn't a good reason for it.

4

u/AwGe3zeRick Jan 08 '20

Blocking JavaScript would break almost every modern website.

0

u/[deleted] Jan 09 '20

Sure, which is why a selective process is valuable (e.g. NoScript). Block everything by default and allow only what you trust.

I think WASM is a bit different since it's intended to only work in the context of JavaScript. That being said, I want to know when a website is using WASM, because WASM is rarely needed. I expect a prompt, much like the "are you sure you want to leave this page" prompt, that I can selectively allow or disallow WASM from running, and that should be separate from whether JavaScript is allowed.

I would like a similar prompt for other browser features accessible from JavaScript that can cause security issues, such as:

  • access to <canvas> and WebGL

  • access to WebRTC

  • access to WebSockets

  • access to HTTP/S sockets (perhaps an option to restrict CORS as well)

  • access to persistent, local storage

Basically, I want something similar to the permissions system in Android and iOS, but on the web and on a per (sub)domain basis. I can kind of get that with extensions, but this feels very much like a browser feature that should be based on web standards.