← All talks

Hacking GitHub Actions: Abusing GitHub and Azure for fun and profit

BSides Buffalo · 202353:0970 viewsPublished 2023-06Watch on YouTube ↗
Speakers
Tags
About this talk
More organizations are applying a DevOps methodology to optimize software development. One of the main tools used in this process is a continuous integration (CI) tool that automates code changes from multiple developers working on the same project. Multiple CI tools are available today, Jenkins, CircleCI, TravisCI, GitLab CI, and now GitHub Actions. In 2019, GitHub released its own CI tool called GitHub Actions (GHA). According to GitHub, GHA helps you automate tasks within your software development life cycle, and it has been gaining a lot of adoption from developers. This presentation results from detailed research on the topic where the author investigated abuse case scenarios, such as how attackers leveraged this free service to mine cryptocurrencies on their behalf and on behalf of other users, among other attack vectors. We’ll also demonstrate how to perform interactive commands to the Runner servers via reverse shell, which is technically not allowed via traditional means. Ultimately, we’ll show the problem of third-party dependencies via the GitHub Actions Marketplace. Finally, we’ll demonstrate how easy creating and publishing a fake GHA on the GitHub Marketplace is. And if used unwillingly by other projects, it can compromise the victim’s Runners to act as bots, target other victims, and even be used in supply-chain attacks by tampering with the result of the pipeline or even creating a botnet of crypto miners inside Azure. ABOUT THE SPEAKER: Magno Logan As an Information Security Specialist, Magno Logan specializes in various subjects, including Cloud, Container, Application Security Research, Threat Modeling, and Kubernetes Security. He boasts multiple international certifications and is a sought-after speaker at worldwide security conferences, presenting in countries such as Canada, the US, Brazil, and Europe. In addition to his professional accomplishments, Magno is the founder of the JampaSec Security Conference and the OWASP Paraiba Chapter. He has previously served as a Snyk Ambassador and member of the CNCF Security TAG, Kubernetes SIG Security, and OpenSSF.
Show transcript [en]

um thanks everyone for staying to the end um and and thank you for joining thanks for the organizers for b-sides for inviting me here uh my name is Magna Logan and today I will be talking about hacking GitHub actions abusing GitHub and Azure for Fun and Profit before we start just a little bit about myself I promise there's no malware on this QR code as the previous professenter ah yes sure but yeah my name is Magna Logan I'm originally from Brazil I've been in Canada for over five years now um I'm part of the nebula team which is a cloud and container security research team inside uh Trend Micro also based out of Ottawa as I mentioned

I also have a Blog called Katana security and I'm a partner at go hacking it's a cyber security training company out of Brazil um so just to start I'll show you some pictures and ask if this is Canada or us Canada or us maple syrup Canada hockey debatable Canada milk in a bag yes good sorry they were all Canada I know uh it's just to get your attention and of course to make you uh probably raise your awareness to the speaker as well so sorry about that and yes we tend to say sorry a lot I'm getting used to that uh to get my citizenship as well so yeah um but yeah as I mentioned

um just to start uh I'm a partner at go hacking which is a cyber security training company and one of my trainings it's about secure coding and devsecops uh were uh we're launching our training their lives and all live and online and we're launching this training and other ones in English as well uh primarily we are based out of Brazil as I mentioned so if you want to learn more it's a 40-hour training around uh secure coding static analysis Dynamic analysis and GitHub actions as well but in a builder kind of sense uh how to build your pipeline using GitHub actions so there's that and also before I start um I like to give back to the community

in a way and the way that I do that nowadays um it's basically helping people either get jobs or transition into their uh you know I.T or cyber security career so uh if you reach out to me if you want me to review your resume your LinkedIn or if you want to do a mock interview all completely free no strings attached just reach out to me and we can talk about it I do that and I've been doing that since uh since the pandemic since covet for uh mostly uh Brazilians back in Brazil but now I'm explaining that to anyone interested as well okay so this is what who here uh has heard about GitHub

actions actually okay a few people who here has heard about GitHub okay good so yeah uh I'm gonna give you an overview of GitHub actions how it works uh the syntax and what you can use it for um and then we're gonna dive deep into the security part and the research that I did uh during my my time at Trend Micro and doing this this kind of uh focusing on exploiting or how attackers can abuse GitHub actions for malicious purposes and how they're abusing it today to basically make free money uh so we're gonna talk about malicious actions like how can someone deploy a malicious actions to the marketplace and and compromise others some attacks and

