<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Greg Bulmash</title>
    <description>The latest articles on Forem by Greg Bulmash (@gitguardiangregb).</description>
    <link>https://forem.com/gitguardiangregb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1166915%2Feeebfbdd-dc74-4a7b-a49a-12f3e65c24c1.jpg</url>
      <title>Forem: Greg Bulmash</title>
      <link>https://forem.com/gitguardiangregb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/gitguardiangregb"/>
    <language>en</language>
    <item>
      <title>Five Ways Your CI/CD Pipeline Can Be Exploited</title>
      <dc:creator>Greg Bulmash</dc:creator>
      <pubDate>Fri, 26 Jan 2024 17:08:58 +0000</pubDate>
      <link>https://forem.com/gitguardian/five-ways-your-cicd-pipeline-can-be-exploited-20cg</link>
      <guid>https://forem.com/gitguardian/five-ways-your-cicd-pipeline-can-be-exploited-20cg</guid>
      <description>&lt;p&gt;We've talked about &lt;a href="https://blog.gitguardian.com/security-zines-2-compromising-ci-cd-pipelines/"&gt;how Continuous Integration and Continuous Delivery (CI/CD) tools can be a source of secrets sprawl&lt;/a&gt;. While it's not as insecure as leaving them laying around in a publicly accessible file, CI/CD pipelines can be exploited in a number of ways and I'm going to share a few with you.&lt;/p&gt;

&lt;p&gt;This article is not exhaustive. GitHub's &lt;a href="https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions"&gt;Security Hardening Guide for GitHub Actions&lt;/a&gt; alone is 16 pages long if you try to print it. &lt;a href="https://owasp.org/www-project-top-10-ci-cd-security-risks/"&gt;OWASP's Top 10 CI/CD Security Risks&lt;/a&gt; is 38 pages long. Protecting your CI/CD systems is not a tiny task, but it's an important one. To get you started, here's a quick read on five ways attackers can leverage your CI/CD to gain access to additional systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  #1: When someone can find your credentials
&lt;/h2&gt;

&lt;p&gt;In an &lt;a href="https://research.nccgroup.com/2022/01/13/10-real-world-stories-of-how-weve-compromised-ci-cd-pipelines/"&gt;NCC Group report on 10 exploits&lt;/a&gt; they ran, their first exploit starts with an improperly permissioned S3 bucket. The bucket had a script with a hardcoded Git credential. From there, it was a matter of steps to gain access to the CI/CD environment and get more credentials the CI/CD processes had access to… Pwned!&lt;/p&gt;

&lt;p&gt;GitGuardian has found millions of hardcoded secrets in Git repositories, but secrets can be anywhere: S3 buckets, screencaps, you name it. Secrets hygiene should be followed &lt;em&gt;everywhere&lt;/em&gt;. And given how many exploits have started in misconfigured S3 buckets, if you're going to use S3, make sure you're using it correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  #2 When GitHub has your AWS credentials
&lt;/h2&gt;

&lt;p&gt;While &lt;a href="https://blog.gitguardian.com/secure-your-secrets-with-env/"&gt;environment variables&lt;/a&gt; are considered somewhat of a minimum standard for keeping secrets out of your code, if the code that uses them is compromised or is poorly configured, it can start revealing them through your logfiles.&lt;/p&gt;

&lt;p&gt;GitHub and AWS actually have an &lt;a href="https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services"&gt;ingenious workaround for this&lt;/a&gt;, using OpenID Connect (OIDC). In this case, AWS uses GitHub as an identity provider (IDP) for an Identity and Access Management (IAM) role you create. That IAM role becomes accessible only by your repository, and you can even scope it to a specific branch. GitHub and AWS negotiate temporary tokens between themselves and no password is stored.&lt;/p&gt;

&lt;p&gt;When no password is stored by the system, no password can be revealed by the system.&lt;/p&gt;

&lt;h2&gt;
  
  
  #3 When access is poorly managed
&lt;/h2&gt;

