Hello, everyone. Hello, good night. Thanks a lot for your time. Thanks a lot for being here in this last talk. It's 7 p.m. It's a little bit late. And I appreciate your time. I'm Alejandro Hernandez. I will be presenting some interesting stuff that I have found in EEG technologies this last year. I would like to quickly introduce myself. I'm a consultant from IOactive. It's a security company. I do fuzzing. I love programming. I'm a security enthusiast. I've been for 12 years now in the security industry, in the hacking scene. I have a background from computer systems engineering. I didn't study any medical related career. Doctor of neuroscience or whatever. So I really apologize if I say something wrong technically in this because I started from scratch from just computer background in this new topic for me, right? So in this talk, I'm going to quickly start talking about neuroscience 101. What is EEG? What are brainwaves? And then we can jump into the insecurity aspects I have found in design, in cryptography, in authentication. And just the conclusions of this. This is not an invasive brain computer interface talk. So don't expect to be Johnny Mnemonic after this talk. So you remember Keanu Reeves using his brain as a hard drive, right? So this is not invasive. Sorry, if you expect to have a hard drive in your brain after this, this is not the talk. Why this talk? You might wonder why brainwaves? What's the purpose of this? Nowadays, we care about information security. Your mobile security, your car hacking, your internet of things. We put more attention in security of your coffee machine in your house or your fridge. But what about your bill signals? In this case, let's say EEG. What is the security in the acquisition, in the processing, in the storage and the transmission of your brainwaves to different digital mediums? So, this is very important for me. EEG tech is being adopted more and more. This is not only in clinical use nowadays. We will see some examples in a few minutes. Why is this becoming an important technology and we should and we must put security in that part. And sure, brain stuff is cool, isn't it? We've seen like a lot of movies recently, brain computer interfaces, so for me, playing a little bit with the brain and brainwaves is very interesting. Okay, in order to understand EEG technology, we need to understand where the waves come from, right? So basically, we have the outer layer of your brain. This is the cortex. And in there, there's many neurons, many connections between neurons, transmitting information, chemical information, electronic, electric information. And this information depends on the different regions of the brain. We have different lobes, the parietal lobes. The synapse has a different function. Every part of your brain is connected, is related to any of these different things, like sensory association, the smelling, the tasting, the motor things of your body. Neurons, they are connected between each other through electrical signals, chemical signals. And some of these signals, they are escaped between this synapse activity. And this is the things that we catch with EEG, with electroencephalography technologies, right? So, the synaptic activity is affected by external things, like if you have depression or if you are on drugs, on cocaine, or caffeine, or alcohol, your brain waves are different than from a baby sleeping, for example, right? In one year studying this new topic for me, I really understood why in the media, on Discovery Channel, they say that the human brain is super complex. After reading some books and a lot of articles on the internet, I found really complex information there. So, thank you neuroscience. They are doing really cool stuff in this area. Okay, what are brain waves? The brain waves, we need first to understand what's the difference between invasive and non-invasive computer interfaces. This is an implant here. This is the cortex of your brain. This is an electronic implant. This is invasive. And non-invasive is this electrode on your scalp, outside from your head. This is an active, an invasive brain computer interface. You have the implantation here in your head, and it's easier to get information from your brain, because you are getting information This is one of the most famous cases, BrainGate. This is the first woman controlling a mechanical arm, just thinking of the movements of the arm. On the other hand, we have the non-invasive technologies. The most famous one is EEG. EEG stands for electroencephalography. And basically are the electrodes in the scalp. And it looks like this. Basically it's the representation of the muscles, right? Represented over time. Now, this is a very easy to use method. It's been used in the clinical and the medical industry for years, for decades, in order to find different things that I will show you in a bit. However, the EEG technologies are susceptible to noise. I really like this quote from this famous neuroscience. John Donoghue, I don't know how to pronounce his last name, sorry. He said that current brain technologies is like trying to listen to a conversation in a football stadium from a blimp. A blimp is like this balloon flying over the stadium. That difficult is because your synaptic activity has to go through to the school, to different layers. So, in order to get a good EEG quality, you need amplifiers in between, encoders in between, filters, etc. Okay. This is, these are the main frequencies in brain waves. Every frequency is relaxed with different mind states. For example, the lower frequencies, theta, are for people who are completely sleeping or are really calm. On the other hand, you have like beta activity, which is when you're awake, when you're putting attention, you're like, oh, it's all you now. Thank you for your beta waves. Well, there are some standards in the industry, like this one, 1020 systems to put the electrodes in your scalp. This is very famous. So remember, the brain waves are analog. If you want to process it in computers, we need the ones and zeros, right? So we need to digitalize through amplifiers and converters. After we have the signals, they look like this. This is a real EEG recording. Every line is an electrode in your brain. You can find patterns. I mean, not you, not me, neuroscience people who study this, because the things that I see here, I don't understand. I only see waves. But, for example, there are doctors in neuroscience. I got a book by this book. This is basically an atlas. And inside, you might find interesting brain waves. Like I found, for example, a kid who had a lithium toxicity, and you can see his brain waves acting in a really weird way. I'll show you very quick. This is basically a big atlas. And they, the doctor, they explain you here what you can see in some cases. So it's very complex. And okay. This is the book that I showed you. Now, how did you acquire the brain waves? You can buy commercial hardware. I was talking with her a little bit, a few minutes ago. And she's agreed with me that it's very expensive hardware that is being used in hospitals, in the medical industry nowadays. Up to $1,000. However, there are these technologies being adopted and it's being implemented in these small devices. This is a mind wave. It's one of the cheapest ones. It's super simple. 100 bucks. And you have one electrode in your brain. I'll show you in a bit. On the other hand, you have the do it yourself. You have open source software. And there are many cool applications out there. Like really good stuff out there. Open EG, open BCI. This is the first demonstration. It's very quick. It's nothing complex. It's just the visualization of the brain waves. . So I'm very nervous and I'm sweating a little bit. So I'm not sure if it will get my brain activity now. It's turned on. I need to meditate a little bit. One sec. I think this is the hardest demo I've ever done. Seriously. This is the hardest demo I've ever done. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . to the car. In security, we know passwords. What about past thoughts? There is people doing research on this because they think that brain waves are unique to each individual. What could possibly go wrong if you can't do reply attacks, right? I will show you in a bit. There is people using EEG to identify cyber security threats in companies. Military use. Now they are using soldiers' thoughts to launch computer commands without human interaction, just their brain waves. This is a long-term research by the U.S. Army as well. They are showing to the soldiers different images. So they just see the images and they can find threatening scenarios after they put the results in the machine learning algorithm. They just see the pictures and perhaps in the future they will use the images to identify the threats. So they use this information to find potential threatening scenarios in the field. For relaxation, this is called neurofeedback. So you can control your breathing, control your mind. There are people like this Mexican, she is doing really cool stuff with art and EEG. She is doing art with some speakers, water and her brain waves. And she is using this information to jump off of YouTube, right? After we would use our brain, she is getting an investment of or something. This is the Может. This is an important case. I'm not sure about laws or regulations but now this murderer, this criminal, he defends, he ordered to do a quantitative EEG. So the result of an EEG scan could affect the outcome of the trial, right? People in video games. People doing their own ne where marketing to predict movie success. Neuraware, this is Alec act the old rule .. not likeッ™ it looks like this. Why is it so difficult? The this is really funny and really interesting thing is basically wearables with an EEG device. It has to be in Japan, right? So, based on their emotions, on their the EEG device is just basically measuring her attention levels or her relaxation levels, right? What about the 21st century Tinder? Like connecting people through that's real. That's completely real. What about surfers in the coast of Mexico? In Mexico doing neuroscience, scanning brain waves. Sending your brain waves to the cloud. Neuromore is a new application that takes your brain waves and uploading it to the cloud for further research for different purposes. So, what possible attack scenarios do we have here? We can do theoretically now because the technology is new. Theoretically we could do replay attacks. We could control things, drones, and to bypass authentication if we can do replay attacks. What about if there is an attacker in the hospital network. And you can unauthorized update the record of a criminal or patient in the network. Because of the lack of encryption they have authentication right? Or what about as there are spamers now treating 3000 email addresses. What about trading efficiently and proving your... knowledge when it's about transmission with curse and snare不錯? data for behavioral analysis in neuromarketing. I just had this random ideas but this, you know, it could be, they could be real scenarios in five years. What about client-side attacks? Like in this software that I showed you a few minutes ago, if you corrupt some data, some metadata of the brain waves files, you can exploit, you can find bugs in client-side applications. Okay, the first one, design. There are some applications that include security in the design of their products, of their software. They put authentication, encryption, for example, I quickly checked neuromore and I found that they are uploading the data to an SSL channel, which is good, right? But on the other hand, in the 90% of the manuals and the specifications and brochure that I read from many different vendors, many different companies, I look for specific keywords, like secure, to find words that are secure. I look for words like security or secure or crypt or authentication or password. And in no one of them, 90% they are not implementing security in their design, right? If we go to the further, if we go further in encryption, in transit, many technologies, many vendors are using TCPIP as their communication channel. So brain waves on the wire, what could possibly go wrong again? If you go to Google and you just look for neuro acquisition or your product name and TCP port, you will find different products supporting TCPIP. These applications, for example, Siesta, is an ambulatory EEG device in hospitals, so the patient has a Wi-Fi enabled application with this high tech security web, wireless, whatever. Could you imagine a really attack scenario there? Just someone cracking the Wi-Fi easily and sniffing the network there. I'm not sure if this product has encryption or not, but in many, many vendors put this information, like this technology enables your computer and all the computers in the land to easily connect to this and blah, blah, blah. They don't mention security or authentication or something, right? There are many different products. This is a specific case, the first case, Neuralectrics, it's a company based in Barcelona. They're doing really cool stuff in this area. And in their manual, you will see that this is the software. This is the hardware and when the software connects to the hardware, this middleware software opens a TCP port, one, two, three, four, and when it's ready, you just connect to the port and you will be receiving the information on the channels in a raw data, right? That means that if someone is connected to this cap, anyone else could connect to this port and just receiving their brain waves, right? Because there is no encryption in here. This is a library. It's a very used library nowadays for different applications, LSL. I read a little bit of their source code and basically they're sending and receiving data through binary variables. I mean, they're just sending the data on the wire. They're not encrypting. They're not decrypting. And time for a demo. In the following demo, I will be using this very old and unmaintained software. It's NeuroServer. It's very old but it's still in use nowadays because it's being adopted by some other applications like Brain Bay. Basically, it's a server on TCP IP using the EDF format. I will talk about EDF in a bit. The normal scenario is this. This is a server that is using this software, the mind wave device, and I will be sending my brain waves to the EDF server. Remember the IP address. 149, the host name Daria. This is the server. After that, there will be an attacker in the middle. This is another virtual machine. It's an IP 60, right? Since it's over TCP IP, that means that, you know, TCP IP doesn't have security in design. Authentication or encryption. So with a basic R poisoning that all of you know how to do really easily, you can basically sniff brain waves, right? I'll show you. So here I have my ARP table, not poisoned yet. In this computer, this is the NeuroServer. This is the attacker computer. This is the attacker computer. This is the brain wave. So now the man in the middle attack is taking place. Now you see they are poisoned. This is another program. It's called brain wave. So you can design different signalings and different things. In this case, this is the brain wave. In this case, I have this com reader connecting to the com5, which is my Bluetooth device talking to the brain wave, right? So I'm going to connect to the device. Now it's connected. It's ready to receive waves. So I'm going to connect to the device. So the output of this channel, I will send this output to this basic oscilloscope just to visualize the waves. But on the other hand, I use the TCP sender. The TCP sender is sending my brain waves to the NeuroServer, which is this IP address, patient name, Alejandro Hernandez, and some extra information like sampling rates, et cetera. So this is the brain wave. Let's see the NeuroServer is ready. And I start the session. So these are my brain waves now. I will connect to the server. It's connected. And I will start sending my brain waves. 3,000 packets, many packets sent. NeuroServer received my information here. So it works, right? But here the attacker is receiving a copy. This is just the protocol of the NeuroServer protocol. There are different protocols, there are different file formats. And these OKs are from NeuroServer. It's not encrypted. These numbers, these minus numbers are my brain waves, my signals. My going back and forth, et cetera. So this is just a demonstration, a book. There is still a lot of data. So I'm going to connect to encryption in the product. It's very easy just to do many attacks and to receive and decode in the proper file format or protocol. It's very easy. All you need to know is the information. This information is going through the edf file format so it's quite simple to decode this information. OK. It was a first demo for encryption. Now, encryption in REST. In REST, EG data is in files, like in PDF or in the files or Word documents there is no encryption. So also I was wondering what about the cloud? How are these companies protecting your brain waves in the cloud, right? And I had this idea to use Shodan and looking for net bills shares on the internet. Just looking for specific product names like brain vision or neuro server and yeah, there is people sharing brain waves there. What about authentication? If you don't have authentication, okay, we need authentication between first, when you connect to a port you need to supply something before start receiving the information, right? Also there should be authentication between the acquisition device and the other point. For example between this device and the drone. Otherwise there will be anyone else just connecting through the drone theoretically and taking control of the feed. If there is no authentication, right, there should be something in between, I don't know, a password, a hash, something, an authentication mechanism. This is another case. It's the same that I described to you before. Just connect to the TCP port and it works. And the following demo is changing the patient name in the middle attack in the same scenario. So I will send the patient name, Alejandro Hernandez. I'm going to send the patient name. But if there is an attacker in between, in the following demo I will be changing my name for just John Connor. In the neuro server we will be receiving this name. This is a proof of concept. This is just a nasty change. But you can modify brain waves. Remember brain waves are just bytes. Remember, they are just bytes. So imagine that you are sending brain waves to a server which hikes spikes or low spikes and there is an attacker in between modifying this information to send fake brain waves to the other point, right? It works. So in this example, I will run neuro server again and in the attacker side I will modify the hacking tool, the main in the middle tool, in order to modify on the fly this information. . Okay, so. . the session. This is my brain waves. I open the TCP sender. Look, patient name, Alejandro Hernandez. I'm going to send this information to this server. I connect to it and I start sending the information. It's working, right? Sending the packets and everything. However, the server received junk owner and the attacker has like yeah, patient name replaced. This is the attacker, the man in the middle. He could change the raw brain waves, the patient names or any other information in between, right? So this is because of the lack of authentication. Now, passing to the next topic, resilience. Resilience basically is the ability to support or to recover from adversity, in this case denial of service attacks. I was impressed when I had this idea using 90s techniques and it's still killing. Seriously. Creating sockets, 10,000 connections, TCP IP. You couldn't believe it. But most of the application I tested, they died. So in the following demos, this will be the scenario. I'll have the brain device here sending to the server. And it's over TCP. There are many clients. In this case, could be, I don't know, in the hospital, a monitor showing in real time the brain waves or a doctor or a physician with a handheld connecting to the server, seeing the patient data in real time as well. But if it crashes, no one of the clients will be able to see the information, right? So for the following demo, I will be using this software, OpenBive. It's acquisition server remote denial of service. This is a software for real time neurosciences and brain computer interfaces. So this is the acquisition server. I have to send the data to the server, say that I will be using the NeuroSky mindset driver that is connected on the port COM5. Okay. And that I will be receiving this information, the electrode information. I connect to the driver. I start. Now these are my brain signals. It's just saying that it's ready. It's working, right? All you have to do is connect to the TCP port 1024. What is this listening? And I will be using the second part of the software. It's just a designer. Like in brain bay, like something like brain bay, you have different objects here like file readers, signals, processors. In this case I have a computer that I'm going to connect to an acquisition client. It's connecting to the port 1024. And it's sending the output to an oscilloscope quickly. One second. Okay. Okay. Okay. Okay. Okay. Okay. Okay. Okay. Okay. Here we go. This is my real time signals. This is the server. Working. Accepting new connections, but if we launch a basic attack, check it and see. It's still working, right? Now I have a generator on the illuminating. I can connect to the MIDI account or everything else in the port 1024. generic port stressor connecting to this port and I will be doing 10,000 connections. This is a 90s technique. After a few seconds, boom. Cannot connect. This cannot connect anymore to the server. It's just stopped. So no one else could connect to the server. And this just died. The application died. So this is a software bug. It's a denial of service attack. So it worked. I have another example. This is from another company. I have this recorded. So TCP server. A lot of clients here. Cannot connect. Cannot connect to the server. This is the same attack in a different port, in a different TCP port that is listening this application and in no one of the ports you will be able to connect anymore. So the application just hang. You have to close it because just hang. And this is a proof of my bad English. Hang, hang. I can't remember the word. Another example. Neuro server. This is some EDF head that I did. I read the specification which is very simple. You just have to send a malformed packet. I killed the server by triggering this assertion in programming. This is why it's a good idea. It's a good practice not to include your assertion in your final products, any kind of software. You all know this, right? So it was very easy to kill this. So for this I just write the quick proof of concept code in Python. This is neuro server. This is my code. This is my code. I'm just open it with GDB which is the debugger for Linux so I can see what happened. I'm just open it with GDB which is the debugger for Linux so I can see what happened. And the code is very simple. All you have to do is just send a malformed EDF. EDF. Neural server remote denial of service sending the malformed packet. Neural server should be dead now connecting. Neural server is down. Yep. Denial of service. This is another one. It's a memory corruption vulnerability. I don't have time. I have just five minutes more. So I will go quickly. It's the same. You have a segmentation fault and we can see while I was at GDB I was able to see that it was because of the mem set. This is a boundary checking. It's a normal security bug. Software bug. This topic is very interesting. Tower of Babel. Perhaps many of you know the story of Tower of Babel. Basically in the story of this tower is that humanity we all spoke the same language. And the humans wanted to reach the sky. Wanted to reach God. They wanted to reach the sky. to talk. So they started to create the tower. But when God realized that, he was like, no, I don't want you to come here. So he changed their languages of many of them. This is the origin of the languages. This is why we speak like Spanish, English, broken English. And yes, remember, the origin of EEG technologies is from clinical perspective, from the medicine perspective. So there are different vendors, many different companies doing products, many different developers. So there are many compatible formats. Most of them use proprietary formats. There were some efforts to do standardization, but back in 92, it's an old format. I spent, it took me weeks, seriously, it took me weeks to go through brochures, manuals, specification, to do this Excel document. So this helped me a lot. I was able to do this for my research in order to identify which is the most used file format in EEG technology. So my conclusion was that EDF, most of the products support EDF and EDF plus. And of course, they're proprietary formats, right? So that said, I just went and played with different with EDF format. And remember, parsing is parsing. It's just like parsing any other things. Like PDF document, parsing a picture. Or basically bytes in data structure. That means that if you don't put security, you have the same risks as in any other kind of software. You are prone to buffer overflows, arithmetic calculations, especially here, because here you have a lot of multiplications, lot of division between frequencies, between number of channels. There are many, many arithmetic problems here. And how does this change the way we do the data? I'm going to however the attack surface is very reduced because this file format is not mainstream. You're not sharing data with your friend, right? But still the problem is there. And this is just like this feeling that I have that I think that developers in this industry come from a different background. It's not like us that we come from IT background that we know some secure programming. Perhaps they're not fully aware of secure programming and they're still using many string copy basic. I'm not telling that they're insecure. It was just a quick look. They're really good programmers. They're amazing, really good. But still there are some insecure functions. But I haven't had time to go through them and check if they're false positives or if they're secure. So I'm not telling that they're security bugs. So I did trivial fuzzing. Just basic fuzzing. Dumb fuzzing using mangle.c from a colleague of mine. I also use Microsoft. The test cases there is this network. It's just a bunch of files from different formats. EDF files from real people. From patients for research purposes. So you are able to download different data sets from here to play with. And this is my fuzzing. I don't know how to say. Schedule my fuzzing results. I did different. I played with different samples, different fuzzers, different headers according to the specification. Percentage and output. And it was not fun. You know why? Because in the first test cases, most application broke. It's not this. Fuzzing is not good. It's not good. It's not not interesting unless you leave your faucet working for hours, right? And in the end you come the next morning and it's like hell yeah, I found a bug. But this was not the case. I found like many segmentation faults, many potential memory corruption bugs. I will show you quickly some demonstration in some commercial products and some open source software. This is one of the most used application inside too by Persyst. It's one of the most complete applications. It has like a lot of file formats supporting from different proprietary vendors from different vendors. And yeah. So this is sick viewer. This is a sleeping EEG data. This is a basic. So you basically open a file, sleeping, it's loading and it works, right? If you open a corrupted file. This one is first. Boom, it died. Let me see another one. This one is second. This one is third. This one is fourth. So that one is fifth. This one is fourth and then this one is fifth. This one is first. So you things like that. some open source software. It's basic instability kits which you is very similar to the one I was talking about that the ODA Google Potential Manager product that they offer more than an additional life cycleバ fly out anyways. So it's another other fust. It's opening. Boom. It died. It crashed. There are many segmentation fusts. There are many vulnerabilities in parsing here. The bugs are still there, you know. But as I said before, the attack surface is very reduced. This is very important research. This is not my research. I just, but it's the word to mention. It's like these guys from Berkeley and Oxford and Geneva, they did this amazing research on the feasibility of side channel attacks in brain computer interfaces. So basically from their population, they put, they measured the brain waves from different people. And they showed to these people different pictures from different banks. And they were just watching the pictures. For example, bank A, bank B, bank C. But unconsciously, your brain waves behave differently if you see the logo of your bank or if you see your pin code or if you see people that you know. You know, you know that your neighborhood in a map. Right? And the outcome of this amazing research is this. That the entropy of the private information is decreased on the average by approximately 50 to 40 percent compared to random guessing attacks. So that's really, really cool. Right? Now if we jump to regulatory compliance best practices for EEG, who is in charge of it? Hypa or I'm not the regular regulations guy. I don't have any idea. I just found this information on the internet. Also the FDA, the food and drugs administration is working together with the cybersecurity community to improve the security in these technologies. I also went to this website. It's some guidelines by the American clinical neurophysiology society. However, the guidelines are dated 2006, 2008. And for example, and this one, guidelines for recording EEG on digital media that'll do mentioning magnetic storage. So in conclusion of all these things definitely we need to put more security in mind for brain signal team in acquisition, in storage, in transmission. We needed to put more efforts in file format for more secure programming practices. We need to create or update best practices for EDG. We have a new terrain to play with networking and parsing. If you have a drone and you're using it for research, just play with some replay attacks, try to sniff the data. What if you save your brain waves and you reply this to, I don't know, to your processes. Would it work? Definitely it would work. If you don't have authentication and encryption, it will work. You need to test your medical devices and so forth if you are a vendor. This is for the research, just some other random ideas that I had. What if you scan the internet with ZMap and you scan for the ports used by non-EDG acquisition software and hardware? I have found a couple of them. I won't tell you. I was just sniffing brain waves from someone in the internet. I was just getting the signals from there. It worked. It works. Or I was thinking the other day, let's say that ten years ago, no one was talking about SCADA or industrial security. Only a few guys were talking about SCADA hacking and blah, blah, blah ten years ago. Nowadays we have physical firewalls that goes with deep inspection through layer seven applications in SCADA. For example, Modbus. So they can go inside the protocol and detect potential attacks, potential malformed data. So what if we have the same biosignals, not only for brains, like for other kind of signals from your body. Biosignals are firewalls or IPS with the same level of inspection in the future. I don't know. I can imagine a future in hospitals where there are firewalls for this, that all the data back and forth, you know, from your body to the servers are going in the proper way. This is it. I hope you liked the presentation. Thank you.