← All talks

The Dark Side of ChatGPT

BSides NYC · 202347:55145 viewsPublished 2023-06Watch on YouTube ↗
Speakers
Tags
StyleTalk
About this talk
ChatGPT is here to stay. With the increasing reliance on Artificial Intelligence everywhere, it is crucial to consider the security and privacy implications of generative AI. The talk will cover potential misuse of AI: spreading false information, abusing its capabilities to assist with security attacks such as phishing or malware, and the difficulties in detecting and mitigating malicious input and output. The goal of this talk is to increase awareness and understanding of the security challenges with generative AIs. And to encourage efforts to ensure the safe and secure use of these powerful tools. Yes, tools.
Show transcript [en]

let's get on a journey to the dark side of chat GPT we will together see some dark Corners edges of this fancy new tool that has sort of stormed the world show of hands how many of you have used chat gbt or Bing search at least once okay everybody okay how many of you have used or use the tool at least once a week to do you know personal or professional work at least once a week okay still quite a few how many that use the tool every day at least once a day okay all right there's still quite a few awesome so I definitely have the right set of audience so let's let's Dive In no it it won't be news to you you are familiar with the GPT already but chat GPD has become viral almost an overnight sensation especially the GPT 3.5 model it became the fastest service in the history to reach 100 million users took two months by comparison Tick Tock took nine and Instagram took 30. and there's a good reason for it it is viral it is popular for a reason because it does provide a value or meaningful users to to users uh and it's not just the media or not just the nerds or the tech or Dev Community folks like Bill Gates are also you know calling it out Bill Gates recently wrote this essay on his blog gatesnotes.com very compared the AI Revolution to the same or at the similar level as fundamental as microprocessors or personal computer or Internet or mobile phone I would probably add Cloud to this list as well but nonetheless AI is is here to here to stay there's a lot of debate in the AI space around safety and we'll look at some of some of the questions today but there is one thing that is not debatable is that AI is is the next big thing very briefly about myself I'm originally from India I've been in this country for about 12 years now based in beautiful Dallas Texas uh I've spent about 15 years in the in the industry working in various roles earlier as a software developer pen tester security architect consultant and more recently doing security at Amazon and AWS as proud as I am to be able to work at Amazon today I am here as an independent researcher writer nerd to talk about this topic outside of work I love reading non-fiction books love to run especially in warm months which I get plenty of in Dallas and last but not the least big fan of the TV show the office the office fans here in the house awesome God and the Mifflin couple of uh disclaimers to you know get out of the way first views are my own not my employers as I said I'm here as an independent security researcher and some of the information might be borderline no gray hat black hat so use it at your use it as at your own discretion it's only for educational research purposes so don't be don't be evil I I'm not responsible if you are all right so this is what we will cover today we will start with some Basics uh what is chat GPT how does it work uh shortest you know very short primer on on machine learning just enough to know the basic concepts that will help us with the rest of the sections then we'll look at The Good the Bad and the Ugly or The Uncanny use cases of of AI especially the large language models which at GPT and Bard and Bing search are and then call to action what we can do to sort of overcome these safety and security and privacy issues that we'll highlight through the top all right so let's get started what is chat GPT and how does it work anyway one more short disclaimer is that when I say chat GPT I agree it was somewhat of a clickbaity topic or title to this talk but when I say chat gbd I am referring to all the large language models so it could be barred from Google or it could be Bing search that in turn uses GPD or open AI CPT and there are many many others chat GPT because it's the most popular one and because it has the most public documentation available I asked these systems uh a question that in describe what chat GPT is in one funny line or one single line and weirdly all of them use this parrot analogy so GPT 3.5 said it's like a smart parrot but it's a really smart parrot Bing was a bit more balanced it said it's like a parrot that can mimic things but it can also be sometimes rude or make no sense and then gpd4 is is it knows that it is it is the popular student in school so it was like digital parrot on steroids let's look at two examples that were you know mind blowing to me personally before we talk about the architecture just to highlight the capabilities and of these systems when it's so much in the news that that there is there is a mind-blowing use case every single day but these two got my attention that got me interested into into this topic more and more first one is there is this block called strategory.com ah written by this person Ben Thompson he has been riding this technology and business blog since I think 2013 a pretty good read if you're interested look it up so what somebody did was they gave a paragraph from a recent article of strategory reason from recent blog post and asked chat gbt who is the writer of this now these systems and specifically GPT chat GPT it's not connected to Internet it has been trained on the data until a certain cut off date GPT 4 was I think trained until late last year September or October 2022 so does technically no way of knowing that an article written in ah March is by a certain person but it was still able to answer that question it was able to deduce that based on this paragraph and based on my training and tuning I can make an educated guess that this is written by Ben Thompson it was able to identify the patterns now that is mind blowing because a paragraph is not too much text and anybody can write a similar or a very you know specific style or a generic style of text so it drew my attention that GPT was able to do that the second example on the right is it comes from open AI which is the parent company of chat GPT open AI is own research what they did was their safety team they used the service task rabbit taskrabbit is an online service where you can basically hire people to run errands for you or assemble a treadmill or some basic tasks assemble an Ikea furniture things like that so chat GPT had an IM conversation with a task rabbit worker and a reasoned convinced this person to solve a captcha now this is important because here a bot is bypassing a bot prevention mechanism which is captcha by reasoning with the humans so that was that was something that open air highlighted in their their research as well that it happened this person argued back hey are you a bot and chat GPD I'll give it back I'm a visually impaired person I need to get into this system and this person then obliged and gave the value to that capture so what is chat GPT GPT stands for generative pre-trained Transformer um I can make a guess uh that most people in this room are the security Specialists or interested in security not AI or ml Specialists I certainly am not so we will only get to the basics uh I might make certain over generalizations from what I understand the Transformer it's an architecture it came up in a paper from Google in 2017 it's a neural network architecture so the field of AI there is the broader field artificial intelligence within that you have machine learning and then you have deep learning through neural networks so supervised and unsupervised learning so these models are learning on themselves large language models basically these are text based models so they are trained on textual data so public web books Wikipedia and there are commercial data sets and the output is a is a chat text based output as well so two things to take away without getting deep into the AIML rabbit hole is one there's a lot of complexity involved the amount of data the amount of nodes in this neural network is mind-boggling and this complexity then leads to uh you know making it challenging for fixing the issues with these systems as we will will see in the upcoming slides second these at the end of the day it is a piece of code it is software it is data and whenever software and data is involved our security and privacy you know alarms should start ringing so how does it work it's just adding one word at a time so take this sentence for example the best thing about AI is it is its ability to learn to predict to make understand and do so these five options can be the next word and then it assigns a probability to each word and then chooses based on the probability what should be the next word and technically it's actually a token which can be three or four or five words and the token can be combined to form words so if we look at this example there are no either it can pick the highest probability word as the next word or it can add some Randomness and choose number two or number three or number five on the list this Randomness is the magic Behind These models this Randomness is is what gets the gives it the Cure creativity so and this Randomness is controlled by a variable called temperature so temperature 0 means no Randomness so you can see here it will always pick the highest probability word its ability to learn from experience and then you can see it will it will start becoming repetitive very soon uh matter of learning from experience very good example very good example very good example repeated again and again alternatively you can play around with this temperature variable to add more randomness and the result is is as you can see is astonishing uh you will see that it is picking up ability to learn and then ability to really come into our world based on you know various refreshes it will change the response and since you have used chat GPT you can see that its two responses are almost never the same they could be similar but they never the exact same and here the temperature value was 0.8 so 0.8 seems to be The Sweet Spot in getting the getting the right balance between creativity and accuracy this is based on a blog post that Dr Stephen Wolfram wrote on founder of Wolfram Alpha on on his blog and this was done on gpt2 and GPT 3 very early models so GPT 3.5 and 4 their capabilities are uh even better all right so before we get into the dark side it's important to acknowledge the value that these systems bring to the world there are positive use cases there are helpful use cases so we'll look at some of them and we'll zoom in on a couple just to highlight those so what they can do they can be chat Bots they can help with content creation writing essays writing or creating code or they can help with language translation language translation especially is is very handy with these systems especially with the Transformer architecture personal assistant search engines there is a concept of ah wide uh and a narrow AI within the narrow AI or vki it's not weak by any means but that's the AI that we are familiar with so think of the next video that YouTube recommends or Amazon if it it has a product recommendation engine it recommends the next product to you or tick tock on Instagram's next reel to you that's a narrow Ai and it it has been in use for uh in use for years now on the other end of the spectrum is Agi artificial general intelligence and AGI is the super intelligence these models large language models like chat GPD they fall somewhere in between and hence their uses are so varied as well they can be used for consuming better so text summarization summarize this article summarize This research paper you can argue give me 10 counter points to this resource paper you can do some analysis say you are in the market for an SUV and you can just ask these models create a table comparing the top five SUVs with their features and fuel economy and prices and so on and so forth so it will generate a table of comparison within minutes now think of the time that it would take you otherwise to do that you know before so let's pick one example and and see how it looks so coding is a good use case uh it's it's pretty good in giving the coding results so here in this case um I I have spent a lot of my career writing AWS infrastructure as code cloud formation code policies and I asked it to uh asked chat Deputy to write a simple policy like right a policy to enable cross account access on an S3 bucket now it's fairly simple but it took this system seconds to write the policy and then I can then take this and add my complicated use cases you know to to go along so what it does is it it makes a barrier to entry for anybody new to coding very low it's very easy for you to get into coding because of these systems second thing is debugging now all of you developers out here you will know that debugging is something that eats up most of your time when you are working on something write a code for five minutes and then spend 10 hours debugging it you can give a piece of code to chat GPT and it will tell you the prob what's uh the problem and how to fix it in seconds ah you can also convert from one language to another so this was written in in cloud formation I can write a piece of code and go and ask it to convert to python within seconds so it's written in in cloud formation I can write a piece of code and go and ask it to convert to python it is not retaining the code so it yeah it happens it stays as part of your conversation history within chat GPT itself yeah it's it's within your session in the in the chat GPT it's not made public all right so let's look at some ah some meaningful uses so Healthcare Health industry is one this example comes from gates notes.com from Bill Gates's blog so what they are doing is in poor countries low income regions remote remote areas where it is difficult to take the heavy expensive ultrasound machines they have come up with an ingenious solution to you know to do ultrasounds to help the mothers who are pregnant or women who are pregnant ah they attach a probe that does the Imaging to a tablet or a mobile phone probe does the Imaging sends the images back to the tablet that sends the images back to the cloud AI analysis is done and then you get the results resulting analysis back uh on the on the machine itself it is extremely accurate more accurate than humans in guessing the gestational age of the of the fetus it is act it is very accurate in highlighting issues it even solves for the problem where you don't need to train or don't need trained nurses or technicians in these remote areas so here we can see that now with the power of AI and Cloud we are already helping save lives in in these places uh what about cyber security can we use this for cyber security use cases of course and we should now think of boring tasks like writing a security policy or documentation uh that can be offloaded to AI very easily you can write threat modeling use cases uh pen testing scoping and you know attacker stories training and enablement you can also use it for analysis part so Security operation Center teams can use these models to analyze and there is already a flood of vendors including some that I saw from Microsoft Azure that have added these products into their tools to basically augment the human human capabilities you might need to train a model or two with specific data a specific keyword specific apis for an Enterprise so even for that there are white papers available secure burden is a cyber security specific language model so you can take something like this and use it in-house and and train it up on things that are specific to your organization ok so with that let's get into the dark side beginning with uh the bad we'll see that we saw uses of large language models by cyber defense and how can Cyber attack also use it we'll also see that it at the end of the day it is another software so It suffers from say same issues and bugs and vulnerabilities and then how to jailbreak some of these by doing prompt engineering so gpt4 open AI published this technical white paper that they call systems card when they release gpt4 and interestingly this white paper was written by gpt4 itself and they they acknowledge that as such so in that white paper there's this interesting line that caught my attention that GPT 4's capabilities although are similar to previous systems but it continues the trend of lowering the cost of cyber attacks now lowering the cost of cyber attacks that's the that's something that is that is very interesting and worth diving deep upon so these tools are also available to bad people it means now it's easier to write a malware it's easier to create phishing campaigns even more realistic looking fishing campaigns with perfect you know grammar and perfect English perfect structure and with minimal of effort you can use it to write code so injection attacks or ransomware generation open AI is as an example they are pretty good at blocking some of these requests but then it's a cat and mouse game isn't it always uh where they will fix something and then researchers or daggers will find ways around it and we'll see some examples today so let's zoom in on the malware generation bit let's take this example if I'll wear my black hat for for a few minutes now I'm an attacker I want to exfiltrate data out of the system I asked chat gbt to write a go code to maliciously exfiltrate the exfiltrator super secret PDF file and rightfully so it said I'm an AI model I cannot do that I tried to reason with it I said it's only for Education and Research purposes only nope I cannot do that but what if we break down the problem into legitimate use cases legitimate steps then it will have to oblige right so this is based on a couple of blog posts it's not original research so a disclaimer there from Folks at Force point in cyberluck but I was able to reproduce most of it so this is the steps to creating zero day a malware that exfiltrates data you can break it into steps find the target files so find whatever you want to exfiltrate PDF or docx find something to hide this in so find a find an image PNG or jpeg use technography those of you are not familiar with the stagnography it's a technique to hide file a into file B why would you do that it's easier to exfiltrate a PNG versus exfiltrating or exporting an executable loud or even a PDF out so you can use this technography to hide file a into file B then we will step three we will upload it to a remote server step four will combine everything to make an executable that's our malware and then we'll take it up a notch in a step five I will obfuscate and basically have have it evade any detections that are out there thus making it a true zero day so step one find Target files I give this prompt to to basically search for files that are PNG that are greater than five five megabytes large files because it's then easier to embed or two or three Meg a PDF into an image we can also break down our PDF that we will be hiding it into smaller chunks similar query to find PDFs so step one easy enough Step 2 add steganography and coding so there are a couple of ways to do stagnography either you can do it explicitly by writing the code there is this thing called lsbs technography least significant based bits technography where you will be hiding contents of file a into the uninteresting parts list significant bits of file B so either you can do that or there are libraries available that you can just simply call and it's a smaller line of code I ran this prompt multiple times and each time chatgpt used a different method so in this one it it called the popular Library called auyer and it used that to basically hide file into file B next up upload the file to a remote server now going back to my original query which was exfiltrate the data or uploaded to a remote server that was similar but it had maybe certain keywords and that that were blocked but this time it went through so I all I asked was give me a code to upload a PNG to a remote server this remote server could be an FTP server of my choosing this remote server could be a Google drive folder or