&lt;p&gt;The number two item in &lt;a href="https://owasp.org/www-project-top-10-ci-cd-security-risks/"&gt;OWASP's Top 10 CI/CD Security Risks&lt;/a&gt; deals with IAM as well. It goes into a number of ways you can improperly manage this. To quote them: "Ensuring each human and application identity has been granted only the permissions required and only against the actual repositories it needs to access is not trivial."&lt;/p&gt;

&lt;p&gt;This isn't limited to the service AWS calls "IAM," either. Identity and Access Management relates to everything from a keycard to get in the door of the building to an access policy assigned to a specific branch of a Git repository. Ensuring your CI/CD processes can only touch what they're supposed to touch and see what they're supposed to see is crucial. &lt;/p&gt;

&lt;p&gt;Additionally, the number of people with access to your CI/CD logging and how they're able to access it matters. If your CI/CD process is leaking credentials into the logs and a contractor's login is shoulder-surfed in a Starbucks, the clock to a complete takeover starts ticking.&lt;/p&gt;

&lt;p&gt;Some of the worst hacks don't start with someone finding the keys to the castle laying around. They start with someone who found the keys to the stable laying around. In the stable, they found the keys to the scullery in a saddlebag. And so on and so on.&lt;/p&gt;

&lt;h2&gt;
  
  
  #4 When you obfuscate your credentials
&lt;/h2&gt;

&lt;p&gt;Many CI/CD logging systems have some method of identifying and redacting credentials in the logs. But if you make it so the redaction filters can't spot the credential, but an experienced human can, you might just clever yourself into getting hacked.&lt;/p&gt;

&lt;p&gt;In many demonstrations of poisoning pipelines (getting a bit of bad code into your CI/CD process), the hackers have the bad code output your passwords in base 64. For example, PASSWORD='LetMeIn' in base 64 is UEFTU1dPUkQ9J0xldE1lSW4n. While redaction filters may get better and better at spotting these kinds of things, some systems' redaction filters are just a handful of regular expression patterns. Converting secrets into another format can help sneak them past the sniffers that are there to protect you.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions"&gt;GitHub's security hardening advice&lt;/a&gt;, one of the primary points of guidance for secrets is "never use structured data as a secret." Packing up your secrets in XML, JSON, or YAML may help put the helpful secret-sniffing robots off the scent and let those secrets escape into your logs.&lt;/p&gt;

&lt;h2&gt;
  
  
  #5 When every file has the same write permissions
&lt;/h2&gt;

&lt;p&gt;GitHub offers a feature called &lt;a href="https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners"&gt;CODEOWNERS&lt;/a&gt;. We don't mean to bang the GitHub drum, but this offers a practical application that can be translated to other systems.&lt;/p&gt;

&lt;p&gt;With CODEOWNERS, you can set the permissions on your .github/workflows directory such that whenever someone tries to change anything in it (creating a "poisoned pipeline"), an admin specified by CODEOWNERS is not only alerted, but has to approve the change.&lt;/p&gt;

&lt;p&gt;Depending on your systems, it's possible to lock down important files or directories within a development environment and ensure only the people who &lt;em&gt;need&lt;/em&gt; to be able to change build scripts or configurations can. Whether on a local build or the primary server, this helps ensure that you're not accidentally or intentionally sabotaged by an insider.&lt;/p&gt;

&lt;h2&gt;
  
  
  What else can you do?
&lt;/h2&gt;