abuses different options there and of course at the end I'll showcase uh some countermeasures and I'll give you a preview of a tool that I'm developing uh which is basically a static analysis for GitHub actions so that it can analyze your GitHub actions and attack if there is something suspicious or malicious in your emo files uh this stock is based out of these two main articles that I published on the Trend Micro blog so the first one they're talking about the runners which are the VMS that run inside uh Azure as GitHub is owned by Microsoft everything runs on Azure and the second one here to the right it's talking more about the crypto Miners and how attackers are

abusing these free cloud service compute service to my cryptocurrency okay so here's our overview every action every GitHub action think think about GitHub action as your CI right so similar to Jenkins which is more popular uh but but it's it's probably not as uh safe let's say there is an event so an event happens in your repository in your application code and that triggers your action that triggers your workflow right so an event inside your repository it can be like a pull request any changes to a file it can be a commit anything so there is a list of events uh uh in the documentation there I don't remember everything out of uh of the top of my head but some of the main

events it can be even triggered manually so workflow dispatch for example you can trigger your pipeline manually just like any any CI CI CD tool what happens when the event is triggered you have you have the the runner is deployed technically it's not deployed the runner which is the VM running on Azure it's already there so it gets assigned to run your workflow so at first when I was doing this research of course I didn't read the documentation I went straight to like Hands-On and I thought it was containers right so I thought okay it's run so fast because when I start my action it's already a sign and it's running my commands but no

it's a VN but it's not spun up as I start my workflow it's already there but it gets assigned so you Microsoft Azure GitHub they already have like some VMS ready to run your automation which is interesting um so every Runner think think of Runner as VMS every Runner will run jobs and jobs are a set of steps or strips or commands that you can uh Define in your workflow and your workflow it's basically a yaml file that you describe you define and you store that inside your application repo right and your specific location for that workflow file which is dot GitHub slash workflows with an S if you forget yes it doesn't work believe me I had this problem before

um but yeah inside your job as I said you can run different actions and actions this is where it gets interesting actions can run other actions so my action can call another action or a third-party action right so remember that this is going to be a problem later I can also run scripts like a shell script if I'm on Linux I can also run Powershell if I'm on windows so what's interesting about GitHub actions first that it's free for any GitHub user today of course the limits and if I'm not mistaken it's 30 hours per month per user for the free version and you can deploy your Runners can be Linux Mac OS or windows so you

can have these free options right the Linux is Ubuntu one but yeah um so in this example here this diagram we have another Runner which means that I have another job so another view VM will get assigned to to run this automation this job and by the way that it's being demonstrated on this diagram here you see that there is a connection between the event Runner run and Runner two what that means is Runner run or two depends on Runner one so Runner one needs to finish completing all the steps here from step one to step four for one or two to start doing their action that means that there is a dependency so technically when you have that the

output of the job one probably probably would be the input of job two right so you can have that that's not mandatory you can have jobs uh and Runners running parallel as well but also because of the the limits there is a limit on the amount of uh Runners that we can have running parallel depending on your license from GitHub any questions so far feel free to ask questions this is the last talk so ask away um one of the reasons I believe for the such great success of GitHub actions because it's getting a lot of attention lately most people that are and most people in organizations that are on GitHub they're either using actions

today or deciding to move to GitHub actions instead of their own CI because it takes away that uh that need to maintain a Genki server and maintain it up to date and updating plugins from Jenkins which is a pain for example um so one of the benefits is the marketplace as I said you can run actions from someone else so where do you get those actions that's on the marketplace the GitHub Marketplace for actions for example and this number is already outdated I got tired of updating this live because every time I present about this uh the name the number changes but it's almost at 19 000 today I just checked so anyone can write their own

actions and publish to the marketplace and the problem is that there is no security verification there is no validation of whoever publishes that in the marketplace or whatever is inside that action that emo file that automation that you make you can say oh yeah this is a automation to build your job application but then there is a back door inside there is no verification GitHub does nothing around that okay remember that um so here's just an example of an action that I got from the nuclei Dash scale it's used a lot today by bug Hunters as well to validate and find bugs um but just let's just understand the syntax here because this is going to be

