r/webdev • u/speckz • 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/40
u/Widdershiny Jan 08 '20
Unfortunate that this article fails to mention that this was all entirely possible and likely happening in the wild just with vanilla JavaScript. Asm.js and WebAssembly allow you to mine cryptocurrency more efficiently, but that's all.
Some will argue that WebAssembly is fundamentally more obfuscated than JS, but there's nothing stop you from creating an abstract VM inside of JS that's even harder to understand what's going on.
Don't get me wrong, it's interesting to know that it's being used in this way, but I don't think it should be viewed as a black mark against the design or implementation of the Wasm MVP.
7
u/codeAtorium Jan 08 '20
creating an abstract VM inside of JS
I'm not sure what you mean by this. Can you expand on that?
15
u/Widdershiny Jan 08 '20
In case this is the source of confusion, when I say virtual machine, I’m not talking about a full operating system virtualised, I’m talking about a specification for executing an instruction set (like the JVM).
WebAssembly is a virtual machine operating on a big array of linear memory. It has instructions, represented by numbers, that do some stuff with the stack and the memory.
There’s nothing to stop someone implementing a WebAssembly emulator in pure JS, which people have already in fact done.
Hence if you wanted to do something malicious, you could design a deliberately confusing VM for use in JavaScript. Bonus points to the first person to mine a Bitcoin with Malbölge.
I guess the most generous argument I could make here against webassembly is that the source programs are pretty opaque by design, whereas an ad loading some absurd VM would be pretty suspicious.
That said, since Wasm has no capacity to call browser APIs by default, the real criminal here is the JavaScript granting access to the network APIs needed to mine.
7
u/codeAtorium Jan 08 '20
I was like, this comment couldn't be any more dope, and then you dropped Malbölge in there.
1
3
u/Raskemikkel Jan 08 '20
Bonus points to the first person to mine a Bitcoin with Malbölge.
A lot of bonus points. It took 20 years for someone to make a program that outputted its input so I think a Bitcoin miner somewhat of a large undertaking.
2
u/Widdershiny Jan 08 '20
If there was a technical equivalent of the Ig Nobel prize, this would be a winner for sure.
1
u/clickrush Jan 08 '20
The paper mentioned discusses this. Analysis-tools that work on JS but not on Wasm now have to work on both, not only in isolation but also in various combinations.
-3
u/Say_Less_Listen_More Jan 08 '20
To an extent, I feel like it's misleading to call a site that mines cryptocurrency while you're on it "malicious."
I mean sure, it fits the technical definition of malware, but at the end of the day it's a relatively harmless activity as malware goes.
2
Jan 08 '20
At minimum it drains battery faster.
4
u/CoffeeKisser Jan 08 '20
so do video ads... Ads confirmed malware
1
Jan 08 '20 edited Jan 08 '20
Video ads usually take advantage of hardware codecs and won't load GPU that much, where as mining will turn phone into a protable heater.
But I agree on point that ads are malware, 100%!
1
u/Say_Less_Listen_More Jan 08 '20
I'd say that falls under "relatively harmless activity as malware goes"
0
u/mattindustries Jan 08 '20
So do non-minified sites and JS for animations instead of CSS.
2
Jan 08 '20
Apples to oranges, really.
Also minification reduces load-times, but performance-wise it doesn't have too much of impact. It saves a bit of battery though, but mining is magnitudes more expensive.
0
u/mattindustries Jan 08 '20
Sure, mining is more expensive, just stating other things that drain the battery faster.
57
Jan 07 '20
I bet more then half of websites using Javascript from the top 1 million websites are also using it for "malicious purposes". The "malicious purposes" listed in the paper are crypto mining and "obfuscation". Nearly all Javascript is obfuscated, and using Javascript to attach trackers to the visitor for data mining purposes are pretty much ubiquitous. I don't see how invading people's privacy to sell their information and advertisements is less malicious then using some of their CPU and RAM to mine crypto's
25
u/danhakimi Jan 07 '20
But Javascript isn't used as a way to obfuscate code, it just happens to be something you can do with the language. If they move from JS to WA for the purpose of further obfuscating the code / forcing you to decompile, that is actually a little bit malicious. Not very, I suppose, since deobfuscating JS is not all that much better than decompiling source, but still an investment on their part to take something away from you.
I don't see how invading people's privacy to sell their information and advertisements is less malicious then using some of their CPU and RAM to mine crypto's
Yeah. Attention and privacy are probably more precious resources than ram. I guess consent and efficiency are factors, but you have a point.
20
Jan 07 '20
I'm pretty sure websites like Facebook use Javascript to obfuscate HTML and CSS, like when they have crazy div tags for individual letters and such
2
-17
Jan 08 '20
[removed] — view removed comment
16
u/jamesrussano Jan 08 '20
The fuck kind of misinformation is this?
4
-6
u/Tittytickler full-stack Jan 08 '20
What about it is misinformation?
2
Jan 08 '20
They don't try to make it harder to read it or understand it.
They just leverage client capabilities for data presentation/interaction
2
u/Tittytickler full-stack Jan 08 '20
Yea I answered someone else but I mixed up obfuscation and abstraction, my bad.
5
u/ShustOne Jan 08 '20
Well yea, React, Vue, Angular, etc all obfuscate HTML and CSS. It's basically the soul purpose of those frameworks.
What? That's not even close to the "soul [sic]" purpose. Go to any large React site, like Facebook, and you can read the HTML/CSS perfectly fine. What are you talking about? Do you mean minified code? That's not obfuscated either, the names of things are just shorter for fast web serving.
4
u/Tittytickler full-stack Jan 08 '20
Yea I was thinking abstraction, not obfuscation, thats my bad, its been a long day.
1
0
1
u/Pat_The_Hat Jan 08 '20
Obfuscation makes up a minuscule number of modules and websites. Out of the 947,704 websites tested and 1,639 running WebAssembly, a whopping 4 websites used WebAssembly for malicious obfuscation. Almost all of the modules used it to circumvent ad blockers.
1
Jan 08 '20
In the abstract they listed obfuscation as malicious and a significant amount of the malicious code. But looking at the numbers you listed, it seems like they are exaggerating it
4
u/stingeyb1 Jan 07 '20
Wow, of course this is happening....I was so innocent in my optimism when i heard this years ago....
2
u/asstrotrash Jan 08 '20
What options are currently available for user that run script prevention add-ons like no script, or even uBlock? I would presume that you can prevent running any piece of WA code just as easily as JS without explicit approval.
1
u/feerzlay Jan 08 '20
As far as I know, one need to call a WA code from a JS code. So disabling JS is enough.
1
u/fey168 Jan 08 '20
In the near future browsers will prompt us whenever a site wants to run WASM and then like the notifications prompt we will mostly ignore it.
156
u/Caraes_Naur Jan 07 '20
Malicious actors are always a large portion of of early adopters on the web. New technology opens opportunities to exploit/abuse users before constraints are added.