&lt;p&gt;After telling you all the ways you can be compromised, even though knowing them helps avoid it, we wanted to leave you with a couple of things you can proactively do (and if you're already doing them, you can finish this feeling good that you are).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Shift Left&lt;/strong&gt;: This can relate to multiple things, but here, we mean don't wait until the build to test your code. Run more tests &lt;em&gt;before&lt;/em&gt; code gets to the CI/CD pipeline. Tests need access and generate logs, and if those are being run in development environments, they're not providing an additional attack surface at the CI/CD level. Additionally, scan, scan, and scan again. There are multiple points, from a pre-commit hook in a developer environment to scanning the log files and artifacts from a CI/CD run, where you can integrate a secrets scanner like GitGuardian.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Vaults:&lt;/strong&gt; Remember how AWS and GitHub can communicate without you giving GitHub an AWS secret? That doesn't just need to be limited to pushing builds to an EC2 instance or S3. It can also let you pull secrets for other resources from AWS Secrets Manager, so they're never stored in GitHub. You may not use AWS or GitHub, but you can explore how your favorite CI/CD tools and your favorite vault can integrate so you're not storing secrets in your build scripts, build tools, or the artifacts they produce.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We hope you're leaving this with some better understanding of how CI/CD tools can get exploited, how you can protect yourself better, and some ideas for exploring the topic further. To quote the excellent 1980s police drama, "Hill Street Blues": &lt;a href="https://www.youtube.com/watch?v=MJDQewSMB-E"&gt;Hey, let's be careful out there&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>cicd</category>
      <category>security</category>
      <category>hacking</category>
    </item>
    <item>
      <title>Secure Your Secrets with .env</title>
      <dc:creator>Greg Bulmash</dc:creator>
      <pubDate>Tue, 09 Jan 2024 17:00:52 +0000</pubDate>
      <link>https://forem.com/gitguardiangregb/secure-your-secrets-with-env-4c5m</link>
      <guid>https://forem.com/gitguardiangregb/secure-your-secrets-with-env-4c5m</guid>
      <description>&lt;p&gt;Using environment variables to store secrets instead of writing them directly into your code is one of the quickest and easiest ways to add a layer of protection to your projects. There are many ways to use them, but a properly utilized &lt;code&gt;.env&lt;/code&gt; file is one of the best, and I’ll explain why.&lt;/p&gt;

&lt;h2&gt;
  
  
  They’re project scoped
&lt;/h2&gt;

&lt;p&gt;Environment variables are a part of every major operating system: Windows, MacOS, and all the flavors of *nix (Unix, BSD, Linux, etc.). They can be set at an operating system level, user level, session level… It gets complicated, and where/how you define them matters to the scope in which they can be accessed.&lt;/p&gt;

&lt;p&gt;This variety of scopes also creates the distinct possibility of variable collisions. If you’re looking for an environment variable named &lt;code&gt;API_KEY&lt;/code&gt;, that could be getting re-defined in each scope, and if you’re not steeped in that OS, it’s extra work to be sure you’re not clobbering something someone set at a different scope that some other app or service needs.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.env&lt;/code&gt; files are only consumed at runtime and only in the context of the app that’s consuming them. That prevents them from clobbering any other environment variables on the system that might be consumed outside your app.&lt;/p&gt;

&lt;h2&gt;
  
  
  They can be "ignored"
&lt;/h2&gt;

&lt;p&gt;If you’re working on a JavaScript application in Node, you can’t ignore your &lt;code&gt;index.js&lt;/code&gt; file in the version control system. It contains essential code. But you can &lt;a href="https://youtu.be/3KrjEytC5qc"&gt;set your &lt;code&gt;.gitignore&lt;/code&gt; file&lt;/a&gt; to have the Git system ignore your &lt;code&gt;.env&lt;/code&gt; file. If you do that from the inception of your repository, you won’t commit secrets to the project’s Git history.&lt;/p&gt;

&lt;p&gt;A better option is to include a &lt;code&gt;.sample.env&lt;/code&gt; file that sets the variable names, but only includes dummy data or blanks. People cloning/forking and using the repository can get the secrets via another route, then &lt;code&gt;cp .sample.env .env&lt;/code&gt; (in a terminal), and assign the real values to the proper variables in the ignored &lt;code&gt;.env&lt;/code&gt; file.&lt;/p&gt;

&lt;h2&gt;
  
  
  They’re relocatable
&lt;/h2&gt;

&lt;p&gt;While most systems will default to looking for the &lt;code&gt;.env&lt;/code&gt; file in the root of the app’s primary directory, you can always have it a level or two higher. So, if for example, a server configuration error or code bug leaves it possible to view all the files at the root of your web app as a directory, the &lt;code&gt;.env&lt;/code&gt; will not be there for easy pickings.&lt;/p&gt;

&lt;p&gt;This is not an uncommon practice. SSH keys are stored by default at &lt;code&gt;~/.ssh&lt;/code&gt; (a "hidden" subdirectory of the home directory of the user) on Windows, Mac, and Linux. You do not need to move them into the root directory of a project that uses them.&lt;/p&gt;

&lt;h2&gt;
  
  
  A quick .env demo in Node
&lt;/h2&gt;

&lt;p&gt;Let’s say your working directory for the app you’re building is &lt;code&gt;~/Documents/work/projects/games/tictactoe&lt;/code&gt; and &lt;code&gt;tictactoe&lt;/code&gt; is the root directory for the app you’re building and your Git repository. You can put the &lt;code&gt;.env&lt;/code&gt; in the next directory up, &lt;code&gt;games&lt;/code&gt;. And while we generally call the file type &lt;code&gt;.env&lt;/code&gt;, you can call it &lt;code&gt;.toecreds&lt;/code&gt; if you want to make it a distinct file that other processes would never even think to touch. We'll use that in the demo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s how you’d do that in Node.js.:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1. In your &lt;code&gt;games/tictactoe&lt;/code&gt; directory, &lt;code&gt;npm init&lt;/code&gt; (go with the defaults) and then &lt;code&gt;npm install dotenv&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;2. Create your &lt;code&gt;.toecreds&lt;/code&gt; file in the &lt;code&gt;games&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;3. Fill the .toecreds file with information in the following format &lt;code&gt;VARIABLE_NAME=VALUE&lt;/code&gt; (no spaces). You can also start a line with # for a comment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Leaderboard SaaS&lt;/span&gt;
&lt;span class="nv"&gt;LEADERBOARD_ENDPOINT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://example.com/leaderboard/v1
&lt;span class="nv"&gt;LEADERBOARD_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;jknfwgfprgmerg…
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4. At the top of your &lt;code&gt;index.js&lt;/code&gt; (or whatever file is your launchpoint) in &lt;code&gt;games/tictactoe&lt;/code&gt;, include the following lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dotenv&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../.toecreds&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LEADERBOARD_ENDPOINT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run your &lt;code&gt;index.js&lt;/code&gt; and the endpoint URL will be output to the terminal. Meanwhile, the environment variables you set in it will not be available from the terminal and the file lives a level above your repository and can't accidentally be swept up if you misconfigure &lt;code&gt;.gitignore&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Try adding a long timeout to the script and then running &lt;code&gt;node index.js &amp;amp;&lt;/code&gt; to return control back to the terminal after invoking the script. While the script is running in that shell session, the environment variables available to the shell still do not contain the secrets. They are scoped to your running application.&lt;/p&gt;

&lt;p&gt;You can have dev, test, and prod credential sets, having your CI/CD tooling pull the correct keys for the deployment target from a secrets manager and write the &lt;code&gt;.toecreds&lt;/code&gt; (or &lt;code&gt;.env&lt;/code&gt;) file to the same relative directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  And there you have it
&lt;/h2&gt;

&lt;p&gt;The use of a &lt;code&gt;.env&lt;/code&gt; file helps you keep your app's secrets from ever being committed to your version control and provides an additional layer of protection against your secrets being discovered by hackers or other prying eyes. It's a great addition to your developer / dev-ops toolbox.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Ethical Hacking Q&amp;A with Sonya Moisset</title>
      <dc:creator>Greg Bulmash</dc:creator>
      <pubDate>Tue, 19 Dec 2023 16:54:32 +0000</pubDate>
      <link>https://forem.com/gitguardian/ethical-hacking-qa-with-sonya-moisset-461g</link>
      <guid>https://forem.com/gitguardian/ethical-hacking-qa-with-sonya-moisset-461g</guid>
      <description>&lt;p&gt;GitGuardian’s Mackenzie Jackson had the privilege of hosting a webinar on ethical hacking with Snyk’s Sonya Moisset. What follows is a lightly edited transcript of the Q&amp;amp;A after her presentation or &lt;a href="https://youtu.be/U2ZLLvrPals"&gt;watch the Ethical Hacking Q&amp;amp;A video clip on YouTube.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mackenzie (after describing the process for submitting and upvoting questions):&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;I'm just going to ask &lt;em&gt;my&lt;/em&gt; question because I'm the host and I can do that. &lt;/p&gt;

&lt;p&gt;So the question that I have too is… when we're doing something ethically, when we're ethically hacking something, we obviously have parameters that we have to work within. Is there anything that we have to look out for that could be a legal issue if we… if we perhaps access the wrong things? Do we have to be careful of that when we're starting our ethical hacking journey? &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sonya:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yeah. This is why I stress the fact that when you go on those bug bounty platforms, it's really important to read their rules of the game because they will let you know which endpoint you can test, which URLs, which API you can actually test. And if you do test outside of this scope, this is where it's actually illegal. &lt;/p&gt;

&lt;p&gt;And usually, when you test on these platforms, as I mentioned, you do sign an NDA when you're doing so, so you ask permission to actually test those. If you haven't signed the NDA and you actually find one vulnerability, then you can come up to these platforms and try to find those programs. &lt;/p&gt;

&lt;p&gt;Usually, &lt;a href="https://hackerone.com/bug-bounty-programs"&gt;HackerOne&lt;/a&gt;, &lt;a href="https://www.intigriti.com/programs"&gt;Intigriti&lt;/a&gt;, and other platforms will help you to actually convey this report and be in a safe place. But as I mentioned during the demo I wasn't supposed to have the codebase on my machine, because this is… you can consider it an IP, intellectual property, that I actually copied and had on my machine. &lt;/p&gt;

&lt;p&gt;You should actually do all of the things with the Patch reversal to have the information. So just make sure to not have copies of databases, user information, and all of those. Make sure to stay in the scope of the testing and make sure to provide a detailed report of all of the commands that you've done, because potentially the security team/developer team will actually look at the logs. So yeah, they could potentially look at what you've done in their systems. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mackenzie:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's great. Thanks so much for that. We have another question here. Now there's actually kind of a lot of similar questions about this and I think that maybe &lt;a href="https://learn.snyk.io/"&gt;Snyk Learn&lt;/a&gt; might be a good place. But where, if people want to get started… where do the beginners go to kind of… what would be your first steps, maybe to start with, and then what would be the journey beyond that, do you think? &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sonya:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sure. So there are a couple of websites, good websites, and also free platforms where you can start this learning journey, which are &lt;a href="https://tryhackme.com/"&gt;Try Hack Me&lt;/a&gt; and &lt;a href="https://www.hackthebox.com/"&gt;Hack The Box&lt;/a&gt;. They’re two great platforms where you can create an account and actually try to “Pwn” those machines. &lt;/p&gt;

&lt;p&gt;At Try Hack Me, I find it a little bit more beginner-friendly because they do have those rooms with step by step walk throughs. When you feel a bit more confident you can go on Hack The Box and try to hack the beginner machines. So, yeah, this is potentially a good one. &lt;/p&gt;

&lt;p&gt;There's other platforms you can also try—the &lt;a href="https://owasp.org/www-project-juice-shop/"&gt;OWASP Juice Shop&lt;/a&gt;, which is an online retail shop that has a lot of vulnerabilities. There's also &lt;a href="https://picoctf.org/"&gt;picoctf&lt;/a&gt;. There's a lot of those platforms. There's also, as you've mentioned, &lt;a href="https://academy.hackthebox.com/"&gt;Hack The Box has an academy&lt;/a&gt; where you can actually learn a bit more. They do have modules on specific vulnerabilities, on how to do those ethical hacking methodologies and workflows, so this is to help you on that path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mackenzie:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Excellent. And there are a couple of more questions along that… I don't think we need to answer them… You know there are courses, there are certifications, but if you want to start, I think that those are the places to start. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sonya:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yeah, I would say if you want to also demonstrate those to recruiters, and you might not have the budget to actually do the certifications, is start with Try Hack Me, Then move to Hack The Box. And when you manage to pwn the box, write a detailed walkthrough on which tools you've actually used, the commands, what were the results, and also recommendations. &lt;/p&gt;

&lt;p&gt;Then you can start working on creating a portfolio of walkthroughs. And this is something that [you] could potentially show to recruiters because you will have hands-on, specific tools, and the methodology, which is important because you want to demonstrate the skills. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mackenzie:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yeah, that's really cool, because perhaps people don't realize but there are certifications that you can get and they go on the end of your, you know, a lot of people have them on the end of their LinkedIn profiles. And a lot of them are great and it can show the recruiters that you know what you're talking about, &lt;em&gt;but&lt;/em&gt; by golly, some of them are so expensive to do. I feel like what you're saying is that if you don't have the budget to do that, then if you document it, that can be a place you can save in.&lt;/p&gt;

&lt;p&gt;That's fantastic advice. &lt;/p&gt;

&lt;p&gt;Now you touched on AI and we had a question here from Abdullah, who says “How do you think generative AI will affect your day as an ethical hacker and the cybersecurity field as a whole? Are there real-world applications?” &lt;/p&gt;

&lt;p&gt;So you've kind of touched on this, but is there anything more that you could kind of add on that? Are &lt;em&gt;you&lt;/em&gt; using AI when you're doing ethical hacking today?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sonya:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, here we're talking about generative AI. This is the code that is generated through Copilot, through ChatGPT, and the other LLMs, so this would depend on how… what… what you're doing about this code. &lt;/p&gt;

&lt;p&gt;So it's great to have those tools. Let's say if we're producing code through ChatGPT, what I would recommend is the same as when you copy/paste code from Stack Overflow. &lt;/p&gt;

&lt;p&gt;Do you have security tools? It could be GitGuardian, Snyk… just to make sure that you have a pipeline to make sure that you're scanning the code that you will introduce into your code base. You can use these tools. Just make sure to double-check and make sure to understand what you're actually putting into your codebase. The problem that you might have copy/pasting Stack Overflow would be the same with the code generated through different LLMs.&lt;/p&gt;

&lt;p&gt;But also this was an open question for not generative AI, but any of the ethical hacking AI tools or those that are powered by AI. This is interesting. It’s always the same, as with any tools, have a good understanding of the tools that you're using and also make sure that you're using them as an assistant. Don't lean only on your tool. Make sure to double-check every time the results, the outputs, just to make sure that it doesn't produce hallucinations or false positives or false negatives in a sense. &lt;/p&gt;

&lt;p&gt;So just make sure to use it as an assistant when you're stuck and you need better ideas or explanations. For example, line by line for code or for an exploit. So, yeah, it depends on the usage that you're actually doing on AI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mackenzie:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Yeah, amazing. [pauses to promote the next webinar]&lt;/p&gt;

&lt;p&gt;Maybe a couple more questions. This one I find quite interesting: “What overlap does an ethical hacker have in the day-to-day with a typical software engineer?” &lt;/p&gt;

&lt;p&gt;And what I kind of think–perhaps I'm interpreting this wrong–but if you're in a company, and perhaps you're a red teamer, or you're on the appsec team, how do you interact with the software engineers? Do you have any advice for how to interact, perhaps, with software engineers and help them, and not just be the “opposite team,” let's say? &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sonya:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sure, so the most important thing is the culture that you have in the organization. The security team should be enablers. They shouldn't be blockers or gates for developers. They should have that collaboration piece and communicate with the team.&lt;/p&gt;

&lt;p&gt;It's usually a good thing, for example, doing these kinds of webinars with live hacking demos during lunch breaks or organizing this within the company so the developers have a better understanding of what is happening in the cyber security space because it's quite exciting. &lt;/p&gt;

&lt;p&gt;When we're talking about hacking, everyone is interested to know, to have a better understanding of it, so this a good way, actually, to increase the culture and just to break the silos between both teams. &lt;/p&gt;

&lt;p&gt;You can also gamify it. You can dedicate a day to making sure that you go through the backlog of security vulnerabilities. And you have the security team doing some training, explaining the vulnerability, sitting down with the developers, just you have that collaboration and communication piece. &lt;/p&gt;

&lt;p&gt;This could also go through the Security Champion program, for example. A Security Champion is basically a developer that is acting as a bridge between security and developer teams. They could also upskill through this program. So there are several ways to do so, but the company should make sure the security team are enablers. That's the most important thing. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mackenzie:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;[Winds up the webinar]&lt;/p&gt;

</description>
    </item>
    <item>
      <title>“Do Not Push To Production” And Other Insecure Coding, Demonstrated By An Ethical Hacker</title>
      <dc:creator>Greg Bulmash</dc:creator>
      <pubDate>Thu, 07 Dec 2023 23:47:50 +0000</pubDate>
      <link>https://forem.com/gitguardiangregb/do-not-push-to-production-and-other-insecure-coding-demonstrated-by-an-ethical-hacker-5hg7</link>
      <guid>https://forem.com/gitguardiangregb/do-not-push-to-production-and-other-insecure-coding-demonstrated-by-an-ethical-hacker-5hg7</guid>
      <description>&lt;p&gt;In November, our own Mackenzie Jackson hosted a webinar called “&lt;a href="https://www.youtube.com/watch?v=SDeG4BXfLnU"&gt;Crack the Code: A Beginner’s Guide to Ethical Hacking&lt;/a&gt;” with special guest, &lt;a href="https://snyk.io"&gt;Snyk&lt;/a&gt;’s &lt;a href="https://sonyamoisset.github.io/"&gt;Sonya Moisset&lt;/a&gt;. Viewers got to see some interesting vulnerabilities and coding practices that made her demo app pretty open to exploits.&lt;/p&gt;

&lt;p&gt;I will warn you right now, if you &lt;a href="https://www.youtube.com/watch?v=SDeG4BXfLnU"&gt;watch the ethical hacking webinar&lt;/a&gt;, be careful about what you’re drinking, where you’re facing, and the size of your sips. I learned this the hard way when I almost sprayed my monitor with Coke Zero as she got to a specific point I’ll note when we get there.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is “Ethical Hacking?”
&lt;/h2&gt;

&lt;p&gt;To quote Sonya, ethical hacking is “identifying and exploiting vulnerabilities in computer systems or networks in a responsible and lawful manner.” It’s been around for quite a while. A friend of mine published a book about it over 25 years ago, called The Happy Hacker.&lt;/p&gt;

&lt;p&gt;Basically, there are four main tenets that ethical hackers are supposed to follow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Only hack with permission. If you’re hacking without permission, no matter what your motives, you could get arrested.&lt;/li&gt;
&lt;li&gt;Follow relevant laws and regulations. Again, you can get arrested, even if your motives are altruistic.&lt;/li&gt;
&lt;li&gt;Don’t be destructive/disruptive. Don’t try to nuke your target, crash it, or delete production data to prove your hack. Don’t use tools you know could do damage. Remember, if you’re hacking ethically, you’re a guest in the systems you breach, so be respectful.&lt;/li&gt;
&lt;li&gt;Document your findings and provide a comprehensive report to the system owner.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ethical hackers are very useful. They’re often the source of reports that lead to security patches for your browser, your OS, etc. For example, the Sakura Samurai ethical hacking group exposed (and helped fix) a security hole that provided &lt;a href="https://blog.gitguardian.com/united-nations-databreach-jan/"&gt;access to sensitive United Nations data&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The heist!
&lt;/h2&gt;

&lt;p&gt;Sonya’s demo went through hacking an app called Patch, which is a deliberately vulnerable demo application, written in Node.js. Thank goodness, she was running it locally, but had she put a tunneling service like ngrok in front of it, the app could have been available to the broader internet.&lt;/p&gt;

&lt;p&gt;One of the first steps in hacking is reconnaissance. As part of her recon, Sonia tried some common and simple tests. She found that assets were being served from the &lt;code&gt;public&lt;/code&gt; folder. She was able to take the URL to an asset, remove the file name and get access to the full directory listing of the folder. &lt;/p&gt;

&lt;p&gt;This is pretty old and has multiple ways to solve it. Apache lets you turn off showing the directory listing in the server configuration. I simply include an &lt;code&gt;index.html&lt;/code&gt; file in those directories. It has one line of text: “These are not the droids you’re looking for. Move along.”&lt;/p&gt;

&lt;p&gt;But then she got a little fancier and tried a &lt;a href="https://learn.snyk.io/lesson/directory-traversal/"&gt;directory traversal exploit&lt;/a&gt; to see if she could get out of the public directory and into directories she shouldn’t be able to access. And she could. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/5wWf7GVNH7aOFo7e6DS/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/5wWf7GVNH7aOFo7e6DS/giphy.gif" width="345" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;She found her way to the top level of the app directory, giving her the ability to view and exfiltrate the entire source code. As she’d show later, directory traversal could go even farther, giving an attacker access to the &lt;code&gt;~/.ssh&lt;/code&gt; directory where secure keys are stored or the files where hashed system passwords are stored.&lt;/p&gt;

&lt;p&gt;First thing she did, though, was browse through the &lt;code&gt;package.json&lt;/code&gt; file, which provided a list of all the third-party NPM packages it was using. Using the Snyk plugin for VSCode, she was able to scan the app for vulnerabilities and find that the directory traversal weakness came from the app being pegged to the 0.2.5 version of a package that’s currently at version 3.0.0.&lt;/p&gt;

&lt;p&gt;It may seem simple to fix that just by updating the version, but realize that there are likely to be breaking changes between those two versions because they’re so far removed. Extensive testing would be necessary. But it’s not her job to fix it. It’s her job to report it, so she recorded it with as much detail as possible, and moved on. &lt;/p&gt;

&lt;p&gt;Remember though, she got access to all the code, not just that file. She started digging into the main code file, &lt;code&gt;index.js&lt;/code&gt;, and scrolling through it. She saw all the packages being imported, then she was able to see all the routes for all the endpoints, including an endpoint for a chat feature she wasn’t aware of.&lt;/p&gt;

&lt;p&gt;She scrolled further down to find the code associated with the chat endpoint and that’s when I almost… &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/hvq8ONQhQ1XLq/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/hvq8ONQhQ1XLq/giphy.gif" width="320" height="253"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// DO NOT PUSH TO PRODUCTION&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For those of you who aren’t programmers, that’s a comment in the code. It’s a reminder to anyone who reads the code, but has absolutely zero impact on whether the code will actually get pushed to production. It’s not functional, simply informational, and might as well be a post-it note with “TO DO: Don’t!” on it for all the security it offers. This is why I almost covered my monitor in Coke Zero Sugar, because it’s the coding equivalent of a slapstick gag.&lt;/p&gt;

&lt;p&gt;She checked that the endpoint actually worked, then started to probe it with API calls using CURL. She was able to add messages to the chat with information she found in the code. Then she tried to delete one and was blocked. But she went back through the code, found something interesting, traced it to another outdated package with a Prototype Pollution vulnerability, and was able to use it to inject code that gave her the ability to delete chat messages.&lt;/p&gt;

&lt;p&gt;Note, she only deleted her own messages. Remember the tenet of not being destructive.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up…
&lt;/h2&gt;

&lt;p&gt;When I did a demonstration of how to code a simple WebSockets chat at a developer meetup over 10 years ago, my app was so simple that it didn’t sanitize the messages. People were injecting HTML and CSS into their messages and the stuff they got up to was crazy. One of the better known XKCD comics is about a boy with a SQL injection exploit in his name.&lt;/p&gt;

&lt;p&gt;It’s easier than you think to write vulnerable code and ethical hacking can help you find it when you have. But remember the four tenets: get permission, avoid illegal stuff, avoid destructive stuff, and most importantly document and report your findings to the system owner and give them time to fix things before you tell anyone else. If you ignore any of those, your hacking is not ethical and you could get in trouble.&lt;/p&gt;

&lt;p&gt;If you want to learn more about ethical hacking, our friends at Snyk have a great set of ethical hacking resources for you to explore. And remember, an important bit of hacker recon is to go through public repositories, looking for plaintext secrets in your public code. To help you remedy that, try &lt;a href="http://gitguardian.com"&gt;GitGuardian&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>hacking</category>
      <category>cybersecurity</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
