I'm going to introduce you to our next speaker. He's currently working as application security engineer at global.com, which is a news media and TV network from Brazil. He has OSCP and OSC certifications, jumped into soft engineering to help develop teams improve the quality of their code by finding vulnerabilities as soon as possible. He's very interested in development, exploit development and building security tools to automate the process of security issues during the SDOC or CICD, you choose. His presentation is going to be about Husky CI, finding security flaws in CI before deploying them. Give a round of applause to Rafael Santos. Hello. Well, thank you very much. I'm very excited to be here. It's first time here speaking in Vegas, so today I'm going to talk and present a tool that I have been working on with my security team and it's called Husky CI. Who I am? I have already been presented, but as a Brazilian I play a lot of soccer and when I play soccer I usually play as a left winger. And last year I was working a lot in the pain testing field and this is something that I did, some sorts of certifications in this field. And currently I'm working as a security engineer at Globo.com and Globo.com is the largest media company in Brazil and in Latin America. It's actually a TV channel. We host some famous shows like Big Brother Brazil and The Voice Brazil. And my passion is about writing security tools and trying to understand how the process of exploit development is and this is some of my passions. So today I'm going to talk about a story about a day in the life of a development team. So let's imagine that there is this development team that they have their project, they have that repository that is hosting in GitLab and during the process of developing their project they actually use for example Tsuru. Tsuru is our platform as a service that is open source, but you can also use Heroku and AWS to deploy our project. And later on we have our project in production. So this is basically the overview of a day in the life of a development team. So let's imagine that this developer wants to develop his features and try to do his commit to the repository and all tests are being used in his CI. So we already have these configurations being made, the build, the iOS, Android and linked and the test. So later on we at global.com we ask to another developer to do this manual code review. So to check if there are some flaws and something that was not seen by this automated test. And if that is correct this commit is merged to master and we deploy it to our platform as a service and later on the project is in production. So as a security team this process we see there's something is missing. I mean no security test is being made here. So as some security teams we say wow, you are actually coding in Go. Have you ever heard about this static analysis called GoSec that is open source? It's very good so you can add it into your CI so we can find eventually security flaws before deploying it. So the developer actually, the development team actually include this in their test and this is something that we as a security team thinks that is very good. But later on another developer that is working in another language that is Ruby, the same process, we as a security team comes to the team saying hey, have you ever heard about Brakeman that is also an open source tool that do the same thing and the same process goes and the team will eventually put that in their CI as well. But what happens if there are a lot of other languages that we do not know? For example, which static analysis tool does these developers must use if you use Java or JavaScript? So we as a security team could eventually ask them hey, what about using a tool that we could eventually create that developer may abstract and will not have to worry about which security tool she or he would eventually try to use and this is what we dream. This would be great if we were able to do that. So a day in the life of a bigger organization. As I was saying, we are actually talking about one security as one development team. So global.com is a huge organization, we have a lot of developer teams, so if we try to scale this scenario, we have a lot of development teams, we have a lot of pull requests, we have a lot of commits and each one uses its own repository, GitHub, GitLab, so everyone is deploying, everyone is doing this thing. Unfortunately, our security team can't be inside all of the development teams, so all this commit is being made, is being deployed, and later on our security team will do some tests, some manual tests, some pen tests on this project that is already in production. So this is something that is very bad in our perspective, because there's a lot of coding involved. So at global.com we have this project that is called the Hack Day, this is actually my t-shirt that I'm using, that is a hackathon that we take a day, a day or two to do a lot of everything that we want, and this was a great opportunity to us as a security team to try to develop in this security tool. So what would be our dream? We have all these development teams, each one using its own repository, we would eventually add this security tool in EverCI, and eventually some may eventually pass and some will eventually fail. And for those that fail, we will eventually receive this response, because we can eventually have this emailed and that is good to us to know what vulnerability is being found. And for example, for this second development team, it will eventually see, oh, we have found this vulnerability, all right, let's correct it and send another pull request, and we'll eventually mitigate it. But for some development teams, this may not be so easy. So by using this tool, we can eventually put this security analyst inside that team to understand that vulnerability, for example. We do not know how to mitigate this SQL injection, would you help us? So our security team may eventually be there and try to help them, and now this deploy can be made. So this is our dream. And later on, our security team will eventually continue doing these pen testings and manual testings in our productions. Okay, so what are we coding? At global.com, we code in a lot of languages. So we use a lot of Golang, use a lot of Python, we use a lot of Ruby, use a lot of, a lot of languages, and this is maybe, and this is, we eventually meet the, the same scenario as you face every day. And I even challenge you to, to check this slide and see, you, you may eventually miss some language that you work on, and that shows how challenging it is to us to, to, to security team to, to handle this. So as we are working in the hack day, we were just trying to focus on these three languages at first. We're trying to use Golang and Python and Ruby, and there are three open source tools that are being done. And this is another important thing, we, we were using open source tool only, so any other, other companies could eventually use this tool as well. So GoSec, Bandit, and BreakWin was our starting security test tools that we eventually do. So how would we build this tool? So we have this development team, it will eventually send this pull request, the CI will, will start all the security tests, and HuskyCI will eventually fail if some vulnerability is found. So we, we are using some, so three companies here, we use an API, a Docker API, and our database that we are using Mongo, and for example, if we're using this Golang story, when this pull request is being made, and HuskyCI will receive that request, it will eventually send this request to a Docker API to start a container that will, for the first thing that we'll do, it will use Henry. Henry that is, is actually another open source tool that can check which language are in those repositories. If you go to GitHub or GitLab, you, you, you eventually see, oh, this repository is 80% Go and 20% Makefile, for example. This is what Henry do. So, and he does, sorry. So Henry will eventually see that, that is a Golang, and will return it to the HuskyCI API and say, hey, this is a Docker API, this is a Golang repository. So what, what are the security tools, the open source tools that we have in Golang that we can eventually try to scan it and find vulnerabilities? At this moment, we do, we only have GoSec, but as we are building this, this tool, we are actually trying to make it possible so everyone could send plugins, so I, I've got this new security tools in Golang, and so this will eventually build a lot of containers and try to run all of them, and eventually to fail it. So this is the, this is the same process, and later on the security team will eventually see these results that is being stored in our Mongo database. So what happens if another, another language is inside this repository? So now Python is being aided, some scripting Python is being aided in that repository, so the same process will, will, will, will flow. And, and he will, will check that now we have both Golang and Python, and later on we will, we will create two containers or, or more if there are more security tests related to Python in parallel, so we can run all the security tests, and later on if, if there are vulnerabilities, we will fail with DCI. So this is, this is our dream. And what we would like to see with, what are the metrics that are important to us? The first thing that we, it would be good to see is the commit alter, not to blame the developers or, or, or nothing like that, just to get, have this method so we could, for example, if we find that this top ten developers are committing a lot of SQL injection, we could eventually get our security team to train them in this specific, in this specific vulnerability. So git commit alter is something that we think it's good to us to see. The repository language for, for metrics, it's very good. Also the files that were found in that repository so we can have, for example, in this pull request we have these files, and later on a new file has come in, a new vulnerability was found, so this is something that would be good to us to see. Also the branch name, and the most important to us are the vulnerabilities that, that are being found. So these are, this is an example of the two. And also the mitigation, so if the vulnerability was mitigated is a very important metric to us to see. So this is how our MongoDB looks like. And there is this repository, the containers that were used, and the results that we're actually trying to, to separate here. We currently are trying to, to fail the CI, well, medium and high vulnerabilities are found, so this is, this is something that we start with, and this is how we also are printing it in, in some JSON so that we can consume this, this output in other, in other, in other tools. For example, if we use a front-end later on. So I've got a, and this is another thing, so what dev, the developers must do now. The developers must only add, add his configuration in the CI, these simple requests that we eventually download this client, this HuskyCI client, and, and the client will be executed inside that container, and the container will run that container. So we run the security test, so the developers do not need to, to, to check which are the security tools that we, he or she needs to use. HuskyCI will do that for, for him or her. So I've got a video here to show the, the tool working. I've created a, an open, a repository that is open, that is public. And this is, this, this is a repository that, that is in GitLab, I have the reference for the links. And let's check the GitLab CI's configuration. We'll see that there are a lot of stages that are already being used. And now I'm using this HuskyCI that we have built this external environment so we can test. And now we're going to add some vulnerabilities here just to check how the, the, the tool works. We're adding some, a new function here that gets MD5, that is something that, that there is a, a vulnerability in Golang that we are using some wiki function here. So we're actually checking out, creating a new branch to push it. And at this moment this repository only has one, one, one, one language that is Golang. And after committing and pushing it into GitLab, all these tests will be, will start. And we are not using GoSec, we're using only HuskyCI. And HuskyCI will be, will be able to understand that, that repository is a Golang. And later on we, it will eventually start all the security tests related to Go. So I have added the video so that we, as we are short on time, so the pipeline has started. And all this security, all this pipe, all this pipeline, this pipeline has a lot of jobs and the last one is HuskyCI. And when we click it on HuskyCI we will see it running. And the container will run. And, and we'll eventually download the HuskyCI client and start the analysis. So after a few moments and a few minutes, HuskyCI will eventually find those vulnerabilities on the CI that is medium high. We're using a weak cryptography primitive. And it shows the file that, that, that vulnerability was found. It finds the line of it, the code itself. And, and give it some summary over there, over there so developers could see what's going on. So for GoSec, it, it has found some four or three vulnerabilities and as there are some vulnerabilities that are medium, the, the, the CI will eventually fail. So that, that is the, the CI failing. So what if a new language is added into the project? As, as I mentioned before, as what if a, a new script is aided? So I'm aiding, I'm creating a new branch here and I'm, and I'm aiding this Python script that is using some, that has some intended vulnerabilities here so we can check if it, HuskyCI will find that we are storing some hard-coded credentials on it and eventually calling a function that could cause a remote code execution, for example, that is, that we consider insecure. So the same process is being done. Now we are committing and pushing it once again to, to GitLab and let's see what HuskyCI will find. And the new pipeline is, is created. And the jobs will be run. I have aided the radio so we can check. Just to HuskyCI. And the runner will start. Now the HuskyCI will eventually see that a new language is being set and it will add, and it, and it will run all the securities related to Python. So as we already had the vulnerabilities in GoSec, we still can see them there. And also as we are using now Python, currently in Python we have two security tasks that we use, that is bandit, that do some static analysis and safety, that checks for vulnerable, vulnerable, vulnerable dependences. So this is what it, it found. So I want to show you how, some statistics that we have in global.com so far. So we have talked to some development team so if, if they wanted to have HuskyCI in their, in their CI as a better testers. So as I said, this is our, some of the products that we, we have in Brazil in global.com and some of them are already using HuskyCI. And we have a 65 unique repository that was already analyzed and 108 unique range that was analyzed. So 20% of the, of this, of our CI has failed, causing, showing us that some vulnerability was found. And 52 passed and the others just have, the developers are still understanding how the, the tool works and some errors has been found. For example, they forgot to, to set their environment variable that HuskyCI needs to, needs to run. So this is our, our first statistic that we, we have. And the, the, the metrics of the seconds that each security tool takes to, to, to run completely. GoSec takes 14 seconds. BreakMan as well. For Python we have these both security tests that we are running that take this long, 7 and 30 seconds. And for JavaScript we have these two, these two tools. We are NPM, we are using NPM Audit that we have built our own containers to do this check. And Retire.js is, JS is another security tool that we use. Retire.js takes a little longer because we are, we need to do some NPM install before using the, the tool. So this process of NPM installing is taking a little longer, so. And all the process is being taken seven minutes, our average. Because a lot of projects use multi-languages and eventually all these containers must be created and this is our average so far. For vulnerabilities, the most, most vulnerabilities that we are facing there is some error are not being handled. For example, in Golang we, we are able to return error when we, when we are using our function. And if we do not want to use this error, we would eventually use, use a, I forgot the word in English, a dash, I guess. And this is some security vulnerability for us. And all the others are vulnerable dependencies. This is the top one for all of them in languages. And what are our next steps? As I said, this is an open source tool that everyone could eventually try to use inside your organization and try to understand how this could help you. So as I said, we are at this moment, we, at this moment we have these three components and our security team is working on checking all the, all this data from our MongoDB and, and some feedback that we are having from our developers is that we need to have a front end so everyone could check in in a more, more friendly way to see this vulnerability and to collect these metrics. There are already some open source tools that are very, are very good to do this. There's R3sec and eventually SonarCube that can use it as input to, to use as a front end. So we are, we are not using none, none of them at this moment, but we could eventually use them. And there are a lot of other languages that we are not facing, we are not handling at this moment, but it, it would be great if we, if we could. And next step is also to contribute to this, to this awesome open source tools. Then they are all, they are all open source tools that we, they are being updated daily and it would be great to us as a HuskyCI community also contribute to them. And add more security tests. For example, there are some, these are some open source tools that could, that we could add. And there are some GitHub repositories that have a, a huge list of security tests, uh, of security, uh, static analytics tools that can be, can be used. And this is something that we have to, in mind. And many more, we are trying to open some issues to handle all, how, how the future of the tool is going, uh, on, on how we could do some more, uh, features and, and now, and everything. And I would, if you would like to give HuskyCI a chance, we are trying to build some documentation so it's, it's turns it so it's easier to other, uh, to other companies to use it as well. And as I said, it's open source. These are my references. I'm not sure if I was too fast, but I'm open to questions if anyone has one. Yes? Yes. Uh, so, do you scan just the commit changes or the whole entire repo? On each push or whatever? Yes, we are, we are scanning each push. If, when a, when a new push is made, we're, we're getting that branch and, and, and, and using that commit from, until that commit, that branch. And we clone all the, those repositories based on that branch. We, we do some git clone, a single branch and the following branch that we're working on. And later on, we start all the security analysis based on, on, on, on that code. So... Yeah, it's the entire repository. I'm not sure if that is optimal, but this is something that we're doing at this moment. Yes? Yes. We, we are trying to use some goroutines to start all the containers in parallel and trying to make it possible to scale it so it's easier when a lot of repositories try to use it, we, it, it, it's smoother to our environments to run it. So we're using goroutines to start them in parallel, all the security tools. Yes? Parallel. They are working in parallel. Yes? So you had a lot of examples for GitLab in your CI system. Has there been any thought about moving to using, expanding it to Jenkins? Yeah, sure. We are using a lot of GitLab because we use a lot of GitLab in our, in global.com, but we also use some GitHub and also SecureCI and, and another, another CI. So, uh, basically we, what, what we could do is, is just add it, you have to build this environment, this CI environment and put that line inside your container that will be run. So I think it, it would be easier to use in Jenkins than any other CIs. Yes, nice. Some, some security tools, uh, permit us to add this, this, this comment in the line that we, that developer and the security team think that these are false positives. For example, GoSec allows us to put some comment in, you, uh, uh, using NoSec, so that GoSec will eventually not consider that as a, as a, as a, as a vulnerability. But false positive is some of our challenges in, because if some developers also, uh, ask us how we could not fail that CI if this false positive is, is shown. But we are, at this moment we rely on how the security tools are, are, are, are, are allowing us to, to handle these false positives. So for Bennett we, we, or safety we need to check if them can allow us to, to add this tool. But it's something that we could eventually do in HuskyCI client. We could do some feature to try to allow it, us to not face this problem. ... ... Did you find that you were able to handle the capacity of putting the resources out? And as, like, a follow-up question, was there any, is there anything you're noticing in terms of, do developers run into some of the same problems where you might have the same vulnerability popping up across your Nice. Well, when we first talked to development teams to use this tool, it's something like, it's a culture. So each team has its own autonomous way of handling those repositories. And as unfortunately we are not able to be inside all of the development teams, but on the development team that we do have a secure analyst. We ask them to gently add this security tool in their CI. And our most problem is basically finding that the repository using vulnerable dependencies. So this is something that we are trying to do. Developers are generally saying that those dependencies are from the vendors, not of their project. But we actually see as, well, it is indeed a vulnerability. So we should not use this, this, this, this dependence. So this is something that we are trying to, to handle. And I see security more, more like a people. So we have to talk with them and try to increment, put some security culture inside our team. But this is something that we are trying to, to work on. Currently our, our SQCI team is, is, is free, two and three developers as well. But it's something that we could eventually add in the future. Even trying to integrate to, to these tools or ServiceNow and, and any other tools. Okay. Thank you very much.