important when I start showing you uh the malicious actions or the abusive actions as well so first we have name uh which is okay the name of Your Action that's pretty uh self-explanatory but then you have on they're on directive it's it's going to tell you when your action is going to run so here I have two on directives I have the schedule which is based on the like you like the Chrome tab for Linux but same way right so I specify there and I have the workflow dispatch which means that that action can run manually so anyone that has rights that that has the permissions inside that repo they can go there and click Start the section

and the pipeline will run that might be necessary for example in this case because you have like periodic scans but maybe your scan didn't run or you want to run a standalone scan for example an ad hoc that's where why you would need the workflow dispatch then you have jobs and in this this job jobs directive you only have one job that's called nuclei skin or nuclear skin and you see that the directive runs on that means which OS which category of os your Runner will be so I can have the Ubuntu latest which is the latest version of the OS for GitHub actions it's not the latest version of Ubuntu overall but only for GitHub actions and

then you have Ubuntu latest and Mac OS latest if you're running the runners provided by GitHub you can also run your deploy your own self-hosted Runners but then you'll pay for it steps that's where my automation my workflow really starts so the first step there it says uses actions slash checkout at V2 what that means that means it's using a third party action actions slash checkout where is that code coming from it's coming from a public repo from inside GitHub github.com actions slash checkout you can check that code right now it's public all GitHub actions code are public they should be public uh and the V2 is just a version of the release so uh you can

specify that as well so this is a third party action uh this this one specifically the actions username or organization this one is maintained by GitHub so everything that inside actions uh username it's maintained or published by GitHub but then you have a second action here with the name nuclei Dustin it uses project Discovery nuclei Dash action admin now that's another third party action from Project discovery which is the company that owns a nuclei and that's actually your automation your dash scan your validation right uh to check the application for vulnerabilities it's going to run here and you also have some parameters there with Target example.com that's basically the URL of your application it can be an IP address

right if you have like a development or keyword environment so that's also a third-party action um so if I stop there if my scan my automation runs my scan ran how do I know how do I get the results how do I get to scan results or the logs for the scan the problem is that after the workflow is finished I don't have access to that Runner anymore that VM that was deployed on Azure to run my automation it's only available during this automation once that's done it's cute I don't have access to that anymore so if I need to upload something that was generated during this automation I need to specify that I need to explicitly tell the

action to upload that back to GitHub and that's basically what it's doing on these two last actions two last steps here a workflow artifacts the first one is uploading the nuclei log so if there is something wrong with my scan I need to check the logs that's the first one there actions upload artifacts and and the last one is the results so it's a DOT serif file which is a common for security tools usually static analysis but nowadays Dynamic analysis as well basically with the findings from the nuclei scan because if I don't upload that and that's going to be available on my GitHub repo if I don't do that I'm not going to be able to see the results

any questions on the syntax of GitHub actions okay good okay so what are the problems here some of the vulnerabilities and this was when I started doing this research back at the end of 2021 there was only basically one reference which was the GitHub security Lab website I didn't find anything else into 2021 when I started doing this research so the three main problem

pound request what that means was that people were working the a repository they were changing the yaml file for the GitHub action to mine cryptocurrency and then they were sending the pull requests back to the original creator of that repo and so the automation was running when they sent send the pull request your automation started running and it started mining cryptocurrency but the bad user was the victim the original creator of that application of the open source repo and not the attacker right and so GitHub started that in a way uh enabling a feature uh that for someone to send a first pull request to a new repo to run the actions they need to be

approved so I'm going to talk about that in the counter measures so that it's uh this attack is kind of presented right now because by default this is disabled but there were like uh users forking like hundreds of reports repos changing their yaml files and then send it back to the original ones rejection if you are interested inputs so if you're dealing with the GitHub action there are some Fields inside inside your action that can be controlled by the user so should be considered untrusted validating the input system basic uh application uh coding secure coding hygiene so you need to be aware of that as well but the third one that was kind of the

main focus of my research is okay what happens because we're always talking about supply chain supply chain attacks okay what happens is I create a malicious GitHub action I make it seem it seem legitimate and I published The Marketplace and someone starts using that what what could happen so that was kind of the main topic of the research that I'm gonna talk about today so this is just an example I know it's not great because of the lighting just but I have other examples here this is the example from the forehead repos people were basically changing the yellow code to mine cryptocurrency and I have other uh examples there so and sending back to the original uh

