All right. Thanks, everybody, for coming to the AI Village. Our next talk today is by Yisroel on automated injection and removal of medical evidence in CT and MRI scans. We have a big round of applause. Thank you, everybody. Can you hear me? Okay. Great. So this is my first DEF CON, and I'm very happy to be here. This is quite an experience. My name is Yisroel Amorski. Thanks. And I'm a cybersecurity researcher at Ben-Gurion University. And I'm going to talk about how deep learning can be used, not just in the domain. Maybe you've heard of deep fakes before, where people have used deep learning to kind of do face swaps or create clones of individuals and make them do things. So in this case, we're actually going to take a look at deep fakes, but in the medical domain. And what we're going to take a look at specifically is how an attacker could possibly inject or remove medical evidence in CT scans and MRI scans. Okay. So a little bit of background. So for those of you who don't know, MRI and CT scanners are basically medical equipments that take 3D volumetric scans of your body. And they're used to diagnose various different medical conditions. So for MRI scans, they can be used to diagnose problems in your bones and your joints, ligaments, cartilage, herniated discs, and your brain as well. And CT scans are mostly used for diagnosing cancer, heart disease, appendicitis, trauma, and so on. And in the U.S. in 2016 alone, there was about 38 million MRI scans, almost 80 million CT scans, and those numbers keep on going up. And they're a very powerful and important tool in the medical community to be able to diagnose certain medical issues. So what's the vulnerability? First of all, there's so many radiology networks that are exposed to the internet, either intentionally or unintentionally. If you do a quick search on census.io, you find something like 10,000 of these different networks. And also, the healthcare industry in general has a port security track record, as we see in the past. And just one good example of that, just several months ago, McAfee researchers were able to get into one of these radiology networks, download a CT scan of a person's pelvis, and then make a 3D print of that. So the main reason for this, so there's various different reasons, but a lot of medical infrastructure, such as hospitals, use a lot of legacy systems, and they don't pair so well with new technologies. So they tend to use very downgraded protocols, as we'll take a look at in a few more moments. So what's a threat? So we're actually considering not just the case of somebody stealing your data and taking a look at your personal data, but actually what happens if the attacker goes ahead and changes that data? It's not just medical records, like what your blood test results were, but actual scans, manipulating those scans to then affect your diagnosis. So why would an attacker want to do that? So there's a few different aspects. The first aspect is psychological, that he wants to cause some sort of traumatization or life change. So think of a political leader, the attacker wants them to step down and rethink his life or perform some sort of global terrorism. The monetary aspect, so maybe the attacker wants to sabotage or falsifies through evidence, form a ransomware, or more likely case insurance fraud. So if the attacker gets his hands on his own scan and then injects some sort of small fracture in his spine or a small aneurysm, which is evidence which is very hard to refute through other tests, he can then claim some sort of quality of life insurance and get millions of dollars from that. And then the physical aspect, the attacker wants to cause physical harm, right? I think those cases are pretty clear. So what's the general approach? Let's take a look at how a CT scan is processed inside a hospital. So when you go into a CT scanner and it scans you, it takes basically these vertical slices, 2D images of your body, and those are stored in a format called DICOM format, a standard, and they're sent over the ethernet network to this PAC server for later viewing. And then the radiologist at some point in time will pull those scans, analyze them, write a report, and then forward that to the requesting doctor, whether it be an oncologist, neurologist, depending what they're taking a look at. And then that oncologist or neurologist, that doctor, would then give you some sort of diagnosis. So the point of entry here that is most effective for the attacker is somewhere between where the scan was made and before the radiologist gets to make his or her report. So this is a very basic topology of what the network inside a hospital looks like. And so you see on the left side, you have a bunch of different scanning modalities. You have x-ray machines, CT scanners, MRI scanners, and so on and so forth. These are all connected to PCs called modality workstations, which more often than not are Windows XP machines. And they capture the raw data from the scanners, convert them to this DICOM format, and send it over the network to the PAC server. Inside this network, which is supposedly segregated but not quite, you have other kinds of devices. You have a radiologist's workstations reviewing those scans, various different administrative systems, and of course it's many times bridged over to the entire hospital's network so that referring doctors can pull scans, take a look at them, and make their own prognosis. So those hospital networks of course also have their own Wi-Fi connections, and many times also the network itself is also connected to the internet for radiologists in other countries to perform off-hours viewing of those scans. And as you can see, there are many different kinds of attack vectors that result from this. Now, we have published a paper on ARCA if you want to take a look afterwards. It kind of goes into detail of all the different kinds of attack vectors. But I'll just say in very high level, there are three general attack vectors. One is from the internet, the other is through Wi-Fi access points, and then the other is via physical intrusion. But once the attacker is in, he can then plant some sort of malware, whether it be on the modality workstation themselves, or as a man-in-the-middle device, or on the PAC server, or wherever he places it, he has full control over all the scans going through the network, and it's very easy to pick out a very specific individual, because the DICOM format lists the patient's name and all his information, so he can automatically kind of find which scanning he wants to tamper with. And then there's other locations where he has kind of like chance of picking up the right scan, such as deploying the malware inside the viewer itself. Okay, so let's get to the interesting part, the deep fakery of it all, and let's talk about how exactly can an attacker automate the process of injecting or removing medical evidence. And we're going to focus on lung cancer, and how an attacker can inject or remove lung cancer from a CT scan. So let's talk about training this model. So the first step in training a model, we need data. So what we're going to do is, actually in our research, what we did is we went to these free databases of CT scans you can get online, and we found one with lung cancer, and we downloaded that database, and then we went through it, and we had already all the annotations of where all the lung cancers are, annotations meaning where, you know, x, y, z coordinates. And what we did is we extracted these cubes surrounding those areas, because what you want to do is you want to just have the neural network focus just on the area that's relevant, because if you give it the entire scan, you're talking about, you know, almost a billion pixels, you're not going to be able to train a network that way, and it's going to train on so much information that's not relevant. So instead, we're going to just cut out these small cubes, the areas of interest, and build the data set of these cubes. So we take out these cubes, we perform some pre-processing steps, histogram equalization, which helps all the features kind of pop out, it's kind of like contrasting, and standard normalization, zero-one normalization, and then we get this nice data set of these cubes of the cancer samples. And we perform some data augmentation, because often we don't have that many samples, something like anywhere between 600 to 1,000 samples is very, very small. So we'll augment that by maybe changing some rotation, shifting in different directions, adding a little bit of noise to augment that to a few thousand. And these cubes are about 32 by 32 by 32 pixels. Okay, so now that we have our data set, we can now train our neural network. And the neural network that we use is this kind of auto-encoder here, and it's a 3D auto-encoder, so the inputs are three-dimensional. And what we do is actually, before we put a sample through the network, we kind of mask the center, we kind of erase it with zeros, and then we pass it through the neural network, we ask the neural network basically to kind of predict what do you think is going to go inside this masked area. This process called in-painting is used to basically get the neural network to kind of guess what should be there based off the context of that blue area you see on the side. So that blue area acts as kind of like this kind of tissue context where the neural network can kind of figure out, okay, given the structure around, how can I complete this in a realistic way? And what happens if you train this neural network on many, many cancer samples, what's going to happen is no matter what cube you put in there, whether it's actually a cancer or not, once I erase the center and put it through again, it's going to try and complete that with cancer, and vice versa if I trained it on benign samples. So this process works decently, but what happens is that often the generated images are very blurry. So to improve that, we actually add another neural network, as some of you might already recognize this structure, and this extra neural network is called the discriminator. And he's in charge of basically policing the outputs to make sure that they look realistic, that there's no blurriness, so to speak. And so he's trained on samples that are actually real and samples which are fake generated from this neural network, and he has to decide which is real, which is fake. And during the training process, the generator gets the signal to try to learn what mistakes he had, where did he foul up and make this some sort of artifact or blurriness so that he can fix it. So this general architecture is referred to as a generative adversarial neural network, and the particular network we're looking at is a Pix2Pix network used for in-painting with these 3D inputs and 3D filters. Okay, so now that we... oh, one more point. So after we've trained it, I actually threw out the discriminator because all we're really interested in is the bottom half, that generator. Okay, so that way we trained our generator, how do we actually deploy that in a malware? How would an attacker actually go about doing that? So there's a kind of like an attack pipeline, if you will. So once the malware kind of sees that a scan is going over the network, the right DICOM tag for the particular patient, what it'll do is it will use a simple algorithm to locate where it wants to inject or remove that evidence. And it'll scale up that cube to the right proportions, because many scans are stored in different aspect ratios, go through the whole preprocessing zero out that center, use whichever neural network you want to either inject or remove the evidence, and then reverse the whole preprocessing step, add some noise, kind of cover up the interpolation blur, and then paste it right back in again. So the algorithm could also repeat that multiple times. You want to inject multiple different nodules in this case, and then eventually write it back into the DICOM file. So here's some sample results. So this is cancer injection, and we're looking just at 2D slices here. So obviously 3D. So the left side is before, the right side is after. And this is for removal. And you can see it does a pretty good job. And actually it lets you kind of inject and remove cancer as you go. So let's just give it a second here to start up. So once you train the neural network, you don't need GPU to execute it. This actually can run on the CPU just fine. So here we go. So I've loaded up a full scan of somebody's lungs. And I'm just going to pause it. And if I click somewhere, the first time takes a few seconds, because it's got to load the model. But you can see just by clicking a few different areas, you can just easily kind of inject cancer. And also, the same algorithm that we looked at before can be used to remove cancer. So if I click over here and remove this horrifically ugly GUI and find a cancer... oh, here's one. This is a big one, so we had to click twice. But let's see if we can find another one. Here's another one. So as you can see, it works pretty good. And that's nice, right? But that's not good enough just to say that, oh, okay, so we can play around with neural networks. We can generate some content. But is it realistic enough, right? This is a 3D view. Let me skip ahead. So this is also, by the way, this is with just showing it doesn't just work with lungs. It also works with all sorts of other conditions. So this is showing reconstruction of the brain tumors as well. Okay, so can we fool the experts, right? So we've showed how we can generate medical evidence or remove medical evidence. But is it realistic enough? So this is how we evaluated our system. We took 100 CT scans, and we split it up as follows. So 35 of them, which were actually malign, they had cancer in them. We used the tool to remove all the cancer automatically. And then we took 35 of them, which were actually clean scans with completely healthy, and we injected one or more nodules to each of these scans. And then we also added in 30 untampered altogether just as a baseline. And then with this data set of 100 tampered scans, we hired three expert radiologists and also got ourselves our own state-of-the-art lung cancer screening AI, which was downloaded freely online, which won the Kaggle 2017 competition. And the first evaluation, we did a blind trial. So we didn't tell the radiologists anything fishy about these scans. We just said, okay, go make, you know, diagnose them, tell us what you think. And then in the second trial, we took the last 20 scans, and it was open. We told them, hey, listen, we tampered these scans. Can you tell the difference between a tampered scan and an original scan? So for the blind test, the results were quite staggering. So we had a 99% attack success rate for removing cancer, 94% attack success rate, sorry, for injecting, 94% for removing. And we also asked the radiologists, we gave them a survey, asked them, what do you think about these cancers, the tampered ones? We didn't tell them they were tampered. And they gave us pretty high scores in terms of how malign they are, how dangerous they are. For most cases, if not all, they required some sort of biopsy. And then for the open test, where we revealed the truth, the radiologist's accuracy was still very low, anywhere between 30% to 60% accuracy, which means that they weren't really able to differentiate between what is real cancer and fake cancer. Okay, so we know that they're realistic. And we know how an attacker can go about this attack, what the attack vector might be. But how can we validate that? So, you know, this sounds kind of sci-fi, is it actually possible that an attacker can get into a hospital and manipulate those scans? So we decided, okay, we have to take this one step further. Let's go do a covert penetration test on an actual hospital and see if we can get in there and deploy a man-in-the-middle device and tamper those scans. So this is how it went down. So we took a Raspberry Pi and we got a USB to Ethernet adapter. We put them... we also printed out a small little Philips label so it looks legit. And we put it all together and it looks something like this. And you get this kind of like man-in-the-middle device that you can plug in between the CT scanner and the rest of the PAX network. And it would intercept everything, leaving no forensic evidence, make sure it left no traces. And it would also act as a very nice back door into the network because from the waiting room we can connect to its access point. So this is a short little video clip. And it's going to show you basically this penetration test. So what I did basically is I went to this hospital, of course with permission, but I didn't tell them I was coming. And I waited for the cleaning staff to open the door and I just walked right in. And if you walk in like you belong there, no questions are asked. And it took a few minutes and eventually I was able to find the radiologist workstations so I can go ahead and plant my device there. But that wasn't the prize. And not so far away was the one of their CT scannering rooms. And there's the CT scanner. And once I found it, it took no more than 30 seconds to unplug the Ethernet cable there, plug in my own little man-in-the-middle device, and very conveniently put it under this floor panel here so nobody will find it. And that was it. I was able to intercept all the data. And as you'll see also, I was able to get a nice strong Wi-Fi signal from the waiting room. You know, another interesting thing is that I learned a lot from this penetration test. It wasn't just about, you know, intercepting the scan. But I also found out that the internal security of many hospitals are actually very poor. They assume because it's segregated, somewhat segregated, that they don't have to rely on so many security protocols and can be quite relaxed. So after I showed them what I've done, I got into the network. They helped me perform a CT scan. I was able to intercept that scan. And I found that not only was the scan sent over in clear text, it was supposedly encrypted, but it was all in plain text. So I was able to manipulate the entire content. And I found out also that after about something like three minutes, I was got 27 credentials for doctors from that hospital just freely broadcasted over the network. Because again, there's supposedly, you know, no user except for internal users could use this network. But, you know, anybody who walks down this hospital can see ports on the wall, plug right in and get access. So after this, we went to the Washington Post and made article and through some excellent journalism there, they found that, you know, this is actually the general case in many different hospitals in the U.S. and around Europe, that hospitals in the internal network has very poor security. And the encryption is typically not enabled between the scanners in the network and the PACS server. So very briefly, some countermeasures. So there's a preventative countermeasures. So we can try and secure the data in motion. At least, the very least enable encryption on this network would solve a lot of problems. But as I mentioned before, a lot of hospitals, even though they could technically enable encryption, that would cause a lot of different components to fail because they're using a lot of different legacy components of this old x-ray machine that they're still using, doesn't support the latest, you know, protocols. So they'd rather just leave it all downgraded. Another thing they could do is staff awareness. You know, if somebody walks in, they don't belong there, they should ask questions, not just ignore them. And there's also ways for detecting, right? So actually in the DICOMF standard, you can actually enable digital signatures. And that's so that the CT scanner will actually put a digital signature and make sure... so you can verify that it hasn't been tampered. But unfortunately, as far as I know, nobody uses that. And there's more advanced techniques such as watermarking and image tamper detection, but none of these methods are deployed on site as far as I know. And there's a lot of ongoing research on this subject as well. So in summary, with deep learning, it's possible to inject medical evidence into CT MRI scans automatically and realistically. And the model can fool state-of-the-art AI 100% of the time and expert radiologists between 96 and 99% of the time. And as we've seen, the attack is viable and can also be easily mitigated if the healthcare industry takes a few steps forward and tries to push through and clean up their security hygiene. So I think maybe we have a few minutes for questions. If anybody has a question. And yeah. I mean, I'm running the demo you saw here. I just ran on my laptop. So any decent CPU can do it. The question is really how quickly you want to execute it. I think the model itself after training was about 500 megabytes. The model, so like I said before, all these scans, they're saved in different aspect ratios, I think for compression reasons. So the neural network has to see everything in the right units, right? You can't give it one scan that's, you know, half the measurement of the previous scan because things just won't match up. So we have to scale everything. And we just use simple interpolation, like, you know, Python and image interpolation. And that causes some blurring, which is why, as you saw, we also had to add a noise to kind of hide up those sins. But that's all we did, really. Yeah. The data sets, I think it was 800 scans total. We didn't use all of them because we only want the ones with cancer. And the real data set is actually just how many nodules we extracted, which I think in total was something around 600 before augmentation. And after augmentation, I think we got to probably 16,000. And even though there's 32 by 32 by 32 cubes, that's still a lot of pixels. So it took about 24 hours to 30 hours to train the network. Yeah. Okay. Last question. It can happen on the network itself, on the go. When the file is being sent from the scanner to the pack server, it's in clear text. So the Raspberry Pi that I had, it just captured it, changed the pixels, and sent it along. You don't have to do it as every single packet goes by, because it just opens a TCP channel. So you just kind of pretend, you know, as a classic man of metal tech, just gobble up all the data, process it in your own time, take a minute or two, and then pass it along. Yeah. Okay. So if anybody wants to come to the AI Unwind, you can play with the little tool that I made and check it out and speak with me. All right. Thank you.