maintainer okay here we're talking about abusing Windows Runners so the runner the virtual machine that's running inside azure what's happening here the last line is kind of okay the more interesting one more important one that's when I'm running the node.xc file which was inside that malicious Repository and it's basically a crypto Miner right a Monero crypto Miner you can see there action rig the pro and the username for that mining operation but the first uh red arrow there the uses uh Nick Envision slash retry at vichu is Nick here nope Nick okay that's a third-party action right we talk we say we talk about it use this Nick Envision at slash retry but that's a legitimate action I checked the code

for the action it's legitimate it's just to retry your action if your action fails retry your automation retry your workflow so attackers are already leveraging legitimate third-party actions for their mining for their mining purposes so that's happening today yeah so yeah I checked the the code as I said any GitHub action code is a public repo you can check the code uh it was just redirected to a new new name there but it's the same one so it's like okay we tries an action step on failure or timeout it's not malicious right they're using to kind of save time and it looks like the attacker is no more than us around the topic of GitHub

actions and of course the node.exe file that was there doing the crypto mining uh actions it's malicious right just checking it on virus total just an example yes it's malicious some other examples here with uh Windows Runners so it's still on the topic of Windows Runner I'm not sure if you can see very well there but now they're using Powershell you see the invoke web request expand archive these are all Powershell commands because it's running on a Windows box and if you look at that code Captain crypto that's the name of the action there I found the exact same code on over a hundred repositories so all of these and 100 more were the exact same demo code exact same

so attackers were creating different usernames automating their attack creating different repositories and mining cryptocurrency for free right getting money for free we've reported this to GitHub it took them about eight months to to reply back to us and some of these are even not uh taken down yet so I don't know I don't know what's going on there uh but yeah same example with Linux just different approach different commands but yeah at the end it's downloading the accent red and expanding the archive and starting the crypto mining attempt what's interesting is that every job can run for I think no every every job can run for up to 72 hours and every step can run for up to six hours so

that's why they they need some automation they need to restart it there are limits especially on the free accounts another thing that's interesting but it's not on this example this is a specific example here is that the crypto miners know that GitHub and Azure are onto them so in some of the instances that when they start the crypto mining there is a command on the XM rate to limit the CPU usage so the specific limit the CPUs is to 70 to avoid being detected right okay the CPU is not 100 okay it seems normal everything is fine let me get my free money right and recently uh more recently I found abusing Macos Runners which might not

seem that common but yeah it is so there was this repo here saying uh since the core book Hackintosh whatever um I couldn't read it it's sorry I think I believe it's Chinese so I couldn't read it but I can read the Yama file they should be the same so if you look at the yaml file you'll see that down there at the bottom runs on Mac OS latest and here it's basically same thing right giving the execution permissions to the XM rate and run it with the specified configurations and of course the XM rig no fee DJ is a natural binary um and I'm not an expert on doing Metro reverse engineering so I asked a few

friends take a look but yeah uh just virustoto as well is telling me yeah this is not legitimate this is malicious binary okay so if you go to a repository and you go to their actions tab you can see if you have permissions of course you can see how the history all the automations that they did all the the if there is a limit of course but if you see something like that if you see this kind of red banner red tag there means that the GitHub actions is currently disabled for that repo it's probably because they were doing something suspicious or malicious inside that repo the problem is that GitHub only blocks only disables

the action on that specific repo so if the same user creates another repository they can run actions again I don't know why that's how it works uh what is interesting during my analysis was okay what's running by default inside those Runners right there are some Services there are a bunch of tools that come screen stalled inside those VMS because right if you it's a build uh VM right you need to have if you Java python I don't know Docker you need to have all the stuff to install because you wanna you don't need to download it every time you run your automation but what's interesting is that there were three web services installed and one of them was active by default

so two of them were Akashi web server and nginx those were disabled by default but there was another one another one called Mono XSP web server has anyone heard about this web server it's very very old it's it's originally developed in ask.net whatever for Microsoft but they ported to Linux and this was inside the Ubuntu machine and it was enabled by default so yeah you can't find it very uh uh a lot of them exposed online on children but it was there this is from the documentation from the GitHub actions so you see that the mono access before is active and running on Port 8084. so I said okay what the hell is that I

don't know so I started digging I started doing some analysis as well um this is from the nmap scan okay yeah this is getting 500 errors I was able to download the code finding the version of the monoxide speed it's public it's a it was an open source project but even running some static analysis to find vulnerabilities on on the web server itself because it's so rude there are no like there are no tools or rules to specifically uh check for that interesting enough in the latest version now of Ubuntu this mono xsb is removed it's not installed anymore and it's not enabled by default uh I think it was something related to either like a health check or heartbeat

that Azure use it for but uh I'm not sure exactly I couldn't find out the real reason but it's there and I talked more about it on my on my blog post as well okay so the malicious GitHub actions I talked about anyone can post actions in the marketplace it's a kind of uh uh I don't know um it's basically there is no validation there is no verification right so you need to treat anything that you use from the marketplace you need to treat as a third-party dependency just like you do with your libraries from your code from your application third parties you need to treat actions as a third party dependency there is only one thing that GitHub does

that kind of gives you some sense of I don't know uh trust in that maintainer that person or organization that's publishing that action and that's that blue check mark there with the Creator verified by GitHub that's not like Twitter check mark that you pay for it you need some domain validation there but that's all they're doing they're not checking it for security they just validate the company if the company really owns that domain I think and that's it so there is no security checking involved as far as I know but as I said if you see the third party actions being called actions like checkout or actions slash setup node you can go to the URL right the URL is that

one github.com checkout and I can check that code if I understand it if I have a tool to help me out to scan that code sometimes the action code can be just a shell script or can be like a JavaScript node whatever so I can do some static analysis there as well so what kind of attacks can I do if I if I deploy a malicious action and either on my own on my own user or if I make someone else use my third party action that I publish on the marketplace I can run and map scans inside their Azure internal Network I can do the reverse shell from the runner to external server and I can use

that Runner it's a VM I can use that to Pivot and use to attack other targets either inside Azure or even outside because it has outbound connections so the the victim who see all the IP address is coming from Azure but they will never know it was me unless they request Azure for the logs or something like that [Music] so here's just in a map scan I know it's not good because of the lighting but but four ports were open fire ports were open by default 22 has a sage uh 80 HTTP for for free 3389 RDP and the 8084 the uh mono access V server right the the this was from the previous version so it

was there on every other and I saw the first one is my own Runner and the other ones are the ones that are idle waiting to be assigned to run the workflow so I did this and I can do the demo I think we have we'll have time basically what I did was okay what happens if I create a GitHub action that will connect back to my kind of situ commanding control server can I do that so that's what I did and I think we should move to the demo right now see to do hopefully that will work okay so here's my oops up there okay one second good security yeah maybe too much let's give it a minute

okay save file okay uh maybe I should switch to

where is the appearance let's switch to the okay light mode okay I guess that's better and now

okay so this was kind of the the basically one of the main ripples that I used throughout my whole research are the commutes all the stuff that I did it's there if you want to take a look but it's all there is there is no application here there is only the github.ub workflows for my automations and I have free emo files so anything inside this folder that has the dots Y and L or Y A and L A GitHub will try to run will think it's a GitHub action I will try to run so the first one that I have here is just a demonstration for the GitHub actions let me increase that font okay

okay so I'm deploying on Ubuntu latest and I'm just running some Linux commands here okay and you can see that it's on push the directive so any changes to this file or anything else in that repo will trick the automation so that means if I edit this file and let's see I'll remove just the New York here again besides Buffalo commit to main sorry for any developers here but once I do that if I go to my actions tab I see because of all the actions there are running on push all of them trigger at the same time so that's okay but the one that we want to take a look at is this one hello world.yml

let's see it's completed already and and this is kind of the console output similar to Jenkins if you're familiar with so these are the results ID Unit A F and hello so I see the ID here it the username is Runner and inside the docker group I can even sudo to that uh runner as well uh this is the your name Dash a so you can see that it's a Linux running on Azure and then the environment variables there is a ton of environment variables there is one that it's interesting here because it's Mass you see the three stars I can talk about that later and down at the bottom here you see the hello besides Buffalo okay this is just

a simple example but now the funny one the interesting one that I was talking about earlier is okay the second one here uh the NCR and netcat uh so same way I have on push jobs uh runs on Ubuntu latest besides Buffalo and what I'm doing here can ignore this let me add it basically what I'm doing here is downloading netcat from Source building and running netcat and this is the IP address for my uh C Chooser whatever you want to call it and that C2 server is on AWS so that's here let's see if I still have connection yeah uh 21 that's fine yeah 21. okay so that's uh my instance on AWS the

runner is running on Azure it will connect to my instance my EC tutor uh why did I build nightcat from scratch from Source anyone

because the one that is installed on Ubuntu doesn't allow me to do use the leverage Dash e functionality there are other ways to do that but I decided to go this way it seems simpler I just want to validate my assumptions okay so I run I change the file there let's see on the GitHub actions see this one is running so that's the one and C Dot yml and it's going to keep running because it's doing the uh the reverse shell to my ec2 right it's gonna keep running here until I stop so you're gonna see yeah running running and hopefully it'll work let's see yes okay Dash a so you see I'm inside my uh

increase the font here I'm inside my ec2 uh on AWS and I got a shell there from the runner so now I can run because technically you're not allowed to run interactive commands on your Runners right you have to change everything all those commands you have to set it up on the yaml file but now I can now I I found a way to speed up my research because now I can do that interactively right for the six hours timeout that I have so that should be enough time for a good work day that's enough uh but yeah it's there environment variables and all that stuff uh and the one that I was talking about

let's see if it's here

no it's not there yeah uh okay well it's Mass I'll talk about that later there is there is a GitHub token if it's there you should be there okay so now because I stopped I exited so now my my actions also failed stop that's fine but then okay what happens if now I'm calling the action directly right so this is working my action is calling my C2 server directly but what happens if I create a separate repository with that back door that reverse shell which is here this is my kind of me creating a third-party action right there is just the the fake GHA is just the the readme uh the action.am yml and the backdoor.sh which is basically

the same command and if I run that now let's say if I run that here let's go back to DHA test and I have another one that's the marketplace.yamo so you can see here that let's see

okay so now my gaj Dash test would call this third party action right this is the same way that we're calling other third-party actions so every time someone calls this fake GHA they would you know I would get a reverse shell on my my server my C2 so I could could do something there I could do the crypto mining it could do anything I want I could also make it less suspicious because yeah it's a fake GHA it has like the name of the fire backdoor daughter Sage I would probably not do that uh one thing that I didn't do though I didn't publish this to the marketplace because of legal reasons and because I

would probably would be without a job today but yeah uh I was not allowed I asked them even if it was just to do something like a echo hello the legal team said no right so we avoided doing that but since this is a separate repository and I'm calling this from another repository it's the same way it's a third party action so that would work as well and that it did work so it would get a shell in a similar way so let me go back any any questions yep go ahead a picture sorry as an end user do you have any way of protecting questions like my insurance shouldn't access the internet at all

um I found out about it in at Northside more trials a couple weeks ago that there are some ways to harvest your Runner so you can Harden it so there are some good party actions and stuff that you might be able to do that but by default as far as I know no okay so yeah basically this is what this slide is showing if the demo didn't work the reverse sound so I thought to myself okay since I can do the reverse shell from the runners to my servers I can also issue malicious commands from my servers to the runners right so I could start the crypto mining I could do other stuff I could even

collect all the environment variables there might be tokens there and there will be if you're using uh some sort of automation not just the GitHub token which was the one that was masked with the free stars there it's the token that gives you permissions from the runner to your repo so by default that used to have right permissions so if someone grabbed that token from your Runner they will be able to change anything in your repository now it's read only but still if you can give the right permissions if you need to if you have to um and yeah I can use that Runner so for 72 hours I have that VM the free version

the limit for the free version I have the VM to do anything I want so I can even attack other Targets on Azure or outside of azure so this is the slide for the third party action they're the one that I I didn't publish the marketplace but that I showcased right now same same thing back door I make it very clear that this is a malicious action right it's public it's a repo but it's not on the marketplace so if someone went to my username my my repository used that's their fault but yeah same Commander um just another example okay but how do you like as a user as a developer how do you check if your actions or third-party

actions are malicious or not there is no way today there is no scanner or static analysis through as far as I know that can scan your yaml file and detect something suspicious something malicious so what I'm presenting here today this is something new for for you guys I've presented this talk before but this is the first time that I'm talking about a tool to analyze your yaml files to scan your yaml files from your GitHub actions and find some something suspicious or malicious so I can do the demo uh but let me just explain how it works basically leveraging oppa which is open policy agent it's an open source tool Cloud native uh from the cncf the cloud native

Computing Foundation I can use the OPA syntax which is uh called Regal or legal language to write rules to analyze files so basically I wrote These are kind of the all the rules that I have today six rules to uh detect crypto mining malicious commands or Secrets or third-party actions and by using these rules and I'll do the demo in a second I can scan I can run it against my actions and the facts the first one is detecting a malicious Linux command and the second one means that okay this action is calling third-party actions right so it's still it might not be malicious but it's still a problem because I'm following third party so let

me go to the demo again and do this just to know that I'm not lying and uh I still haven't published this this uh project uh as a open source repo yet it's still private but I should publish that very soon I just I'm just writing a few more rules to you know to have it as a kind of I don't know have it make it I don't know uh useful so so let me increase the font there so yeah this is just oops still not working take some time see okay so yeah these are the six rules that I mentioned and let's see running commands running suspicious commands Linux so if I do that and I'm just gonna prove

that using oppa there is the how do I validate that is using oppa eval function and basically what I did was I uh I par I basically converted the emo file to a Json because that's how Opa interprets data inputs and I have my uh my query here the query.vigo is kind of the room that I created to validate this so when I run it here let me increase the font a little bit so you can see that by analyzing the yaml file which was converted to Json it found the suspicious minutes come in like I'm I'm doing a double Gap to an external Source inside my Runner so that might not be suspicious that might that might

be suspicious actually and I have one for crypto mining I have one for secrets for example uh for uh third party as well so let's see CD using third party action and the same same command so yeah it means that this this workflow is just an example a testing action but you can see that this workflow this action is calling two third-party actions the action slash checkout that we saw in the beginning and then the sneak slash action slash node because it's for running a sneak it doesn't mean that this is malicious but it's calling a third party right it's something to be aware of it's kind of a I don't know informational it could be but yeah the

plan is to release this I'm calling this uh GitHub action Sentinel for now we'll see and I'll should be releasing that as an open source really soon okay and with that no we're almost out of time so some counter measures oh wait okay yeah some countermeasures for for you to like take away from this stock and if you're just using actions as a developer uh only using actions for from trusted creators but be aware that trusted creators doesn't mean that it's being validated for security make sure that you set the right permissions to your actions like the least privileged principle right if you don't need right permissions to that token to modify stuff on your repo don't

give it right permissions do not run actions from forked repos that's kind of disabled by default now from GitHub and of course protect your secrets you're going to probably need to add more secrets more tokens inside your actions uh there is a way to do that in a safe way from GitHub but also protect those because if someone captures those Secrets they're usually API tokens and tokens that might give access to other tools that are using so that could be a problem so just some screenshots here if you're not using actions in any way in your organization or on your repo you can just disable it that would be the best way to do it and that's the one from the

42 request so for first try first time contributors someone contributing to your project for the first time it will not trigger any action will not trigger the automation avoiding that problem of 4K Pawn requests and yeah that's it I hope you enjoyed this talk and I'm uh open to any questions right now thank you

yep go ahead

okay yes so uh what Microsoft is doing around the abuse of of the runners and crypto mining um I think not a lot from what I've seen is basically a guacamole you know they try to block people block users but people create it's it's a free service right they can create a free account and just just generate another fake email I just need to bypass their captcha which is not that hard and then I can start mining again so from what I've seen um it's just a whack-a mode I don't see them doing from from an external perspective I don't know uh I have a few friends that work in the GitHub security team there but uh they couldn't disclose

more information but as far as I know I had this idea for this tool for analyzing malicious GitHub actions in 2021 and GitHub already listed that they were doing something with their code ql for scanning emo files and up until today they haven't they haven't done anything so I'm not sure if it's budget priority whatever so I decided okay I thought that GitHub would would create something like this and okay my tool would be useless but they didn't for two years basically so I said okay I might as well get it done then maybe that will motivate them to write some code QR rules so yeah any other questions okay I'll be around until the end of the

day we're pretty much wrapping up so thanks everyone thank you [Applause]