<?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>DEV Community: Miguel</title>
    <description>The latest articles on DEV Community by Miguel (@miguel000).</description>
    <link>https://dev.to/miguel000</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%2F134400%2Fef81aa81-1367-4f26-bacb-762eb16c85bd.jpeg</url>
      <title>DEV Community: Miguel</title>
      <link>https://dev.to/miguel000</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/miguel000"/>
    <language>en</language>
    <item>
      <title>ChatGPT creating OSS security rules and plugins</title>
      <dc:creator>Miguel</dc:creator>
      <pubDate>Mon, 27 Feb 2023 09:44:31 +0000</pubDate>
      <link>https://dev.to/sysdig/chatgpt-creating-security-rules-and-plugins-5g23</link>
      <guid>https://dev.to/sysdig/chatgpt-creating-security-rules-and-plugins-5g23</guid>
      <description>&lt;p&gt;Can &lt;a href="https://openai.com/blog/chatgpt/" rel="noopener noreferrer"&gt;OpenAI ChatGPT&lt;/a&gt; become a contributor for an open source project like &lt;a href="https://falco.org/" rel="noopener noreferrer"&gt;Falco&lt;/a&gt;? Is this the end of GitHub Copilot?&lt;/p&gt;

&lt;p&gt;ChatGPT is SO trendy that I overheard my grandma talking about it to her friends the other day. We’re seeing more and more uses of this AI for real world applications. That made us think…&lt;/p&gt;

&lt;p&gt;Falco, the first runtime security project to join CNCF as an incubation-level project, needs contributors. Would OpenAI’s ChatGPT language model be able to write security rules or plugins for Falco, and become a contributor?&lt;/p&gt;

&lt;h3&gt;
  
  
  ChatGPT as a potential new Falco partner
&lt;/h3&gt;

&lt;p&gt;Jokes aside, in this article we explore the viability of ChatGPT as a tool for organizations to create effective and efficient security rules. Would those new rules in Falco ensure their containers and hosts are protected from potential threats?&lt;/p&gt;

&lt;h2&gt;
  
  
  What is runtime security for ChatGPT?
&lt;/h2&gt;

&lt;p&gt;In order to begin, we need to understand &lt;a href="https://sysdig.com/learn-cloud-native/kubernetes-security/runtime-security/" rel="noopener noreferrer"&gt;what runtime security is&lt;/a&gt;. Rather than using a search engine, we will ask ChatGPT in order to speed up the process. &lt;/p&gt;

&lt;p&gt;According to ChatGPT:&lt;/p&gt;

&lt;p&gt; “&lt;em&gt;Runtime security involves monitoring and protecting software systems in&lt;/em&gt; &lt;strong&gt;&lt;em&gt;real-time&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;as they are running, detecting, and responding to security threats, and implementing mitigation techniques to prevent further damage. The goal of runtime security is to&lt;/em&gt; &lt;strong&gt;&lt;em&gt;identify and respond&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;to security threats and vulnerabilities&lt;/em&gt; &lt;strong&gt;&lt;em&gt;before they can be exploited and cause harm&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;.&lt;/em&gt;”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/image-27.png" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fimage-27-1170x855.png" alt="ChatGPT: What is runtime security?" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A good definition, but let’s see if we can go deeper.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Falco for ChatGPT?
&lt;/h2&gt;

&lt;p&gt;ChatGPT summarized the open source project Falco in a clear and concise manner. &lt;/p&gt;

&lt;p&gt;Rather than copying the information from the landing page of &lt;a href="https://falco.org/" rel="noopener noreferrer"&gt;falco.org&lt;/a&gt;, ChatGPT provided useful context as to how Falco utilizes eBPF to achieve low-overhead when detecting security threats from data collected within the Linux Kernel. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/image-28-1170x683.png" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fimage-28-1170x683.png" alt="Chatgpt what is Falco" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, we understand what runtime security is, and how Falco can be used to detect anomalous runtime security issues. Now that we are familiar with open source Falco, let’s ask ChatGPT to write us some useful Falco rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  Asking ChatGPT to create a Falco rule
&lt;/h2&gt;

&lt;p&gt;Now, let’s ask ChatGPT if the language model is capable of writing OSS Falco security rules. &lt;/p&gt;

&lt;p&gt;Based on the below screenshot, &lt;strong&gt;does ChatGPT looks like a useful contributor to the Falco community?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/image-29.png" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fimage-29-1170x820.png" alt="Chatgpt Falco rule" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, we are happy with the answer that was returned. &lt;/p&gt;

&lt;p&gt;There was a correctly-formatted Falco rule and the language model also returned some added context as to how the rule will work. &lt;/p&gt;

&lt;p&gt;My only concern is that the first rule they created is similar to a rule that already exists in the &lt;a href="https://github.com/falcosecurity/rules/blob/c558fc7d2d02cc2c2edc968fe5770d544f1a9d55/rules/falco_rules.yaml#L2060" rel="noopener noreferrer"&gt;Falco community rules feed&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- rule: Terminal shell in container
  desc: A shell was used as the entrypoint/exec point into a container with an attached terminal.
  condition: &amp;gt;
    spawned_process and container
    and shell_procs and proc.tty != 0
    and container_entrypoint
    and not user_expected_terminal_shell_in_container_conditions
  output: &amp;gt;
    A shell was spawned in a container with an attached terminal (user=%user.name user_loginuid=%user.loginuid %container.info
    shell=%proc.name parent=%proc.pname cmdline=%proc.cmdline pid=%proc.pid terminal=%proc.tty container_id=%container.id image=%container.image.repository)
  priority: NOTICE
  tags: [container, shell, mitre_execution, T1059]Code language: Perl (perl)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above Falco community rule includes different use cases; proc.name is not just sh, it is a long list which is contained in shell_procs. As a result, this would lead to fewer false/positive detections and reduce the attackers’ chances of bypassing the rule. If the rules are too generic, it can potentially capture expected behavior.&lt;/p&gt;

&lt;p&gt;When asking our questions to ChatGPT, we need to be more precise to generate an accurate rule. For example, we would ask ChatGPT to create a Falco rule that detects suspicious login activity on a Linux workstation between certain hours of the day.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/image-30.png" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fimage-30-1170x918.png" alt="Chatgpt Falco OSS rule" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Again, we like how the rule looks. &lt;/p&gt;

&lt;p&gt;Since Falco is designed to handle Linux system calls, there is no need to explicitly mention the workstation OS type. However, ChatGPT nicely mentioned that the rule triggers for activity on Linux workstations because we specifically requested this. We will copy the code snippet and paste it below so that we can dissect it further:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- rule: Detect suspicious login activity during off-hours
  desc: Detects login sessions initiated during off-hours on a Linux workstation
  condition: (evt.time &amp;gt; "2022-12-31T02:00:00.000Z" and evt.time &amp;lt; "2022-12-31T07:00:00.000Z") and (evt.type=execve and evt.argc=3 and evt.argv[2]=login)
  output: Suspicious login activity detected during off-hours: user=%user.name command=%proc.cmdline
  priority: WARNINGCode language: Perl (perl)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Falco rule uses the below system call activity:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;a href="https://man7.org/linux/man-pages/man8/sysdig.8.html#:~:text=evt.time%20is%20the%20event%20timestamp" rel="noopener noreferrer"&gt;evt.time&lt;/a&gt; – This is the event timestamp. It’s between T02:00 (2 a.m.) and T07:00 (7 a.m.).&lt;/li&gt;
&lt;li&gt; &lt;a href="https://man7.org/linux/man-pages/man8/sysdig.8.html#:~:text=evt.type%20is%20the%20name%20of%20the%20event%2C%20e.g.%20%20%27open%27%20or%20%27read%27" rel="noopener noreferrer"&gt;evt.type&lt;/a&gt; – This is the name of the event, for example, ‘open’ or ‘read.’ In this case, it’s &lt;a href="https://man7.org/linux/man-pages/man2/execve.2.html" rel="noopener noreferrer"&gt;execve&lt;/a&gt;. The execve event executes the program referred to by pathname.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you are ever unsure about a certain argument used, what it means, or how to use it going forward, you can ask ChatGPT to elaborate on its findings without re-writing the entire question.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/image-31.png" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fimage-31-1170x918.png" alt="ChatGPT evt.argc and evt.argv" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since ChatGPT is a language model, it does a great job of not just providing rules, but also providing clarity on its findings. With this additional context provided by ChatGPT, we are happy with how this rule turned out. &lt;/p&gt;

&lt;p&gt;Since we don’t have any business need for this specific rule, let’s use ChatGPT to solve some real business problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  ChatGPT, MITRE ATT&amp;amp;CK, and Falco
&lt;/h2&gt;

&lt;p&gt;Continuing the conversation, we got more technical with ChatGPT and tried to combine two areas of expertise: Falco and MITRE.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://attack.mitre.org/matrices/enterprise/" rel="noopener noreferrer"&gt;MITRE ATT&amp;amp;CK framework&lt;/a&gt; for Enterprise environments is BIG! As a result, it can be hard to provide extensive coverage of all Tactics, Techniques, and Sub-Techniques for Linux Systems. &lt;/p&gt;

&lt;p&gt;Since ChatGPT can read and interpret large values of operational data, it speeds up the process of building Falco rules to better align with this widely-used risk framework.&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://github.com/falcosecurity/rules/blob/c558fc7d2d02cc2c2edc968fe5770d544f1a9d55/rules/falco_rules.yaml" rel="noopener noreferrer"&gt;Falco community rules feed&lt;/a&gt;, there was no existing rule aligned to the Technique ID ‘&lt;a href="https://attack.mitre.org/techniques/T1529/" rel="noopener noreferrer"&gt;T1529&lt;/a&gt;.’ For this technique ID, the adversaries may shutdown or reboot the workstation to interrupt access to workstations, or aid in the destruction of those systems. When requesting a rule that detects system shutdown or reboot, we also want to request the appropriate tagging for rules alignment with the MITRE ATT&amp;amp;CK framework. Surprisingly, &lt;strong&gt;ChatGPT answered with an incorrect tactic and technique associated with that technique ID&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/image-33.png" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fimage-33-1170x918.png" alt="ChatGPT Falco MITRE" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The technique &lt;a href="https://attack.mitre.org/techniques/T1538/" rel="noopener noreferrer"&gt;&lt;strong&gt;Cloud Service Dashboard&lt;/strong&gt;&lt;/a&gt; is assigned to the Tactic ‘&lt;strong&gt;Discovery&lt;/strong&gt;’ and the associated Technique ID T1538. Whereas, the technique ID T1529 is associated with &lt;a href="https://attack.mitre.org/techniques/T1529/" rel="noopener noreferrer"&gt;&lt;strong&gt;shutdown/reboot activity&lt;/strong&gt;&lt;/a&gt;, this would be aligned with the Tactic ‘&lt;strong&gt;Impact&lt;/strong&gt;.’ &lt;/p&gt;

&lt;p&gt;For the first time, ChatGPT made an obvious mistake in its answer. When we confronted ChatGPT, it immediately apologized and provided an amended answer that looks more like the Falco rule we would expect.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/image-32.png" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fimage-32-1170x918.png" alt="ChatGPT Falco MITRE wrong" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This regained my trust in ChatGPT becoming an approved Falco contributor. &lt;/p&gt;

&lt;p&gt;However, since we cannot guarantee that ChatGPT is going to return the correct rule, we also need to validate that the rule conditions are valid.&lt;/p&gt;

&lt;p&gt;Again, I’ve pasted the findings into the following snippet field for further inspection. As mentioned by ChatGPT, this rule checks for &lt;em&gt;execve&lt;/em&gt; events where the second argument (evt.argv[1]) contains either shutdown or reboot. This indicates that the process is attempting to shut down or reboot the system, which is a technique used to disrupt normal system operation and, therefore, correctly aligns with the MITRE tactic and technique.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- rule: Detect T1529 - System Shutdown/Reboot
  desc: Detects attempts to shut down or reboot the system
  condition: (evt.type=execve and (evt.argv[1] contains "shutdown" or evt.argv[1] contains "reboot"))
  output: "Detected attempt to shut down or reboot the system. T1529 - System Shutdown/Reboot detected"
  priority: WARNING
  tags: [tactic=impact, technique=T1529, technique_id=T1529]Code language: Perl (perl)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So far, we have learned that we cannot rely on ChatGPT to contribute Falco rules without being vetted by an experienced Falco user. &lt;/p&gt;

&lt;p&gt;That said, ChatGPT has quickly contributed rules that can be used to address regulatory frameworks and/or risk frameworks such as MITRE ATT&amp;amp;CK. The injected tags allow users to categorize and track detections of this technique within your security management tooling.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to detect cryptomining with ChatGPT and Falco
&lt;/h2&gt;

&lt;p&gt;The rules we have created so far are fairly simplistic. In order to test the true power of ChatGPT, we need to ask it for help creating more complex Falco rules involving additional abstractions such as &lt;a href="https://falco.org/docs/rules/appending/" rel="noopener noreferrer"&gt;Macros and Lists&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;An example that we were working on recently was the creation of a small list of known cryptomining binaries for a &lt;a href="https://community.cncf.io/events/details/cncf-cncf-online-programs-presents-cloud-native-live-detecting-crypto-jacking-in-kubernetes-workloads/" rel="noopener noreferrer"&gt;CNCF Livestream&lt;/a&gt;. We would like to see how ChatGPT addresses this request.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/image-36.png" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fimage-36-1170x769.png" alt="ChatGPT Falco Rule Cryptomining" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We were disappointed with this response. &lt;/p&gt;

&lt;p&gt;While the syntax is valid, the default approach from ChatGPT is always to list the process names within the Falco rule, rather than creating a list of known binaries, and mapping this to the Falco rules via a referenced Macro. &lt;/p&gt;

&lt;p&gt;We can ask ChatGPT to specifically reference the binaries in the List.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/image-35.png" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fimage-35-1170x861.png" alt="ChatGPT Falco List" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Funnily, ChatGPT was even more confused by this instruction to the point where it started appending syntax that is foreign to the Falco rules syntax. &lt;/p&gt;

&lt;p&gt;At this point, the rule would no longer work and ChatGPT is losing credibility as a valid contributor to the Falco project.&lt;/p&gt;

&lt;p&gt;As an experienced Falco user, I had to explain that ChatGPT misunderstood my request and that further evaluation is required. It’s not that ChatGPT is unable to answer the request, but it can misunderstand certain aspects of the request depending on our phrasing. &lt;/p&gt;

&lt;p&gt;That’s why your request might require further fine tuning, but we can see that ChatGPT got there in the end. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/image-34.png" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fimage-34-1170x913.png" alt="Wrong Falco List" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ChatGPT has given us a correctly-formatted Falco rule, which is a great foundation for further development. However, the rule is certainly not foolproof. &lt;/p&gt;

&lt;p&gt;There are many examples of cryptomining binaries other than ‘&lt;a href="https://xmrig.com/download" rel="noopener noreferrer"&gt;&lt;strong&gt;xmrig&lt;/strong&gt;&lt;/a&gt;’ – though xmrig is certainly the most common example. The value here is creating an extensive, up-to-date list of all common binaries so we can provide as much security coverage as possible. We mention some of these binaries in the following &lt;a href="https://falco.org/blog/falco-detect-cryptomining/#list" rel="noopener noreferrer"&gt;Falco blog&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can ChatGPT create Falco plugins?
&lt;/h2&gt;

&lt;p&gt;Don’t get disappointed. Let’s see if ChatGPT is able to help us create a plugin for Falco.&lt;/p&gt;

&lt;p&gt;It’s super important to understand how ChatGPT responds to generic commands. When we asked if ChatGPT can create Falco plugins, it said, “&lt;em&gt;I do not have the ability to write or compile code. However, I can assist you in writing the code for a Falco plugin&lt;/em&gt;.”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/image-37.png" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fimage-37-1170x816.png" alt="ChatGPT Falco Plugins" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s also worth noting that ChatGPT explains the supported protocol (gRPC) and the languages that support it (C++, Go, or Python). &lt;/p&gt;

&lt;p&gt;In that case, we just need to ask for guidance in how to write a Falco plugin. We need the request to be for a specific service for this request to be effective. Since &lt;a href="https://www.ghacks.net/2023/02/10/if-you-use-lastpass-you-need-to-change-all-of-your-passwords-asap/" rel="noopener noreferrer"&gt;LastPass is in the news lately&lt;/a&gt;, we will ask ChatGPT to help us create a LastPass Plugin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/image-38.png" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fimage-38-1170x911.png" alt="LastPass Falco Plugin" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Amazingly, the below Python code snippet was provided to help configure a LastPass plugin with the appropriate gRPC protocol that we mentioned previously.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import grpc
from falco_proto import event_pb2
from falco_proto import event_pb2_grpc

class LastPassPlugin(event_pb2_grpc.EventServiceServicer):
    def HandleEvent(self, request, context):
        event = request.event
        if event.event_type == "executed" and event.output.find("lastpass-cli") != -1:
            print("LastPass CLI was executed")
        return event_pb2.HandleEventResponse()

server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
event_pb2_grpc.add_EventServiceServicer_to_server(LastPassPlugin(), server)
server.add_insecure_port('[::]:50051')
server.start()
server.wait_for_termination()Code language: Perl (perl)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code sets up a gRPC server and implements a custom HandleEvent method that is called whenever a Falco event occurs. The method checks if the event is an “executed” event and if the output contains the string “lastpass-cli.” If both conditions are met, it prints a message indicating that LastPass CLI was executed.&lt;/p&gt;

&lt;p&gt;Note that this is just a basic example. ChatGPT clearly explains that this was provided as guidance and therefore you will likely need to modify the code to meet your specific requirements. &lt;/p&gt;

&lt;p&gt;For more information on creating Falco plugins, we would recommend referring to the &lt;a href="https://falco.org/docs/plugins/developers-guide/" rel="noopener noreferrer"&gt;official Falco documentation&lt;/a&gt; and the gRPC protocol documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can ChatGPT contribute to the Falco project?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Unfortunately, no!&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;As ChatGPT explained to us, it can help with the rule creation. But as an &lt;strong&gt;AI language model, it is not authorized to create pull requests&lt;/strong&gt;. As a result, ChatGPT cannot be officially included as a contributor to the open source project. However, project contributors and community members can rely on ChatGPT to validate their rule formatting, identify discrepancies in misconfigured rules, as well as provide insights on how a rule should be formatted to address a framework requirement.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/image-39.png" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fimage-39-1170x736.png" alt="ChatGPT Falco PR" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;ChatGPT is a powerful language model that can assist in creating Falco security rules. With its vast knowledge of various topics and its ability to generate text, it can provide helpful guidance and examples of how to create a rule that detects a specific threat. However, while it can be a valuable resource, ChatGPT should not be trusted to fully automate the creation of security rules. &lt;/p&gt;

&lt;p&gt;The accuracy and relevance of the information it provides can be limited by its training data and its knowledge cutoff, and it may not have the expertise or context to make informed decisions about the specific security needs of an organization. Additionally, security rule creation is an ongoing process that requires constant monitoring, tuning, and updating to keep up with new threats and changes in technology. &lt;/p&gt;

&lt;p&gt;Therefore, it is an option to use ChatGPT and consult security experts to verify and refine the rules before deploying them in a production environment.&lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>security</category>
      <category>devops</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Getting started with kubectl plugins</title>
      <dc:creator>Miguel</dc:creator>
      <pubDate>Wed, 18 Jan 2023 16:46:11 +0000</pubDate>
      <link>https://dev.to/sysdig/getting-started-with-kubectl-plugins-372e</link>
      <guid>https://dev.to/sysdig/getting-started-with-kubectl-plugins-372e</guid>
      <description>&lt;p&gt;Let's dig deeper into this list of Kubectl plugins that we strongly feel will be very useful for anyone, especially security engineers.&lt;/p&gt;

&lt;p&gt;Kubernetes, by design, is incredibly customizable. Kubernetes supports custom configurations for specific use case scenarios. This eliminates the need to apply patches to underlying features. Plugins are the means to extend Kubernetes features and deliver out-of-the-box offerings.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Kubernetes Plugins?
&lt;/h2&gt;

&lt;p&gt;Users can install and write extensions for kubectl, the &lt;a href="https://kubernetes.io/docs/reference/kubectl/" rel="noopener noreferrer"&gt;Kubernetes command line tool&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;By observing the core kubectl commands as essential building blocks for interacting with a Kubernetes cluster, a cluster administrator can think of plugins as a means of utilizing these building blocks to create more complex behavior.&lt;/p&gt;

&lt;p&gt;Plugins extend kubectl with new sub-commands, allowing for new and custom features not included in the main distribution of kubectl.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why are plugins useful for security operations?
&lt;/h3&gt;

&lt;p&gt;Kubernetes plugins provide countless security benefits to the platform. Incident responders can develop additional functionality “on the fly” in their language of choice.&lt;/p&gt;

&lt;p&gt;Since Kubernetes features often fall short in cases where businesses need to achieve “out-of-scope” functionality, teams will often need to implement their own custom operations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Potential security considerations for Kubernetes plugins
&lt;/h2&gt;

&lt;p&gt;While custom implementations add functionality that is not necessarily provided out-of-the-box with &lt;em&gt;kubectl&lt;/em&gt;, these plugins are not always as secure as we would like them to be. This article aims to address the most common or &lt;strong&gt;useful Kubernetes plugins for improving your security posture&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Managing plugins with Krew
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://krew.sigs.k8s.io/" rel="noopener noreferrer"&gt;Krew&lt;/a&gt; is a plugin manager maintained by the Kubernetes Special Interest Group (&lt;a href="https://github.com/kubernetes/community/blob/master/sig-cli/README.md" rel="noopener noreferrer"&gt;SIG&lt;/a&gt;) CLI community. Krew makes it easy to use kubectl plugins and helps you discover, install, and manage them on your machine. It is similar to tools like &lt;a href="https://en.wikipedia.org/wiki/APT_(software)" rel="noopener noreferrer"&gt;apt&lt;/a&gt;, &lt;a href="https://en.wikipedia.org/wiki/DNF_(software)" rel="noopener noreferrer"&gt;dnf&lt;/a&gt;, or &lt;a href="https://en.wikipedia.org/wiki/Homebrew_(package_manager)" rel="noopener noreferrer"&gt;brew&lt;/a&gt;. Today, over 200 kubectl plugins are available on Krew - and that number is only increasing. Some projects are actively used and some get deprecated over time, but are still accessible via Krew.&lt;/p&gt;

&lt;p&gt;Command to install kubectl plugins via Krew:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install &amp;lt;PLUGIN_NAME&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Kubectl plugins available via the Krew plugin index are &lt;strong&gt;not audited, which can cause a problem in the &lt;a href="https://sysdig.com/blog/software-supply-chain-security/" rel="noopener noreferrer"&gt;supply chain&lt;/a&gt;&lt;/strong&gt;. As mentioned earlier, the Krew plugin index houses hundreds of kubectl plugins:&lt;br&gt;&lt;br&gt;
&lt;a href="https://krew.sigs.k8s.io/plugins/" rel="noopener noreferrer"&gt;https://krew.sigs.k8s.io/plugins/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you install and run third-party plugins, you are doing this at your own risk. At the end of the day, kubectl plugins are just arbitrary programs running in your shell.&lt;/p&gt;

&lt;p&gt;Finally, we want to share our top 15 kubectl plugins that will improve your security posture in your Kubernetes cluster.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Stern plugin
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/stern/stern" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stern&lt;/strong&gt; is a kubectl plugin that works a lot like ‘&lt;a href="https://linuxways.net/centos/tail-command-in-linux/" rel="noopener noreferrer"&gt;tail -f&lt;/a&gt;’ in Linux. Unlike &lt;strong&gt;kubectl log -f&lt;/strong&gt;, which has its own limitations around input parameters, Stern allows you to specify both the Pod ID and the Container ID as regular expressions.&lt;/p&gt;

&lt;p&gt;Any match will be followed and the output is multiplexed together, prefixed with the Pod and Container ID, and color-coded for human consumption (colors are stripped if piping to a file).&lt;/p&gt;

&lt;p&gt;You can install Stern with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install stern
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Command to tail an appname in Stern:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl stern appname
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will match any pod containing the word service and listen to all containers within it. If you only want to see traffic to the server container, you could do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl stern --container 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will stream the logs of all the server containers, even if running in multiple pods.&lt;/p&gt;

&lt;p&gt;One interesting security use case for the Stern plugin is to look at authentication activity to your Kubernetes clusters. To show the authentication activity within the last 15 minutes with relevant highlighted timestamps, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl stern -t --since 15m auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. RBAC-tool
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/alcideio/rbac-tool" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Role-based access control (&lt;a href="https://sysdig.com/learn-cloud-native/kubernetes-security/kubernetes-rbac/" rel="noopener noreferrer"&gt;RBAC&lt;/a&gt;) is a method of regulating access to computer or network resources based on the roles of individual users within your organization. The RBAC-tool simplifies querying and the creation of RBAC policies.&lt;/p&gt;

&lt;p&gt;You can install the &lt;strong&gt;RBAC-tool&lt;/strong&gt; with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install rbac-tool
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are unfamiliar with how RBAC roles are assigned to different Kubernetes components, the visualization command generates an insightful graph of all RBAC decisions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl rbac-tool viz --cluster-context nigel-douglas-cluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command scans the cluster with the kubeconfig context '&lt;strong&gt;nigel-douglas-cluster&lt;/strong&gt;.' These graphs are useful for showing a visual before-and-after of permissions assigned to service accounts.&lt;/p&gt;

&lt;p&gt;There are multiple commands other than ‘&lt;strong&gt;viz&lt;/strong&gt;’ provided by the RBAC-tool plugin. The most useful is the ‘&lt;strong&gt;who-can&lt;/strong&gt;’ command. This shows which subjects have RBAC permissions to perform an action denoted by ‘VERB’ (Create, Read, Update, or Delete) on an object.&lt;/p&gt;

&lt;p&gt;To see who can read a secret resource by the name ‘&lt;strong&gt;important-secret&lt;/strong&gt;,’ run the below command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl rbac-tool who-can get secret/important-secret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Cilium Plugin
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/bmcustodio/kubectl-cilium" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cilium&lt;/strong&gt; is a network security project that continues to grow in popularity due to its powerful eBPF dataplane. Since Kubernetes is not designed with any specific &lt;a href="https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/" rel="noopener noreferrer"&gt;CNI (Network) Plugin&lt;/a&gt; in mind, it can be deciduous trying to manage the Cilium agent via kubectl. That’s why the Cilium team released the Cilium kubectl plugin.&lt;/p&gt;

&lt;p&gt;You can install the &lt;strong&gt;Cilium&lt;/strong&gt; plugin with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install cilium
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As a basic first step, you can do a connectivity check for a single node powered by Cilium networking via the below command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl cilium connectivity test --single-node &amp;lt;node&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This doesn’t just provide improved operational visibility - it’s incredibly beneficial to network security engineers. For instance, if Cilium is unable to communicate with core components such as ‘&lt;a href="https://github.com/cilium/hubble" rel="noopener noreferrer"&gt;Hubble&lt;/a&gt;,’ this will show-up in the connectivity test.&lt;/p&gt;

&lt;p&gt;Hubble provides network, service, and security observability for Kubernetes. Being able to quickly diagnose a connection error, such as “connection refused,” improves the overall visibility of threats and provides the centralized network event view required to maintain regulatory compliance. If you want to dig deeper into network policies, discover &lt;a href="https://sysdig.com/blog/denial-of-service-kubernetes-calico-falco/" rel="noopener noreferrer"&gt;how to prevent a Denial of Service (DoS) attack on Kubernetes&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Kube Policy Advisor
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/sysdiglabs/kube-policy-advisor" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The kube-policy-advisor plugin suggests PodSecurityPolicies and Open Policy Agent (OPA) Policies for your Kubernetes cluster. While &lt;a href="https://kubernetes.io/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/" rel="noopener noreferrer"&gt;PodSecurityPolicies are deprecated&lt;/a&gt;, and therefore should not be used, OPA is very much a recommended tool for &lt;a href="https://sysdig.com/learn-cloud-native/kubernetes-security/kubernetes-admission-controllers/" rel="noopener noreferrer"&gt;admission controller&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can install &lt;strong&gt;advise-policy&lt;/strong&gt; with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install advise-policy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This kubectl plugin provides security and compliance checks for Kubernetes clusters. It can help identify potential security risks and violations of best practices in a cluster's configuration, and provide recommendations for how to remediate those issues. Some examples of the types of checks that kube-policy-advisor can perform include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Ensures pods are running with minimal privileges and are not granted unnecessary permissions.&lt;/li&gt;
&lt;li&gt;  Checks that secrets and other sensitive data are not stored in plain text or checked into source control.&lt;/li&gt;
&lt;li&gt;  Verifies that network policies are in place to protect against unauthorized access to resources.&lt;/li&gt;
&lt;li&gt;  Evaluates the security of container images and ensures that they come from trusted sources.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Kubernetes, Admission Controllers enforce semantic validation of objects during create, update, and delete operations. With OPA, you can enforce custom policies on Kubernetes objects without recompiling or reconfiguring the Kubernetes API server.&lt;/p&gt;

&lt;p&gt;kube-policy-advisor is a tool that makes it easier to create OPA Policy from either a live K8s environment or from a single .yaml file containing a pod specification (Deployment, DaemonSet, Pod, etc.). In the below command, the plugin inspects any given namespace to print a report or OPA Policy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl advise-policy inspect --namespace=&amp;lt;ns&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: If you do not enter a given namespace, it will generate the OPA Policy for all network namespace.&lt;/p&gt;

&lt;p&gt;By using kube-policy-advisor, you can help ensure that your Kubernetes cluster is secure and compliant with best practices, which can help protect your applications and data from potential threats.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Kubectl-ssm-secret
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/pr8kerl/kubectl-ssm-secret" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;kubectl-ssm-secret&lt;/strong&gt; plugin allows admins to import or export their &lt;a href="https://sysdig.com/learn-cloud-native/kubernetes-101/how-to-create-and-use-kubernetes-secrets/" rel="noopener noreferrer"&gt;Kubernetes Secrets&lt;/a&gt; to or from an &lt;a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/what-is-systems-manager.html" rel="noopener noreferrer"&gt;AWS SSM&lt;/a&gt; Parameter Store path. A Kubernetes Secret is sensitive information – such as a password or access key – that is used within a Kubernetes environment. It’s important to be able to safely control these sensitive credentials when transmitting between Kubernetes and AWS cloud.&lt;/p&gt;

&lt;p&gt;You can install the &lt;strong&gt;ssm-secret&lt;/strong&gt; plugin with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install ssm-secret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Secrets are not unique to Kubernetes, of course. You use Secrets’ data in virtually every type of modern application environment or platform. In the case of the ssm-secret plugin, all parameters found under a given parameter store path can be imported into a single kubernetes secret as “StringData.”&lt;/p&gt;

&lt;p&gt;This is incredibly useful if you are reprovisioning clusters or namespaces and need to provision the same secrets over and over. Also, it could be useful to backup/restore your &lt;a href="https://letsencrypt.org/" rel="noopener noreferrer"&gt;LetsEncrypt&lt;/a&gt; or other certificates.&lt;/p&gt;

&lt;p&gt;If an AWS parameter at path /foo/bar contains a secret value, and the parameter /foo/passwd contains a secure password, we can view the keys and values in parameter store using the kubectl ssm-secret list subcommand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl ssm-secret list --ssm-path /foo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those output parameters can then be imported with the following import command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl ssm-secret import foo --ssm-path /foo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Security considerations
&lt;/h4&gt;

&lt;p&gt;You must specify a single parameter store path for this plugin to work. It will not recursively search more than one level under a given path. As a result, the plugin is highly opinionated, and users run the risk of failing to import/export secrets to the correct path if they don’t track these paths correctly.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Kubelogin
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/int128/kubelogin" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’re running Kubectl versions v.1.12 or higher, Kubelogin (also known as &lt;strong&gt;&lt;em&gt;kubectl-login&lt;/em&gt;&lt;/strong&gt;) is a useful security plugin for logging into clusters via the CLI. It achieves this through &lt;a href="https://openid.net/connect/" rel="noopener noreferrer"&gt;OpenID Connect&lt;/a&gt; providers like DEX. OpenID Connect is a simple identity layer on top of the OAuth 2.0 protocol. It allows Clients to verify the identity of the End-User based on the authentication performed by an Authorization Server, as well as to obtain basic profile information about the End-User in an interoperable and REST-like manner.&lt;/p&gt;

&lt;p&gt;You can install the &lt;strong&gt;kubectl-login&lt;/strong&gt; plugin with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install kubectl-login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your OpenID Connect provider must have the default callback endpoint for the Kubernetes API Client listed within the OpenID configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:33768/auth/callback
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This Kubectl plugin takes the OpenID Connect (OIDC) issuer URL from your &lt;em&gt;.kube/config&lt;/em&gt;, so it must be placed in your &lt;em&gt;.kube/config&lt;/em&gt;. Once you have made this change to the kubeconfig file, you can proceed to use your username assigned to your OIDC provider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl login nigeldouglas-oidc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this command is executed in your CLI, the browser will be opened with a redirect to the OpenID Connect Provider login page. The tokens in your kubeconfig file will be replaced after a successful authentication on the OIDC provider’s end.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Kubectl-whisper-secret
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/rewanthtammana/kubectl-whisper-secret" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We mentioned the importance of securing sensitive credentials like ‘Secrets’ using the kubectl-ssm-secret plugin. The whisper-secret plugin focuses on creating those secrets with improved privacy. The plugin allows users to create secrets with secure input prompts to prevent information leakages through &lt;a href="https://gist.github.com/JPvRiel/df1d4c795ebbcad522188759c8fd69c7" rel="noopener noreferrer"&gt;terminal (bash) history&lt;/a&gt;, &lt;a href="https://capec.mitre.org/data/definitions/508.html" rel="noopener noreferrer"&gt;shoulder surfing&lt;/a&gt; attacks, etc.&lt;/p&gt;

&lt;p&gt;You can install the &lt;strong&gt;whisper-secret&lt;/strong&gt; plugin with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install whisper-secret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;’kubectl create secret’&lt;/strong&gt; has a few sub-commands we use most often that can possibly leak sensitive information in multiple ways, as mentioned above. For example, you can connect to a Docker registry via the &lt;strong&gt;’kubectl create secret’&lt;/strong&gt; command with a plain-text password for authentication.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create secret docker-registry my-secret --docker-password nigelDouglasP@ssw0rD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;’kubectl whisper-secret’&lt;/strong&gt; plugin allows users to create secrets with a secure input prompt for fields like &lt;strong&gt;--from-literal&lt;/strong&gt; and &lt;strong&gt;--docker-password&lt;/strong&gt; that contain sensitive information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl whisper-secret docker-registry my-secret --docker-password -- -n nigel-test --docker-username &amp;lt;insert-password&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You are then prompted to enter the Docker password, but this is not inserted into the command itself. This way, the password will not show-up in the bash history as a plain text value, increasing security.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Kubectl-capture
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/sysdiglabs/kubectl-capture" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sysdig open source (&lt;a href="https://sysdig.com/blog/sysdig-inspect/" rel="noopener noreferrer"&gt;Sysdig Inspect&lt;/a&gt;) is a powerful tool for container troubleshooting, performance tuning, and security investigation. The team at Sysdig created a kubectl plugin which triggers a packet capture in the underlying host which is running a pod.&lt;/p&gt;

&lt;p&gt;You can install the &lt;strong&gt;kubectl-capture&lt;/strong&gt; plugin with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install kubectl-capture
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Packet captures are incredibly useful for &lt;a href="https://sysdig.com/blog/guide-kubernetes-forensics-dfir/" rel="noopener noreferrer"&gt;incident response and forensics in Kubernetes&lt;/a&gt;. The capture file is created for a duration of time and is downloaded locally in order to use it with &lt;a href="https://github.com/draios/sysdig-inspect" rel="noopener noreferrer"&gt;Sysdig Inspect&lt;/a&gt;, a powerful open source interface designed to intuitively navigate the data-dense Sysdig captures that contain granular system, network, and application activity of a Linux system.&lt;/p&gt;

&lt;p&gt;Simply run the below command against any running pod in the cluster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl capture kinsing-78f5d695bd-bcbd8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the capture container is being spun, it takes some time to compile the Sysdig Kernel module and capture system calls. Once completed, you can read the content within the Sysdig Inspect UI from your workstation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2FScreenshot-2023-01-16-at-16.22.46.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2FScreenshot-2023-01-16-at-16.22.46.png" title="Sysdig Inspect" alt="alt_text" width="800" height="496"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
With these tools, it will be much easier for the analyst to find the source of the problem or to audit what happened. If you want to go deeper, you can read &lt;a href="https://sysdig.com/blog/sysdig-inspect/" rel="noopener noreferrer"&gt;container troubleshooting with Sysdig Inspect&lt;/a&gt; or &lt;a href="https://sysdig.com/blog/triaging-malicious-docker-container/" rel="noopener noreferrer"&gt;triaging malicious containers&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  9. Kubectl-trace
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/iovisor/kubectl-trace" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;kubectl-trace&lt;/strong&gt; is a kubectl plugin that allows you to schedule the execution of bpftrace programs in your Kubernetes cluster. In short, Kubectl-trace plugin is a tool for distributed tracing in Kubernetes clusters. It allows you to trace the execution of requests as they pass through different components of a cluster, including pods, services, and ingress controllers.&lt;/p&gt;

&lt;p&gt;You can install the &lt;strong&gt;kubectl-trace&lt;/strong&gt; plugin with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install trace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One potential security benefit of using the Kubectl-trace plugin is that it can help you identify and troubleshoot issues related to request handling within a cluster. For example, if you suspect that a particular request is being blocked or slowed down due to some issue in the cluster, you can use Kubectl-trace to track the request as it travels through the cluster and identify the source of the problem.&lt;/p&gt;

&lt;p&gt;This plugin runs a program that probes a tracepoint on the node of choice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl trace run &amp;lt;node-name&amp;gt; -e "tracepoint:syscalls:sys_enter_* { @[probe] = count(); }"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another potential security benefit is that Kubectl-trace can help you understand how requests are being handled within a cluster, which can be useful for identifying potential vulnerabilities or misconfigurations. For example, if you see that a request is being handled by a pod or service that has been compromised, you can use Kubectl-trace to track the request and identify the source of the issue.&lt;/p&gt;

&lt;p&gt;Overall, the Kubectl-trace plugin can be a useful tool for improving the security of a Kubernetes cluster by helping to identify and address issues related to request handling and execution.&lt;/p&gt;

&lt;h3&gt;
  
  
  10. Access-matrix
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/corneliusweig/rakkess" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Access-matrix&lt;/strong&gt; (often referred to as ‘Rakkess’) is a kubectl plugin that shows an access matrix for your server resources.&lt;/p&gt;

&lt;p&gt;You can install the &lt;strong&gt;access-matrix&lt;/strong&gt; plugin with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install access-matrix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Simply run the below command to see the Create, Read, Update &amp;amp; Delete (CRUD) permissions for all resources in the ‘default’ network namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl rakkess –n default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some roles only apply to resources with a specific name. To review such configurations, provide the resource name as an additional argument. For example, show access rights for the ConfigMap called &lt;strong&gt;sysdig-controller&lt;/strong&gt; in namespace &lt;strong&gt;sysdig-agent&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl access-matrix r cm sysdig-controller -n sysdig-agent --verbs=all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As rakkess resource needs to query &lt;strong&gt;Roles&lt;/strong&gt;, &lt;strong&gt;ClusterRoles&lt;/strong&gt;, and their &lt;strong&gt;bindings&lt;/strong&gt;, it usually requires administrative cluster access.&lt;/p&gt;

&lt;h3&gt;
  
  
  11. Rolesum
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/Ladicle/kubectl-rolesum" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Rolesum kubectl plugin is a tool for generating a summary of the roles and permissions defined in a Kubernetes cluster. It allows you to see all of the roles and permissions that have been defined in a cluster, along with the users and groups that have been granted those roles. Summarize RBAC roles for the specified subject (ServiceAccount, User, and Group).&lt;/p&gt;

&lt;p&gt;You can install the &lt;strong&gt;rolesum&lt;/strong&gt; plugin with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install rolesum
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One potential security benefit of using the Rolesum kubectl plugin is that it can help you identify and understand the roles and permissions that have been defined in a cluster. This can be useful for ensuring that appropriate access controls have been put in place, and for identifying potential vulnerabilities or misconfigurations.&lt;/p&gt;

&lt;p&gt;You can summarize roles bound to the "nigeldouglas" ServiceAccount.&lt;br&gt;&lt;br&gt;
By default, rolesum looks for serviceaccounts. There’s no need to specify any flag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl rolesum nigeldouglas
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another potential security benefit is that Rolesum can help you quickly identify users and groups that have been granted certain roles or permissions, which can be useful for troubleshooting issues or for performing security assessments.&lt;/p&gt;

&lt;p&gt;For example, you can summarize roles bound to the "staging" group.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl rolesum -k Group staging
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Overall, the Rolesum kubectl plugin can be a useful tool for improving the security of a Kubernetes cluster by helping you understand and manage the roles and permissions that have been defined in the cluster.&lt;/p&gt;

&lt;h3&gt;
  
  
  12. Cert-Manager
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/cert-manager/cert-manager" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cert-Manager is a Kubectl plugin that provides automatic management of Transport Layer Security (TLS) certificates within a cluster. It allows you to easily provision, manage, and renew TLS certificates for your applications without having to manually handle the certificate signing process.&lt;/p&gt;

&lt;p&gt;You can install the &lt;strong&gt;cert-manager&lt;/strong&gt; plugin with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install cert-manager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One potential security benefit of using cert-manager is that it can help you ensure that your applications are using valid, up-to-date TLS certificates. This can be important for protecting the confidentiality and integrity of communication between your applications and their users.&lt;/p&gt;

&lt;p&gt;Another potential security benefit is that cert-manager can help you automate the process of obtaining and renewing TLS certificates, which can reduce the risk of certificate expiration or mismanagement.&lt;/p&gt;

&lt;p&gt;Overall, the cert-manager kubectl plugin can be a useful tool for improving the security of a Kubernetes cluster by helping you to manage TLS certificates in a secure and automated manner. The cert-manager plugin is loosely based upon the work of kube-lego and has borrowed some wisdom from other similar projects, such as kube-cert-manager.&lt;/p&gt;

&lt;h3&gt;
  
  
  13. np-viewer
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/runoncloud/kubectl-np-viewer" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The kubectl-np-viewer plugin is a tool for visualizing the network topology of a Kubernetes cluster. It allows you to view the connections between pods, services, and other resources within a cluster in a graphical format.&lt;/p&gt;

&lt;p&gt;You can install the &lt;strong&gt;np-viewer&lt;/strong&gt; plugin with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install np-viewer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unlike the Cilium plugin we mentioned earlier, the kubectl-np-viewer plugin helps users understand and visualize the communication patterns within a cluster regardless of the CNI plugin used. The Cilium plugin only helps manage Cilium resources, such as the Cilium network policy. By viewing the default Kubernetes network policies, teams who are starting off with Kubernetes networking benefit from useful visibility into potential vulnerabilities or misconfigurations, such as pods that are communicating with unintended resources or are exposed to the internet.&lt;/p&gt;

&lt;p&gt;The below command prints network policies rules affecting a specific pod in the current namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl np-viewer -p pod-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similarly, a potential security benefit from the kubectl-np-viewer plugin is that it helps users troubleshoot network issues within a cluster. For example, if you are experiencing connectivity issues between pods or services, you can use the plugin to visualize the connections between those resources and identify the source of the problem across all network namespace.&lt;/p&gt;

&lt;p&gt;The below command prints all network policies rules for all namespaces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl np-viewer --all-namespaces
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Overall, the kubectl-np-viewer plugin can be a useful tool for improving the security of a Kubernetes cluster by helping you to understand and monitor the network topology of the cluster. Not all businesses have moved to advanced network policy implementations, such as Calico and Cilium. While users are exploring the Kubernetes Network Policy implementation, they can better understand how their policies control potentially unwanted/malicious traffic within their cluster with this security plugin.&lt;/p&gt;

&lt;h3&gt;
  
  
  14. ksniff
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/eldadru/ksniff" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The ksniff kubectl plugin is a tool for capturing and analyzing network traffic in a Kubernetes cluster. It can be used to troubleshoot network issues, monitor traffic patterns, and perform security assessments.&lt;/p&gt;

&lt;p&gt;You can install the &lt;strong&gt;ksniff&lt;/strong&gt; plugin with the below Krew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install ksniff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One benefit of using ksniff is that it allows you to capture and analyze traffic without having to directly access the nodes in a cluster. This can be helpful in situations where you don't have direct access to the nodes, or where you want to minimize the potential impact of capturing traffic on the cluster.&lt;/p&gt;

&lt;p&gt;Another benefit is that ksniff can be used to capture traffic between pods and services, which can be useful for understanding how applications communicate within a cluster. This is helpful for troubleshooting issues, optimizing performance, and identifying potential security vulnerabilities.&lt;/p&gt;

&lt;p&gt;Overall, the ksniff kubectl plugin can be a useful tool for improving the security of a Kubernetes cluster by helping to identify and address network-related issues and vulnerabilities. It achieves this by sniffing on Kubernetes pods with existing technologies, such as TCPdump and WireShark.&lt;/p&gt;

&lt;h3&gt;
  
  
  15. Inspektor-Gadget
&lt;/h3&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/inspektor-gadget/inspektor-gadget" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inspektor-Gadget&lt;/strong&gt; is one of the most useful kubectl plugins. The plugin executes within the user's system and as a DaemonSet when deployed within the cluster. It is actually a collection of tools (or gadgets) to debug and inspect Kubernetes resources and applications.&lt;/p&gt;

&lt;p&gt;You can install the &lt;strong&gt;gadget&lt;/strong&gt; plugin with the belowKkrew command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl krew install gadget
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can deploy one or more gadgets. Example gadgets are categorized into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Advice&lt;/strong&gt; (Generates &lt;a href="https://github.com/inspektor-gadget/inspektor-gadget/blob/main/docs/guides/advise/seccomp-profile.md" rel="noopener noreferrer"&gt;seccomp profiles&lt;/a&gt; and &lt;a href="https://github.com/inspektor-gadget/inspektor-gadget/blob/main/docs/guides/advise/network-policy.md" rel="noopener noreferrer"&gt;network policies&lt;/a&gt; for the cluster)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Audit&lt;/strong&gt; (Traces the system calls that the &lt;a href="https://github.com/inspektor-gadget/inspektor-gadget/blob/main/docs/guides/audit/seccomp.md" rel="noopener noreferrer"&gt;seccomp profile&lt;/a&gt; sends to the audit log)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Profile&lt;/strong&gt; (Analyzes &lt;a href="https://github.com/inspektor-gadget/inspektor-gadget/blob/main/docs/guides/profile/block-io.md" rel="noopener noreferrer"&gt;Block I/O&lt;/a&gt; through distributed latency and &lt;a href="https://github.com/inspektor-gadget/inspektor-gadget/blob/main/docs/guides/profile/cpu.md" rel="noopener noreferrer"&gt;CPU Perf&lt;/a&gt; by sampled stack traces)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Snapshot&lt;/strong&gt; (Gather information about running &lt;a href="https://github.com/inspektor-gadget/inspektor-gadget/blob/main/docs/guides/snapshot/process.md" rel="noopener noreferrer"&gt;processes&lt;/a&gt; and TCP/UDP &lt;a href="https://github.com/inspektor-gadget/inspektor-gadget/blob/main/docs/guides/snapshot/socket.md" rel="noopener noreferrer"&gt;sockets&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Top&lt;/strong&gt; (Periodically report &lt;a href="https://github.com/inspektor-gadget/inspektor-gadget/blob/main/docs/guides/top/block-io.md" rel="noopener noreferrer"&gt;block device I/O&lt;/a&gt; activity, &lt;a href="https://github.com/inspektor-gadget/inspektor-gadget/blob/main/docs/guides/top/ebpf.md" rel="noopener noreferrer"&gt;eBPF&lt;/a&gt; runtime stats, and read/write activity by &lt;a href="https://github.com/inspektor-gadget/inspektor-gadget/blob/main/docs/guides/top/file.md" rel="noopener noreferrer"&gt;file&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Trace&lt;/strong&gt; (Trace almost all activity from &lt;a href="https://github.com/inspektor-gadget/inspektor-gadget/blob/main/docs/guides/trace/dns.md" rel="noopener noreferrer"&gt;DNS&lt;/a&gt; queries/responses to &lt;a href="https://github.com/inspektor-gadget/inspektor-gadget/blob/main/docs/guides/trace/oomkill.md" rel="noopener noreferrer"&gt;OOMkill&lt;/a&gt; triggering a process kill)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It manages the packaging, deployment, and execution of eBPF programs in a Kubernetes cluster, including many based on BPF Compiler Collection (BCC) tools, as well as some developed specifically for use in Inspektor Gadget. It automatically maps low-level kernel primitives to high-level Kubernetes resources, making it easier and quicker to find the relevant information.&lt;/p&gt;

&lt;p&gt;To “Advise” on a Kubernetes Network Policy based on network trace activity, run the below command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl gadget advise network-policy report --input ./networktrace.log &amp;gt; network-policy.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To “Audit” a seccomp profile based on pods, namespaces, syscalls, and code, run the below command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl gadget audit seccomp -o custom-columns=namespace,pod,syscall,code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  DIY kubectl plugins
&lt;/h2&gt;

&lt;p&gt;You can write a plugin in any programming language or script that allows you to write command-line commands. There is no plugin installation or pre-loading required, which makes compiling these plugins rather simple.&lt;/p&gt;

&lt;p&gt;Plugin executables receive the inherited environment from the kubectl binary. The plugin will then determine which command path it wishes to implement based on the name – for example, a plugin named &lt;strong&gt;kubectl-sysdig&lt;/strong&gt; provides a command &lt;strong&gt;kubectl sysdig&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You must install the plugin executable somewhere in your &lt;strong&gt;PATH&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A plugin script would look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
# optional argument handling
if [[ "$1" == "version" ]]
then
    echo "1.0.0"
    exit 0
fi
# optional argument handling
if [[ "$1" == "config" ]]
then
    echo "$KUBECONFIG"
    exit 0
fi
echo "I am a plugin named kubectl-sysdig"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a complete guide on building Kubectl plugins, check out the &lt;a href="https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/#using-a-plugin" rel="noopener noreferrer"&gt;official Kubernetes documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final considerations on kubectl plugins
&lt;/h3&gt;

&lt;p&gt;At the time of writing this blog post, there were &lt;strong&gt;208* kubectl plugins&lt;/strong&gt; currently accessible on Krew. Those kubectl plugins are accessible to developers across all major platforms, like MacOS, Linux, and Windows. While these plugins often address clear limitations over the default kubectl utility for operational tasks and security auditing, they also open a bunch of new security gaps for your Kubernetes cluster.&lt;/p&gt;

&lt;p&gt;From a security standpoint, we discussed 15 of the most useful kubectl plugins for giving security teams better visibility for &lt;a href="https://sysdig.com/blog/guide-kubernetes-forensics-dfir/" rel="noopener noreferrer"&gt;incident response and forensics in Kubernetes&lt;/a&gt;. However, as we add more plugins into the environment, we are also adding additional un-audited binaries that could be compromised. Krew does not provide an obligation to audit these binaries for known vulnerabilities or insecure configurations.&lt;/p&gt;

&lt;p&gt;Some security implications of using kubectl plugins include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Plugin vulnerabilities:&lt;/strong&gt; If a kubectl plugin has a vulnerability, it can potentially be exploited by an attacker to gain access to your Kubernetes cluster.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Insecure plugin installation:&lt;/strong&gt; If a plugin is installed from an untrusted source, it could contain malicious code that could compromise the security of your cluster.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Privilege escalation&lt;/strong&gt;: kubectl plugins run with the same privileges as the kubectl command, so if a plugin is compromised, it could potentially be used to escalate privileges and gain access to sensitive resources in your cluster.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Data leakage:&lt;/strong&gt; If a kubectl plugin is not properly secured, it could potentially leak sensitive data from your cluster.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To mitigate these risks, it is important to only install kubectl plugins from trusted sources and to regularly update and patch any plugins you have installed. It is also a good idea to regularly review the plugins you have installed and remove any that are no longer needed.&lt;/p&gt;

&lt;p&gt;If you don’t feel like a specific plugin adds value to your cluster, it would be wise to remove it just in case.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>beginners</category>
      <category>devops</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How attackers use exposed Prometheus server to exploit Kubernetes clusters</title>
      <dc:creator>Miguel</dc:creator>
      <pubDate>Fri, 02 Dec 2022 11:53:43 +0000</pubDate>
      <link>https://dev.to/sysdig/how-attackers-use-exposed-prometheus-server-to-exploit-kubernetes-clusters-3lek</link>
      <guid>https://dev.to/sysdig/how-attackers-use-exposed-prometheus-server-to-exploit-kubernetes-clusters-3lek</guid>
      <description>&lt;p&gt;What is the main thing we want to explain in this article? It’s simple; &lt;strong&gt;don’t expose your metrics for free&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Sometimes we think about deep and complex defense methods and that’s fine. We don’t know why, but we always forget about the base. &lt;strong&gt;Don’t expose your data&lt;/strong&gt;. By default, your Prometheus server can allow anyone to make queries to get information from your Kubernetes Cluster.&lt;/p&gt;

&lt;p&gt;This is not something new. In 2018, &lt;a href="https://arstechnica.com/information-technology/2018/02/tesla-cloud-resources-are-hacked-to-run-cryptocurrency-mining-malware/" rel="noopener noreferrer"&gt;Tesla had a cryptocurrency mining application in their cloud account&lt;/a&gt;, and the initial access was an exposed Kubernetes Dashboard with credentials in the clear.&lt;/p&gt;

&lt;p&gt;Moreover, we are not the first to talk about (in) security in monitoring tools. Here are three good examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://github.com/juice-shop/juice-shop/issues/1275" rel="noopener noreferrer"&gt;Exposed Prometheus metrics Endpoint&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://jfrog.com/blog/dont-let-prometheus-steal-your-fire/" rel="noopener noreferrer"&gt;Don’t let Prometheus Steal your Fire&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.cncf.io/online-programs/a-look-at-how-hackers-exploit-prometheus-grafana-fluentd-jaeger-more/" rel="noopener noreferrer"&gt;Hacking Monitoring for Fun and Profit&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this in mind, are exposed Prometheus servers a real attack surface?&lt;/p&gt;

&lt;h2&gt;
  
  
  Prometheus exposed in the wild
&lt;/h2&gt;

&lt;p&gt;One of the &lt;strong&gt;most important steps&lt;/strong&gt; in any pentest, ethical hacking, or real attack is &lt;strong&gt;gathering as much information you can get from the target&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The fastest way to check if something is exposed on the internet is to query Google. The specific queries to gather information are denominated &lt;a href="https://www.businessinsider.com/term-of-the-day-google-dorking-2014-8" rel="noopener noreferrer"&gt;Google Dorking&lt;/a&gt; and, in our case, is something trivial to get real exposed Prometheus.&lt;/p&gt;

&lt;p&gt;A cooler way to find exposed Prometheus servers is using search engines. We used the most common ones to check how many servers we could access:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Search Engine&lt;/td&gt;
&lt;td&gt;Number exposed Prometheus server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://www.shodan.io/"&gt;Shodan&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;31,679&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://censys.io/"&gt;Censys&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;61,854&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://fofa.info/toLogin"&gt;Fofa&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;161,274&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;At this point, we would like to clarify a critical fact.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;: We have &lt;strong&gt;not used an actual exposed Prometheus server to consult or prepare for this talk&lt;/strong&gt;. We performed all testing in our demo environment and strongly recommend always following security best practices.&lt;/p&gt;

&lt;p&gt;After that, what can we do if we have access to a Prometheus server and have access to the fingerprint Kubernetes?&lt;/p&gt;

&lt;h2&gt;
  
  
  Prometheus’ exporters and fingerprint Kubernetes
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://prometheus.io/" rel="noopener noreferrer"&gt;Prometheus&lt;/a&gt; is the &lt;em&gt;de facto&lt;/em&gt; &lt;a href="https://sysdig.com/blog/monitoring-kubernetes/" rel="noopener noreferrer"&gt;monitoring standard in Kubernetes&lt;/a&gt;. All the Kubernetes components of the control plane generate Prometheus metrics out of the box, and many Kubernetes distributions come with Prometheus installed by default including a series of standard exporters, generally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Node Exporter for infrastructure and host metrics.&lt;/li&gt;
&lt;li&gt;  KSM Exporter for Kubernetes objects state metrics.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;An exporter&lt;/strong&gt; is an application that &lt;strong&gt;generates metrics&lt;/strong&gt; from other applications or systems that &lt;strong&gt;do not expose Prometheus metrics natively&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cloud provider, where are you?
&lt;/h3&gt;

&lt;p&gt;Imagine that you have a possible target in &lt;em&gt;&lt;a href="http://www.example.com" rel="noopener noreferrer"&gt;www.example.com&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;All you know is that this site is a web page with users and a little e-commerce section. Under that domain, you find an open exposed Prometheus. The first thing you can do is try to &lt;strong&gt;identify the cloud provider&lt;/strong&gt; where the site is hosted.&lt;/p&gt;

&lt;p&gt;You can use the metric &lt;code&gt;node_dmi_info&lt;/code&gt; from the Node Exporter. This metric is very interesting, as it gives information about each &lt;a href="https://sysdig.com/learn-cloud-native/kubernetes-101/what-is-a-kubernetes-node/" rel="noopener noreferrer"&gt;Kubernetes node&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;System vendor&lt;/strong&gt;: It exposes the cloud vendor’s name. Some example values could be “&lt;code&gt;Amazon EC2&lt;/code&gt;” or “&lt;code&gt;Tencent Cloud&lt;/code&gt;.”&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Product name&lt;/strong&gt;: Useful to identify both the cloud provider and the product used, as we can find some popular product names from the AWS EC2 catalog (like “&lt;code&gt;m5.xlarge&lt;/code&gt;“) or other vendors’ products.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But the cloud provider, even if interesting, is still so vague. You can gather more information if you focus on networking. You can start with the &lt;code&gt;node_network_info&lt;/code&gt; metric from the &lt;strong&gt;Node Exporter&lt;/strong&gt;. And even more, you can narrow your search if you filter only the Ethernet interfaces.&lt;/p&gt;

&lt;p&gt;Why only Ethernet ones? Because usually, they are the ones that the host identifies as physical network connections and are used to connect the host with the outside world and other machines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node_network_info{device=~'eth.+'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This query provides the following information:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  IP address of each host.&lt;/li&gt;
&lt;li&gt;  Device ID.&lt;/li&gt;
&lt;li&gt;  Availability zone of the cloud provider.&lt;/li&gt;
&lt;li&gt;  ID of the VPC (Virtual Private Cloud).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is an example of some possible values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    address="06:d5:XX:XX:XX:XX"
    broadcast="ff:ff:ff:ff:ff:ff"
    device="eth0"
    instance="172.31.XX.XX:9100"
    instance_az="us-west-2a"
    instance_id="i-XXXXX"
    instance_name="XXX-XXX"
    instance_type="c5.xlarge"
    instance_vpc="vpc-XXXXXXX"
    operstate="up"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also get more information, like the hostname of each node with the metric &lt;code&gt;kube_node_info&lt;/code&gt; from KSM.&lt;/p&gt;

&lt;h3&gt;
  
  
  The long and windy road to the pod
&lt;/h3&gt;

&lt;p&gt;This was all about physical info, but &lt;strong&gt;how can we get from outside the web page to a pod in the cluster?&lt;/strong&gt; The answer to this question is in the &lt;strong&gt;ingress&lt;/strong&gt; and the &lt;strong&gt;services&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;ingress controllers in Kubernetes&lt;/strong&gt; act as reverse proxies and allow redirecting different paths of the URL to different Kubernetes services. These services normally act as load balancers in front of a set of pods that expose a port for connections. The metric &lt;code&gt;kube_ingress_path&lt;/code&gt; from KSM will give you information about the URL paths and the associated services of the ingress controllers in your cluster.&lt;/p&gt;

&lt;p&gt;This way, you can know that the path &lt;code&gt;/api/users/login&lt;/code&gt; goes to the Kubernetes service &lt;code&gt;users-login&lt;/code&gt; of the namespace &lt;code&gt;api&lt;/code&gt;. Funny, right?&lt;/p&gt;

&lt;p&gt;Load balancer services are a special kind of Kubernetes service. Cloud providers use those load balancer services to expose the service to the outside world. As an example, when you create a load-balancer service in an AWS Kubernetes cluster, it creates an ELB (Elastic Load Balancer) instance bound to the service.&lt;/p&gt;

&lt;p&gt;This &lt;strong&gt;promQL&lt;/strong&gt; query will give you &lt;strong&gt;information about all the load-balancer services&lt;/strong&gt; in a Kubernetes cluster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kube_service_info * on (service) group_left group by (service,type) (kube_service_spec_type{type="LoadBalancer"})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To guess what pods are behind each service, you have two options. You can check the metric &lt;code&gt;kube_pod_labels&lt;/code&gt; from KSM. These labels are the ones that the service usually uses to select the pods that will serve the requests, but unfortunately, there is not a direct way to get the association between pods and service in pure KSM.&lt;/p&gt;

&lt;p&gt;However, if you are lucky enough, the cluster will have installed the OpenCost exporter, a tool that helps infrastructure engineers understand the costs of their cloud usage. This exporter generates an interesting metric called &lt;code&gt;service_selector_labels&lt;/code&gt;, which directly gives you the association between the service and the labels that the pod needs to have to be part of that particular service.&lt;/p&gt;

&lt;p&gt;This &lt;strong&gt;promQL&lt;/strong&gt; query will give you the labels of each workload used for matching in services:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;avg by (namespace,label_app,owner_name)(kube_pod_labels{app="cost-model"} * on(namespace,pod) group_left(owner_name) kube_pod_owner{job="kube-state-metrics"})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While this other one will give you the labels that each service uses to find the pods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;avg by (namespace,label_app, service)(service_selector_labels)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Being a many-to-many association, there is not an easy way to collect all this info in a single &lt;strong&gt;promQL&lt;/strong&gt; query, but the info is there, and it’s easy to make a quick correlation between services and pods.&lt;/p&gt;

&lt;p&gt;This way, we have all the points of the path from the URL to the pods: the path of the URL (thanks to the ingress), and pods serving the requests (thanks to the services and labels of the pods).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/exposed-Prometheus-Kubernetes-02.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fexposed-Prometheus-Kubernetes-02.png" alt="Exposed Prometheus to gather Kubernetes network information"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Logical song of the cluster
&lt;/h3&gt;

&lt;p&gt;You used the metric &lt;code&gt;kube_node_info&lt;/code&gt; to get information on the nodes, but now, you are also interested in making a logical map of namespaces, workloads, and pods inside the Kubernetes cluster.&lt;/p&gt;

&lt;p&gt;This is easy by using the KSM metrics. The metric kube_namespace_status_phase gives you all the namespaces in the cluster. From there, you can go down with the following metrics for each of the different workload types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;kube_deployment_spec_replicas&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;kube_daemonset_status_desired_number_scheduled&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;kube_statefulset_replicas&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;kube_replicaset_spec_replicas&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;kube_cronjob_info&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After that, you can get info on the pods using &lt;code&gt;kube_pod_info&lt;/code&gt;, and associating them with their workloads with &lt;code&gt;kube_pod_owner&lt;/code&gt; in the following &lt;strong&gt;promQL&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kube_pod_info * on(namespace,pod) group_left(owner_name) kube_pod_owner
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, you can even get the container inside each pod with the metric &lt;code&gt;kube_pod_container_info&lt;/code&gt;. For example, a pod called &lt;code&gt;postgres-db&lt;/code&gt; can have two containers named &lt;code&gt;postgresql&lt;/code&gt; and &lt;code&gt;postgres-exporter&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;But there is more. You can not only know the namespace and workload of a pod, you can also discover the node where it is living thanks to the label &lt;code&gt;node&lt;/code&gt; of the metric &lt;code&gt;kube_pod_info&lt;/code&gt;. Why is this important? Keep reading.&lt;/p&gt;

&lt;h3&gt;
  
  
  The boulevard of broken nodes
&lt;/h3&gt;

&lt;p&gt;You used the metric kube_node_info before to get the hostname of each node, but this metric has more surprises to unfold.&lt;/p&gt;

&lt;p&gt;Two labels of this metric will give us full information about the Operative System image used to build the node and the detailed kernel version.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;os_image&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;kernel_version&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A quick search on &lt;strong&gt;CVE&lt;/strong&gt; for “Ubuntu 18.04.4 LTS” or “Linux 3.10.0-1160.59.1.el7.x86_64” will give a possible attacker a &lt;strong&gt;good set of exploits&lt;/strong&gt; to use if they can get access to the machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let’s talk about K8s
&lt;/h3&gt;

&lt;p&gt;You have done a good job gathering information about the cluster so far. Namespaces, pods, services, and more But what about Kubernetes itself? There is a set of processes in Kubernetes itself that are just there, and we don’t even think about them unless they start causing problems. We are talking about the Kubernetes control plane.&lt;/p&gt;

&lt;p&gt;What would you say if we tell you that there is a metric that specifies the specific version of each of the components of the control plane? While presenting Prometheus, we said that Kubernetes control plane components were exposing natively metrics. Well, one of those metrics is &lt;code&gt;kubernetes_build_info&lt;/code&gt;. This gives you information about, not only the full (major and minor) version of each component, but also the git commit and the build date.&lt;/p&gt;

&lt;p&gt;This is great if you want to know if a concrete vulnerability affects one of the control plane components of the cluster (among other things).&lt;/p&gt;

&lt;h3&gt;
  
  
  We have a secret…
&lt;/h3&gt;

&lt;p&gt;Everybody loves secrets, especially attackers. In KSM, there is a metric called &lt;code&gt;kube_secret_info&lt;/code&gt; that gives you information about the namespace, node, and name of the secrets of your cluster.&lt;/p&gt;

&lt;p&gt;But if you are interested in knowing the content of the secrets, you can use this query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kube_secret_annotations{kubectl_kubernetes_io_last_applied_configuration != ""}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why? Well, this is somehow embarrassing. In some older versions of &lt;code&gt;kubectl&lt;/code&gt;, it used to save &lt;a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/" rel="noopener noreferrer"&gt;the last applied configuration in an annotation&lt;/a&gt;. This was being made for every object, including secrets. This had the effect that, even if the secret was only accessible by the service accounts and role bindings that you can imagine, Prometheus can expose the content of the secret in plain text in that metric.&lt;/p&gt;

&lt;h3&gt;
  
  
  On images and registries
&lt;/h3&gt;

&lt;p&gt;Do you think you had enough? There is one more interesting thing you can get from KSM. The metric &lt;code&gt;kube_pod_container_info&lt;/code&gt; has an interesting piece of information in these labels:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;image&lt;/code&gt;: name and tag of the image of the container (for example &lt;code&gt;docker.io/library/cassandra:3.11.6&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;image_id&lt;/code&gt;: name, tag, and hash of the image of the container&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This gives you information about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Application used.&lt;/li&gt;
&lt;li&gt;  Registry used to pull the image.&lt;/li&gt;
&lt;li&gt;  Image used.&lt;/li&gt;
&lt;li&gt;  Tag of the image.&lt;/li&gt;
&lt;li&gt;  Hash that identifies uniquely the image independently of its tag.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Summary Kubernetes fingerprint
&lt;/h3&gt;

&lt;p&gt;Let’s see what you’ve done so far. You gathered information about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Cloud provider.&lt;/li&gt;
&lt;li&gt;  Kubernetes control plane components versions.&lt;/li&gt;
&lt;li&gt;  Network path from the outside to pods.&lt;/li&gt;
&lt;li&gt;  Nodes hostnames and IPs.&lt;/li&gt;
&lt;li&gt;  Operative system and kernel versions.&lt;/li&gt;
&lt;li&gt;  Logical structure of the cluster namespaces, workloads, and pods.&lt;/li&gt;
&lt;li&gt;  Images used for the containers, from the source repository to the image tag.&lt;/li&gt;
&lt;li&gt;  Annotations and names of the secrets of the cluster.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/exposed-Prometheus-Kubernetes-03.gif" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fexposed-Prometheus-Kubernetes-03.gif" alt="Exposed Prometheus fingerprinting Kubernetes CVEs"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All this information is enough to make a good surface attack analysis of the cluster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ninja mode!
&lt;/h3&gt;

&lt;p&gt;Do you want to hear something funny? &lt;strong&gt;We gathered all this information and most likely, there is not a trace of all the queries that we did to get it&lt;/strong&gt;. Prometheus can &lt;strong&gt;register logs of the queries&lt;/strong&gt;, but that’s &lt;strong&gt;disabled by default&lt;/strong&gt;. You can even check if your activity is being logged with this metric:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;prometheus_engine_query_log_enabled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Inside the attackers’ minds
&lt;/h2&gt;

&lt;p&gt;Now, attackers just need to know what their target is. In 99% of attacks, it’s money, but how to get the money from the victim, that’s the point where the attacker’s path is defined.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/exposed-Prometheus-Kubernetes-04.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fexposed-Prometheus-Kubernetes-04.png" alt="Three Kubernetes threats: leaks, crypto mining and ransomware"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the talk, we exposed three examples and in each of them, the tools and services exploited are different. The important thing is that we already know where the weaknesses are.&lt;/p&gt;

&lt;h3&gt;
  
  
  Leak sensitive data
&lt;/h3&gt;

&lt;p&gt;In the first scenario, the exposed application is running on a Kubernetes cluster and the attacker wants to access the data without authorization. The first thing the attacker could check is if the application can be exploited through normal pentesting techniques, for example, with &lt;a href="https://sqlmap.org/" rel="noopener noreferrer"&gt;SQLmap&lt;/a&gt; the attacker can try to gain access to the data.&lt;/p&gt;

&lt;p&gt;But if this does not work, what is the next step?&lt;/p&gt;

&lt;p&gt;The attacker can check if the container has vulnerable dependencies or if the image used could be exploited, then see if the components or the node itself are exploitable. But everything seems to be fine. There are no &lt;strong&gt;CVE&lt;/strong&gt; matches and no known exploits that could be used to gain initial access.&lt;/p&gt;

&lt;p&gt;What’s next? Well, Prometheus exposed the image and registry that the attacker accessed, but what about attacking the supply chain? In this case, we have two scenarios:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Official/private registration&lt;/strong&gt;: In this case, the attacker could use similar image names, such as &lt;a href="https://github.com/bbvanexttechnologies/deep-confusables-cli/" rel="noopener noreferrer"&gt;homographs&lt;/a&gt;, visually similar by using different Unicode groups, to trick the target. Another technique could be to abuse an insider to manually change the exposed image. In this case, it depends on the financial gain of the attacker.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Third-party registry&lt;/strong&gt;: In this case, one of the methods could be social engineering, using tools like &lt;a href="https://beefproject.com/" rel="noopener noreferrer"&gt;BeeF&lt;/a&gt; to create a specific phishing or fake page to get the login credentials and change the image to a new one with a known and exploitable vulnerability and wait for the deployment. One more thing is this is not magic or 100% successful. If the company scans the images in the deployment, it could be detected!&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cryptomining
&lt;/h3&gt;

&lt;p&gt;In this scenario, one of the most relevant in the last years with the era of cloud, the attacker would like to get access to the cloud account where the application or Kubernetes cluster are deployed. The attacker could take two paths. The long path was to identify one app exposed via Ingress-controller that has a known vulnerability easily exploited via HTTP and obtain a Remote Code Execution inside the container.&lt;/p&gt;

&lt;p&gt;The vulnerability exploited in this case will be the infamous &lt;a href="https://sysdig.com/blog/exploit-detect-mitigate-log4j-cve/" rel="noopener noreferrer"&gt;log4shell&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once the attacker has access to the container, they don’t even need to gather more information about the cluster or the node because Prometheus exposed this information as well. From that, we could directly exploit another vulnerability to &lt;a href="https://sysdig.com/blog/container-escape-capabilities-falco-detection/" rel="noopener noreferrer"&gt;escape to the container&lt;/a&gt; and get full access to the node without using more tools or scanning, evading typical defense methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: This is not 100% successful. If &lt;a href="https://sysdig.com/products/secure/runtime-security/" rel="noopener noreferrer"&gt;runtime security&lt;/a&gt; is used and the shell within the container is detected as malicious behavior, the incident will be detected before impacting resources.&lt;/p&gt;

&lt;p&gt;Now that the attacker has full control of the node, they will be able to deploy containers to run cryptominers, or find cloud credentials in configuration files or env variables to gain initial access.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/exposed-Prometheus-Kubernetes-05.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fexposed-Prometheus-Kubernetes-05.png" alt="Attacker path exploit Kubernetes Cluster by exposed Prometheus server"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But this is a long way, what’s the short way? Well, it is possible for Prometheus to directly expose credentials to these cloud providers in the same way that the Kubernetes Dashboard did in the past. Therefore, the attacker only needs to query the information via query and get the API keys in clear text.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ransomware
&lt;/h3&gt;

&lt;p&gt;Yes, ransomware in Kubernetes is not typical but not impossible. The scenario is similar to the previous one. We need to get write access and for that, we need to jump or move between namespaces.&lt;/p&gt;

&lt;p&gt;In this case, we find another application with a different vulnerability, &lt;a href="https://sysdig.com/blog/cve-2022-22963-spring-cloud/" rel="noopener noreferrer"&gt;Spring Cloud&lt;/a&gt;, but with the same purpose: to get a shell inside the container.&lt;/p&gt;

&lt;p&gt;Once inside, we know that a Kubernetes component is an old vulnerable version that we can exploit to get access to etcd, and with that, full access to the namespaces.&lt;/p&gt;

&lt;p&gt;The curious thing here is after the data is encrypted, the attacker needs to ask for a ransom through some channel. In a typical scenario, our PC would be locked and the screen would show instructions to pay via BTC or ETH, but inside the container. We hate to share ideas with the bad guys, but one option could be to deploy a container with a modified UI and force ingress to display this in front of the actual application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We might think that metrics are not important from a security perspective, but we demonstrated that’s not true. &lt;strong&gt;Kubernetes&lt;/strong&gt; and &lt;strong&gt;Prometheus&lt;/strong&gt; advise problems with exposing your data to the world, but regardless, these problems are still widespread.&lt;/p&gt;

&lt;p&gt;Following the &lt;strong&gt;security best practices&lt;/strong&gt; in every part of our chain leads to being safe from most security incidents. Otherwise, we will change the typical scenario with a long battle between attackers and defenders for a speedrun.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/exposed-Prometheus-Kubernetes-06.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsysdig.com%2Fwp-content%2Fuploads%2Fexposed-Prometheus-Kubernetes-06.png" alt="Kubernetes threats speedrun"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will have to continue to fight with new vulnerabilities that impact our services and also a plan against insiders. But let’s at least make things difficult for them.&lt;/p&gt;

&lt;p&gt;If you want to see the talk:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/5cbbm_L6n7w"&gt;
&lt;/iframe&gt;
&lt;br&gt;
The slides are available &lt;a href="https://sched.co/ytmB" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>security</category>
      <category>monitoring</category>
      <category>kuberentes</category>
      <category>devops</category>
    </item>
    <item>
      <title>26 AWS Security Best Practices to Adopt in Production</title>
      <dc:creator>Miguel</dc:creator>
      <pubDate>Wed, 21 Sep 2022 08:42:58 +0000</pubDate>
      <link>https://dev.to/sysdig/26-aws-security-best-practices-to-adopt-in-production-18fo</link>
      <guid>https://dev.to/sysdig/26-aws-security-best-practices-to-adopt-in-production-18fo</guid>
      <description>&lt;p&gt;One of the most important pillars of a well-architected framework is security. Thus, it is important to follow these &lt;strong&gt;AWS security best practices&lt;/strong&gt; to prevent unnecessary security situations.&lt;/p&gt;

&lt;p&gt;So, you’ve got a problem to solve and turned to AWS to build and host your solution. You create your account and now you’re all set up to brew some coffee and sit down at your workstation to architect, code, build, and deploy. Except, you aren’t.&lt;/p&gt;

&lt;p&gt;There are many things &lt;strong&gt;you must set up&lt;/strong&gt; if you want your solution to be &lt;strong&gt;operative&lt;/strong&gt;, &lt;strong&gt;secure&lt;/strong&gt;, &lt;strong&gt;reliable&lt;/strong&gt;, &lt;strong&gt;performant,&lt;/strong&gt; and &lt;strong&gt;cost effective&lt;/strong&gt;. And, first things first, the best time to do that is now – right from the beginning, before you start to design and engineer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Initial AWS setup
&lt;/h2&gt;

&lt;p&gt;Never, ever, use your &lt;em&gt;root&lt;/em&gt; account for everyday use. Instead, head to Identity and Access Management (IAM) and create an administrator user. Protect and lock your &lt;em&gt;root&lt;/em&gt; credentials in a secure place (is your password strong enough?) and, if your &lt;em&gt;root&lt;/em&gt; user has keys generated, now is the best time to delete them.&lt;/p&gt;

&lt;p&gt;You will absolutely want to &lt;strong&gt;activate Multi Factor Authentication (MFA) too for your root account&lt;/strong&gt;. You must end up with a root user with MFA and no access keys. And you won’t use this user unless strictly necessary.&lt;/p&gt;

&lt;p&gt;Now, about your newly created admin account, &lt;a href="https://sysdig.com/blog/why-mfa-prevents-attacks/"&gt;activating MFA for it is a must&lt;/a&gt;. It’s actually a requirement for every user in your account if you want to have a security first mindset (and you actually want to), but especially so for power users. You will only use this account for administrative purposes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/AWS-security-best-practices-02.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KlvPSMgP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/AWS-security-best-practices-02.png" alt="AWS security best practices MFA featured" width="880" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For daily use, you need to go to the IAM panel and create users, groups, and roles which can access only the resources to which you explicitly grant permissions.&lt;/p&gt;

&lt;p&gt;Now you have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;em&gt;Root&lt;/em&gt; account (with no keys) securely locked into a safe.&lt;/li&gt;
&lt;li&gt;  Admin account for administrative use.&lt;/li&gt;
&lt;li&gt;  Several users, groups, and roles for day to day use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of them should have MFA activated and strong passwords.&lt;/p&gt;

&lt;p&gt;You are almost ready to begin your actual work, but first, a word of caution about the AWS shared responsibility model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security and compliance is a shared responsibility between AWS and the customer&lt;/strong&gt;. AWS operates, manages, and controls the components from the host operating system and virtualization layer, down to the physical security of the facilities in which the service operates. The customer assumes responsibility and management of the guest operating system (including updates and security patches), other associated application software, as well as the configuration of the AWS provided security group firewall.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/AWS-security-best-practices-03.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ohONGYXZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/AWS-security-best-practices-03.png" alt="AWS security best practices shared responsability" width="880" height="590"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Therefore, the management and application of diligent AWS security is the responsibility of the customer.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS Cloud security best practices checklist
&lt;/h2&gt;

&lt;p&gt;In this section we will walk through the most common AWS services and provide &lt;strong&gt;26 security best practices&lt;/strong&gt; to adopt.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AWS Security with open source&lt;/strong&gt; – &lt;a href="https://cloudcustodian.io/"&gt;Cloud Custodian&lt;/a&gt; is a &lt;a href="https://sysdig.com/learn-cloud-native/cloud-security/cloud-security-posture-management/"&gt;Cloud Security Posture Management&lt;/a&gt; (CSPM) tool. &lt;a href="https://sysdig.com/products/secure/cspm-cloud-security-posture-management/"&gt;CSPM tools&lt;/a&gt; evaluate your cloud configuration and identify common configuration mistakes. They also monitor cloud logs to detect threats and configuration changes.&lt;/p&gt;

&lt;p&gt;Now let’s walk through service by service.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td colspan="4"&gt;&lt;strong&gt;AWS security best practices by service&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;High Risk 🟥🟥🟥&lt;/td&gt;
&lt;td&gt;Medium Risk 🟨🟨&lt;/td&gt;
&lt;td&gt;Low Risk 🟩&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#IAM"&gt;AWS IAM&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#1"&gt;(1)&lt;/a&gt; IAM policies should not allow full “*” administrative privileges&lt;p&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#4"&gt;(4)&lt;/a&gt; IAM root user access key should not exist&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#6"&gt;(6)&lt;/a&gt; Hardware MFA should be enabled for the root user&lt;/p&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#3"&gt;(3)&lt;/a&gt; IAM users’ access keys should be rotated every 90 days or less&lt;p&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#5"&gt;(5)&lt;/a&gt; MFA should be enabled for all IAM users that have a console password&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#7"&gt;(7)&lt;/a&gt; Password policies for IAM users should have strong configurations&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#8"&gt;(8)&lt;/a&gt; Unused IAM user credentials should be removed&lt;/p&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#2"&gt;(2)&lt;/a&gt; IAM users should not have IAM policies attached&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#s3"&gt;Amazon S3&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#10"&gt;(10)&lt;/a&gt; S3 buckets should have server-side encryption enabled&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#9"&gt;(9)&lt;/a&gt; S3 Block Public Access setting should be enabled&lt;p&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#11"&gt;(11)&lt;/a&gt; S3 Block Public Access setting should be enabled at the bucket level&lt;/p&gt;
&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#cloudtrail"&gt;AWS CloudTrail&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#12"&gt;(12)&lt;/a&gt; CloudTrail should be enabled and configured with at least one multi-Region trail&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#13"&gt;(13)&lt;/a&gt; CloudTrail should have encryption at rest enabled&lt;p&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#14"&gt;(14)&lt;/a&gt; Ensure CloudTrail log file validation is enabled&lt;/p&gt;
&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#config"&gt;AWS Config&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#15"&gt;(15)&lt;/a&gt; AWS Config should be enabled&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#ec2"&gt;Amazon EC2&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#16"&gt;(16)&lt;/a&gt; Attached EBS volumes should be encrypted at rest&lt;p&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#19"&gt;(19)&lt;/a&gt; EBS default encryption should be enabled&lt;/p&gt;
&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#17"&gt;(17)&lt;/a&gt; VPC flow logging should be enabled in all VPCs&lt;p&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#18"&gt;(18)&lt;/a&gt; The VPC default security group should not allow inbound and outbound traffic&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#DMS"&gt;AWS DMS&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#20"&gt;(20)&lt;/a&gt; AWS Database Migration Service replication instances should not be public&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#ebs"&gt;Amazon EBS&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#21"&gt;(21)&lt;/a&gt; Amazon EBS snapshots should not be public, determined by the ability to be restorable by anyone&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#opensearch"&gt;Amazon OpenSearch Service&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#22"&gt;(22)&lt;/a&gt; Elasticsearch domains should have encryption at rest enabled&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#SageMaker"&gt;Amazon SageMaker&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#23"&gt;(23)&lt;/a&gt; SageMaker notebook instances should not have direct internet access&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#Lambda"&gt;AWS Lambda&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#24"&gt;(24)&lt;/a&gt; Lambda functions should use supported runtimes&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#KMS"&gt;AWS KMS&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#25"&gt;(25)&lt;/a&gt; AWS KMS keys should not be unintentionally deleted&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#guarduty"&gt;Amazon GuardDuty&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a rel="noopener nofollow noreferrer" href="https://sysdig.com/blog/26-aws-security-best-practices/#26"&gt;(26)&lt;/a&gt; GuardDuty should be enabled&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  AWS Identity and Access Management (IAM)
&lt;/h2&gt;

&lt;p&gt;AWS Identity and Access Management (IAM) helps enforce least privilege access control to AWS resources. You can use IAM to restrict who is authenticated (signed in) and authorized (has permissions) to use resources.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.- Do not allow full “*” administrative privileges on IAM policies 🟥🟥🟥
&lt;/h3&gt;

&lt;p&gt;IAM policies define a set of privileges that are granted to users, groups, or roles. Following standard security advice, &lt;strong&gt;you should grant least privilege&lt;/strong&gt;, which means to allow only the permissions that are required to perform a task.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/AWS-security-best-practices-04.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yOtsCCxQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/AWS-security-best-practices-04-350x356.png" alt="AWS security best practices least privilege" width="350" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you provide full administrative privileges instead of the minimum set of permissions that the user needs, &lt;a href="https://sysdig.com/blog/threat-detection-aws-cloud-containers/"&gt;you expose the resources to potentially unwanted actions&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For each AWS account, list the customer managed policies available:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws iam list-policies --scope Local --query 'Policies[*].Arn'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The previous command will return a list of policies along with their Amazon Resource Names (ARNs). Using these ARNs, now retrieve the policy document in JSON format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws iam get-policy-version
--policy-arn POLICY_ARN
--version-id v1
--query 'PolicyVersion.Document'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output should be the requested IAM policy document:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "1234567890",
            "Effect": "Allow",
            "Action": "*",
            "Resource": "*"
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look into this document for the following elements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Effect": "Allow", "Action": "*", "Resource": "*" 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If these elements are present, then the &lt;strong&gt;customer-managed policy allows full administrative privileges&lt;/strong&gt;. &lt;strong&gt;This is a risk and must be avoided&lt;/strong&gt;, so you will need to tune these policies down to pinpoint exactly what actions you want to allow for each specific resource.&lt;/p&gt;

&lt;p&gt;Repeat the previous procedure for the other IAM customer managed policies.&lt;/p&gt;

&lt;p&gt;If you want to detect the use of full administrative privileges with open source, here is a Cloud Custodian rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: full-administrative-privileges
  description: IAM policies are the means by which privileges are granted to users, groups, or roles. It is recommended and considered a standard security advice to grant least privilege -that is, granting only the permissions required to perform a task. Determine what users need to do and then craft policies for them that let the users perform only those tasks, instead of allowing full administrative privileges.
  resource: iam-policy
  filters:
    - type: used
    - type: has-allow-all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.- Do not attach IAM policies to users 🟩
&lt;/h3&gt;

&lt;p&gt;By default, IAM users, groups, and roles have no access to AWS resources.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/aws-security-best-practices-policy.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JsAXLLJA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/aws-security-best-practices-policy.png" alt="AWS security best practices policy" width="880" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;IAM policies grant privileges to users, groups, or roles. We recommend that you &lt;strong&gt;apply IAM policies directly to groups and roles&lt;/strong&gt; but not to users. Assigning privileges at the group or role level reduces the complexity of access management as the number of users grows. Reducing access management complexity might in turn reduce the opportunity for a principal to inadvertently receive or retain excessive privileges.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.- Rotate IAM users’ access keys every 90 days or less 🟨🟨
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html"&gt;AWS recommends&lt;/a&gt; that you rotate the access keys every 90 days. Rotating access keys reduces the chance that an access key that is associated with a compromised or terminated account is used. It also ensures that data cannot be accessed with an old key that might have been lost, cracked, or stolen. Always update your applications after you rotate access keys.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/aws-security-best-practices-rotate.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eq59GrE---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/aws-security-best-practices-rotate.png" alt="AWS security best practices rotate api keys" width="880" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, list all IAM users available in your AWS account with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws iam list-users --query 'Users[*].UserName'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For all the users returned by this command, determine each active access key lifetime by doing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws iam list-access-keys --user-name USER_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should expose the metadata for each access key existing for the specified IAM user. The output will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "AccessKeyMetadata": [
        {
            "UserName": "some-user",
            "Status": "Inactive",
            "CreateDate": "2022-05-18T13:43:23Z",
            "AccessKeyId": "AAAABBBBCCCCDDDDEEEE"
        },
        {
            "UserName": "some-user",
            "Status": "Active",
            "CreateDate": "2022-03-21T09:12:32Z",
            "AccessKeyId": "AAAABBBBCCCCDDDDEEEE"
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the &lt;code&gt;CreateDate&lt;/code&gt; parameter value for each active key to determine its creation time. If an active access key has been created before the last 90 days, the key is outdated and must be &lt;a href="https://aws.amazon.com/blogs/security/how-to-rotate-access-keys-for-iam-users/"&gt;rotated&lt;/a&gt; to secure the access to your AWS resources.&lt;/p&gt;

&lt;p&gt;Repeat for each IAM user existing in your AWS account.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.- Ensure that IAM root user access keys do not exist 🟥🟥🟥
&lt;/h3&gt;

&lt;p&gt;As we stated during your initial setup, &lt;strong&gt;we highly recommend that you remove all access keys that are associated with the root user&lt;/strong&gt;. This limits the vectors that can be used to compromise your account. It also encourages the creation and use of role-based accounts that are least privileged.&lt;/p&gt;

&lt;p&gt;The following Cloud Custodian rule will check if root access keys have been used on your account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: root-access-keys
  description: The root user account is the most privileged user in an AWS account. AWS Access Keys provide programmatic access to a given AWS account. It is recommended that all access keys associated with the root user account be removed.
  resource: account
  filters:
    - type: iam-summary
      key: AccountAccessKeysPresent
      value: 0
      op: gt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.- Enable MFA for all IAM users that have a console password 🟨🟨
&lt;/h3&gt;

&lt;p&gt;Multi-factor authentication (MFA) adds an extra layer of protection on top of a username and password. With MFA enabled, when a user signs in to an AWS website, they are prompted for their username and password. In addition, they are prompted for an authentication code from their AWS MFA device.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/aws-security-best-practices-mfa.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yEBWP7vL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/aws-security-best-practices-mfa.png" alt="AWS security best practices MFA diagram" width="880" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We recommend that you &lt;a href="https://sysdig.com/blog/why-mfa-prevents-attacks/"&gt;enable MFA for all accounts&lt;/a&gt; that have a console password&lt;/strong&gt;. MFA is designed to provide increased security for console access. The authenticating principal must possess a device that emits a time-sensitive key and must have knowledge of a credential.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.- Enable hardware MFA for the root user 🟥🟥🟥
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Virtual MFA might not provide the same level of security as hardware MFA devices&lt;/strong&gt;. A hardware MFA has a minimal attack surface, and cannot be stolen unless the malicious user gains physical access to the hardware device. We recommend that you use only a virtual MFA device while you wait for hardware purchase approval or for your hardware to arrive, especially for root users.&lt;/p&gt;

&lt;p&gt;To learn more, see &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_enable_virtual.html"&gt;Enabling a virtual multi-factor authentication (MFA) device (console)&lt;/a&gt; in the IAM User Guide.&lt;/p&gt;

&lt;p&gt;Here is a Cloud Custodian rule to detect lack of root hardware MFA:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: root-hardware-mfa
  description: The root user account is the most privileged user in an AWS account. MFA adds an extra layer of protection on top of a username and password. With MFA enabled, when a user signs in to an AWS website, they will be prompted for their username and password as well as for an authentication code from their AWS MFA device. It is recommended that the root user account be protected with a hardware MFA.
  resource: account
  filters:
    - or:
      - type: iam-summary
        key: AccountMFAEnabled
        value: 1
        op: ne
      - and:
        - type: iam-summary
          key: AccountMFAEnabled
          value: 1
          op: eq
        - type: has-virtual-mfa
          value: true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.- Ensure those password policies for IAM users have strong configurations 🟨🟨
&lt;/h3&gt;

&lt;p&gt;We recommend that you enforce the creation of strong user passwords. You can set a &lt;strong&gt;password policy&lt;/strong&gt; on your AWS account to &lt;strong&gt;specify complexity requirements&lt;/strong&gt; and &lt;strong&gt;mandatory rotation periods&lt;/strong&gt; for passwords.&lt;/p&gt;

&lt;p&gt;When you create or change a password policy, most of the password policy settings are enforced the next time users change their passwords. Some of the settings are enforced immediately.&lt;/p&gt;

&lt;p&gt;What constitutes a strong password is a subjective matter, but the following settings will put you on the right path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RequireUppercaseCharacters: true
RequireLowercaseCharacters: true
RequireSymbols: true
RequireNumbers: true
MinimumPasswordLength: 8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.- Remove unused IAM user credentials 🟨🟨
&lt;/h3&gt;

&lt;p&gt;IAM users can access AWS resources using different types of credentials, such as passwords or access keys. We recommend you remove or deactivate all credentials that were unused for 90 days or more to reduce the window of opportunity for credentials associated with a compromised or abandoned account to be used.&lt;/p&gt;

&lt;p&gt;You can use the IAM console to get some of the information that you need to monitor accounts for dated credentials. For example, when you view users in your account, there is a column for Access key age, Password age, and Last activity. If the value in any of these columns is greater than 90 days, make the credentials for those users inactive.&lt;/p&gt;

&lt;p&gt;You can also use credential reports to monitor user accounts and identify those with no activity for 90 or more days. You can download credential reports in .csv format from the IAM console.&lt;/p&gt;

&lt;p&gt;For more information, check out &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html"&gt;AWS security best practices for IAM&lt;/a&gt; in more detail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Amazon S3
&lt;/h2&gt;

&lt;p&gt;Amazon Simple Storage Service (Amazon S3) is an object storage service offering industry-leading scalability, data availability, security, and performance. There are &lt;a href="https://aws.amazon.com/blogs/security/top-10-security-best-practices-for-securing-data-in-amazon-s3/"&gt;few AWS security best practices to adopt when it comes to S3&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  9.- Enable S3 Block Public Access setting 🟨🟨
&lt;/h3&gt;

&lt;p&gt;Amazon S3 public access block is designed to provide controls across an entire AWS account or at the individual S3 bucket level to ensure that objects never have public access. Public access is granted to buckets and objects through access control lists (ACLs), bucket policies, or both.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/AWS-security-best-practices-s3-exposed.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--L0ClD9Af--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/AWS-security-best-practices-s3-exposed.png" alt="AWS security best practices S3 exposed" width="413" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unless you intend to have your S3 buckets be publicly accessible, you should configure the account level Amazon S3 Block Public Access feature.&lt;/p&gt;

&lt;p&gt;Get the names of all S3 buckets available in your AWS account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws s3api list-buckets --query 'Buckets[*].Name'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For each bucket returned, get its S3 Block Public Access feature configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws s3api get-public-access-block --bucket BUCKET_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output for the previous command should be like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"PublicAccessBlockConfiguration": {
  "BlockPublicAcls": false,
  "IgnorePublicAcls": false,
  "BlockPublicPolicy": false,
  "RestrictPublicBuckets": false
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;If any of these values is false, then your data privacy is at stake&lt;/strong&gt;. Use this short command to remediate it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws s3api put-public-access-block
--region REGION
--bucket BUCKET_NAME
--public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10.- Enable server-side encryption on S3 buckets 🟥🟥🟥
&lt;/h3&gt;

&lt;p&gt;For an added layer of security for your sensitive data in S3 buckets, &lt;strong&gt;you should configure your buckets with server-side encryption to protect your data at rest&lt;/strong&gt;. Amazon S3 encrypts each object with a unique key. As an additional safeguard, Amazon S3 encrypts the key itself with a root key that it rotates regularly. Amazon S3 server-side encryption uses one of the strongest block ciphers available to encrypt your data, 256-bit Advanced Encryption Standard (AES-256).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/aws-security-best-practices-s3.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VulXTey0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/aws-security-best-practices-s3.png" alt="AWS security best practices S3 encrypt at rest" width="880" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;List all existing S3 buckets available in your AWS account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws s3api list-buckets --query 'Buckets[*].Name'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, use the names of the S3 buckets returned at the previous step as identifiers to retrieve their Default Encryption feature status:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws s3api get-bucket-encryption --bucket BUCKET_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command output should return the requested feature configuration details. If the get-bucket-encryption command output returns an error message, the default encryption is not currently enabled, and therefore the selected S3 bucket does not automatically encrypt all objects when stored in Amazon S3.&lt;/p&gt;

&lt;p&gt;Repeat this procedure for all your S3 buckets.&lt;/p&gt;

&lt;h3&gt;
  
  
  11.- Enable S3 Block Public Access setting at the bucket level 🟨🟨
&lt;/h3&gt;

&lt;p&gt;Amazon S3 public access block is designed to provide controls across an entire AWS account or at the individual S3 bucket level to ensure that objects never have public access. Public access is granted to buckets and objects through access control lists (ACLs), bucket policies, or both.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/AWS-security-best-practices-s3-policy.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eQLlQ3zt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/AWS-security-best-practices-s3-policy.png" alt="AWS security best practices S3 policy" width="880" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unless you intend to have your S3 buckets be publicly accessible, which you probably shouldn’t, you should configure the account level Amazon S3 Block Public Access feature.&lt;/p&gt;

&lt;p&gt;You can use this Cloud Custodian rule to detect S3 buckets that are publicly accessible:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: buckets-public-access-block
  description: Amazon S3 provides Block public access (bucket settings) and Block public access (account settings) to help you manage public access to Amazon S3 resources. By default, S3 buckets and objects are created with public access disabled. However, an IAM principle with sufficient S3 permissions can enable public access at the bucket and/or object level. While enabled, Block public access (bucket settings) prevents an individual bucket, and its contained objects, from becoming publicly accessible. Similarly, Block public access (account settings) prevents all buckets, and contained objects, from becoming publicly accessible across the entire account.
  resource: s3
  filters:
    - or:
      - type: check-public-block
        BlockPublicAcls: false
      - type: check-public-block
        BlockPublicPolicy: false
      - type: check-public-block
        IgnorePublicAcls: false
      - type: check-public-block
        RestrictPublicBuckets: false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  AWS CloudTrail
&lt;/h2&gt;

&lt;p&gt;AWS CloudTrail is an AWS service that helps you enable governance, compliance, and operational and risk auditing of your AWS account. Actions taken by a user, role, or an AWS service are recorded as events in CloudTrail. Events include actions taken in the AWS Management Console, AWS Command Line Interface, and AWS SDKs and APIs.&lt;/p&gt;

&lt;p&gt;The following section will help you configure CloudTrail to monitor your infrastructure across all your regions.&lt;/p&gt;

&lt;h3&gt;
  
  
  12.- Enable and configure CloudTrail with at least one multi-Region trail 🟥🟥🟥
&lt;/h3&gt;

&lt;p&gt;CloudTrail provides a history of AWS API calls for an account, including API calls made from the AWS Management Console, AWS SDKs, and command line tools. The history also includes API calls from higher-level AWS services, such as AWS CloudFormation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/aws-security-best-practices-cloudtrail.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ve6jmjoC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/aws-security-best-practices-cloudtrail.png" alt="AWS security best practices cloudtrail" width="880" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;AWS API call history produced by CloudTrail enables security analysis&lt;/strong&gt;, &lt;strong&gt;resource change tracking&lt;/strong&gt;, and &lt;strong&gt;compliance auditing&lt;/strong&gt;. Multi-Region trails also provide the following benefits.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  A multi-Region trail helps to detect unexpected activity occurring in otherwise unused Regions.&lt;/li&gt;
&lt;li&gt;  A multi-Region trail ensures that global service event logging is enabled for a trail by default. Global service event logging records events generated by AWS global services.&lt;/li&gt;
&lt;li&gt;  For a multi-Region trail, management events for all read and write operations ensure that CloudTrail records management operations on all of an AWS account’s resources.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By default, CloudTrail trails that are created using the AWS Management Console are multi-Region trails.&lt;/p&gt;

&lt;p&gt;List all trails available in the selected AWS region:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws cloudtrail describe-trails
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output exposes each AWS CloudTrail trail along with its configuration details. If &lt;code&gt;IsMultiRegionTrail&lt;/code&gt; config parameter value is false, the selected trail is not currently enabled for all AWS regions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "trailList": [
        {
            "IncludeGlobalServiceEvents": true,
            "Name": "ExampleTrail",
            "TrailARN": "arn:aws:cloudtrail:us-east-1:123456789012:trail/ExampleTrail",
            "LogFileValidationEnabled": false,
            "IsMultiRegionTrail": false,
            "S3BucketName": "ExampleLogging",
            "HomeRegion": "us-east-1"
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify that all of your trails and make sure at least one is multi-Region.&lt;/p&gt;

&lt;h3&gt;
  
  
  13.- Enable encryption at rest with CloudTrail 🟨🟨
&lt;/h3&gt;

&lt;p&gt;Check whether CloudTrail is configured to use the server-side encryption (SSE) AWS Key Management Service customer master key (CMK) encryption.&lt;/p&gt;

&lt;p&gt;The check passes if the &lt;em&gt;KmsKeyId&lt;/em&gt; is defined. For an added layer of security for your sensitive CloudTrail log files, you should use server-side encryption with AWS KMS–managed keys (SSE-KMS) for your CloudTrail log files for encryption at rest. Note that by default, the log files delivered by CloudTrail to your buckets are encrypted by Amazon server-side encryption with Amazon S3-managed encryption keys (SSE-S3).&lt;/p&gt;

&lt;p&gt;You can check that the logs are encrypted with the following Cloud Custodian rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: cloudtrail-logs-encrypted-at-rest
  description: AWS CloudTrail is a web service that records AWS API calls for an account and makes those logs available to users and resources in accordance with IAM policies. AWS Key Management Service (KMS) is a managed service that helps create and control the encryption keys used to encrypt account data, and uses Hardware Security Modules (HSMs) to protect the security of encryption keys. CloudTrail logs can be configured to leverage server side encryption (SSE) and KMS customer created master keys (CMK) to further protect CloudTrail logs. It is recommended that CloudTrail be configured to use SSE-KMS.
  resource: cloudtrail
  filters:
    - type: value
      key: KmsKeyId
      value: absent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can remediate it using the AWS Console like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Sign in to the AWS Management Console at &lt;a href="https://console.aws.amazon.com/cloudtrail/"&gt;https://console.aws.amazon.com/cloudtrail/&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt; In the left navigation panel, select &lt;strong&gt;Trails&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt; Under the &lt;strong&gt;Name&lt;/strong&gt; column, select the trail name that you need to update.&lt;/li&gt;
&lt;li&gt; Click the pencil icon next to the S3 section to edit the trail bucket configuration.&lt;/li&gt;
&lt;li&gt; Under &lt;strong&gt;S3 bucket*&lt;/strong&gt; click &lt;strong&gt;Advanced&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt; Select &lt;strong&gt;Yes&lt;/strong&gt; next to &lt;strong&gt;Encrypt log files&lt;/strong&gt; to encrypt your log files with SSE-KMS using a Customer Master Key (CMK).&lt;/li&gt;
&lt;li&gt; Select &lt;strong&gt;Yes&lt;/strong&gt; next to &lt;strong&gt;Create a new KMS key&lt;/strong&gt; to create a new CMK and enter a name for it, or otherwise select &lt;strong&gt;No&lt;/strong&gt; to use an existing CMK encryption key available in the region.&lt;/li&gt;
&lt;li&gt; Click &lt;strong&gt;Save&lt;/strong&gt; to enable SSE-KMS encryption.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  14.- Enable CloudTrail log file validation 🟨🟨
&lt;/h3&gt;

&lt;p&gt;CloudTrail log file validation creates a digitally signed digest file that contains a hash of each log that CloudTrail writes to Amazon S3. You can use these digest files to determine whether a log file was changed, deleted, or unchanged after CloudTrail delivered the log.&lt;/p&gt;

&lt;p&gt;It is recommended that you enable file validation on all trails. Log file validation provides additional integrity checks of CloudTrail logs.&lt;/p&gt;

&lt;p&gt;To check this in the AWS Console proceed as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Sign in to the AWS Management Console at &lt;a href="https://console.aws.amazon.com/cloudtrail/"&gt;https://console.aws.amazon.com/cloudtrail/&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt; In the left navigation panel, select &lt;strong&gt;Trails&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt; Under the &lt;strong&gt;Name&lt;/strong&gt; column, select the trail name that you need to examine.&lt;/li&gt;
&lt;li&gt; Under &lt;strong&gt;S3&lt;/strong&gt; section, check for &lt;strong&gt;Enable log file validation&lt;/strong&gt; status:&lt;/li&gt;
&lt;li&gt; Enable log file validation status. If the feature status is set to &lt;strong&gt;No&lt;/strong&gt;, then the selected trail does not have log file integrity validation enabled. If this is the case, fix it:

&lt;ol&gt;
&lt;li&gt; Click the pencil icon next to the &lt;strong&gt;S3&lt;/strong&gt; section to edit the trail bucket configuration.&lt;/li&gt;
&lt;li&gt; Under &lt;strong&gt;S3 bucket*&lt;/strong&gt; click &lt;strong&gt;Advanced&lt;/strong&gt; and search for the &lt;strong&gt;Enable log file validation&lt;/strong&gt; configuration status.&lt;/li&gt;
&lt;li&gt; Select &lt;strong&gt;Yes&lt;/strong&gt; to enable log file validation, and then click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Learn more about &lt;a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/best-practices-security.html"&gt;security best practices in AWS Cloudtrail&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS Config
&lt;/h2&gt;

&lt;p&gt;AWS Config provides a detailed view of the resources associated with your AWS account, including how they are configured, how they are related to one another, and how the configurations and their relationships have changed over time.&lt;/p&gt;

&lt;h3&gt;
  
  
  15.- Verify AWS Config is enabled 🟥🟥🟥
&lt;/h3&gt;

&lt;p&gt;The AWS Config service performs configuration management of supported AWS resources in your account and delivers log files to you. The recorded information includes the configuration item (AWS resource), relationships between configuration items, and any configuration changes between resources.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/aws-security-best-practices-config.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dsTsZO31--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/aws-security-best-practices-config.png" alt="AWS security best practices config" width="880" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is recommended that you enable AWS Config in all Regions. The AWS configuration item history that AWS Config captures enables security analysis, resource change tracking, and compliance auditing.&lt;/p&gt;

&lt;p&gt;Get the status of all configuration recorders and delivery channels created by the Config service in the selected region:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws configservice --region REGION get-status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output from the previous command shows the status of all AWS Config delivery channels and configuration recorders available. If AWS Config is not enabled, the list for both configuration recorders and delivery channels are shown empty:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Configuration Recorders:
Delivery Channels:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, if the service was previously enabled but is now disabled, the status should be set to OFF:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Configuration Recorders:
name: default
recorder: OFF
Delivery Channels:
name: default
last stream delivery status: NOT_APPLICABLE
last history delivery status: SUCCESS
last snapshot delivery status: SUCCESS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To remediate this, after you enable AWS Config, configure it to record all resources.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Open the AWS Config console at &lt;a href="https://console.aws.amazon.com/config/"&gt;https://console.aws.amazon.com/config/&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt; Select the Region to configure AWS Config in.&lt;/li&gt;
&lt;li&gt; If you haven’t used AWS Config before, see &lt;a href="https://docs.aws.amazon.com/config/latest/developerguide/getting-started.html"&gt;Getting Started&lt;/a&gt; in the AWS Config Developer Guide.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Navigate to the Settings page from the menu, and do the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Choose Edit.&lt;/li&gt;
&lt;li&gt; Under Resource types to record, select Record all resources supported in this region and Include global resources (e.g., AWS IAM resources).&lt;/li&gt;
&lt;li&gt; Under Data retention period, choose the default retention period for AWS Config data, or specify a custom retention period.&lt;/li&gt;
&lt;li&gt; Under AWS Config role, either choose Create AWS Config service-linked role or choose Choose a role from your account and then select the role to use.&lt;/li&gt;
&lt;li&gt; Under Amazon S3 bucket, specify the bucket to use or create a bucket and optionally include a prefix.&lt;/li&gt;
&lt;li&gt; Under Amazon SNS topic, select an Amazon SNS topic from your account or create one. For more information about Amazon SNS, see the &lt;a href="https://docs.aws.amazon.com/sns/latest/dg/sns-getting-started.html"&gt;Amazon Simple Notification Service Getting Started Guide&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose Save.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To go deeper, follow the &lt;a href="https://docs.aws.amazon.com/config/latest/developerguide/security-best-practices.html"&gt;security best practices for AWS Config&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Amazon EC2
&lt;/h2&gt;

&lt;p&gt;Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable computing capacity that you use to build and host your software systems. Therefore, EC2 is one of the core services of AWS and it is necessary to know the best security practices and &lt;a href="https://sysdig.com/blog/aws-ec2-security-cloudtrail-sysdig/"&gt;how to secure EC2&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  16.- Ensure attached EBS volumes are encrypted at rest 🟥🟥🟥
&lt;/h3&gt;

&lt;p&gt;It is to check whether the EBS volumes that are in an attached state are encrypted. To pass this check, &lt;strong&gt;EBS volumes must be in use and encrypted&lt;/strong&gt;. If the EBS volume is not attached, then it is not subject to this check.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/aws-security-best-practices-ec2.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OjRw0DC4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/aws-security-best-practices-ec2.png" alt="AWS security best practices encrypt ebs at rest" width="880" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For an added layer of security to your sensitive data in EBS volumes, you should enable EBS encryption at rest. Amazon EBS encryption offers a straightforward encryption solution for your EBS resources that doesn’t require you to build, maintain, and secure your own key management infrastructure. It uses KMS keys when creating encrypted volumes and snapshots.&lt;/p&gt;

&lt;p&gt;Run the describe-volumes command to determine if your EC2 Elastic Block Store volume is encrypted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws ec2 describe-volumes
--filters Name=attachment.instance-id, Values=INSTANCE_ID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command output should reveal the instance EBS volume encryption status (true for enabled, false for disabled).&lt;/p&gt;

&lt;p&gt;There is no direct way to encrypt an existing unencrypted volume or snapshot. You can only encrypt a new volume or snapshot when you create it.&lt;/p&gt;

&lt;p&gt;If you enable encryption by default, Amazon EBS encrypts the resulting new volume or snapshot by using your default key for Amazon EBS encryption. Even if you have not enabled encryption by default, you can enable encryption when you create an individual volume or snapshot. In both cases, you can override the default key for Amazon EBS encryption and choose a symmetric customer managed key.&lt;/p&gt;

&lt;h3&gt;
  
  
  17.- Enable VPC flow logging in all VPCs 🟩
&lt;/h3&gt;

&lt;p&gt;With the VPC Flow Logs feature, you can capture information about the IP address traffic going to and from network interfaces in your VPC. After you create a flow log, you can view and retrieve its data in CloudWatch Logs. To reduce cost, you can also send your flow logs to Amazon S3.&lt;/p&gt;

&lt;p&gt;It is recommended that you enable flow logging for packet rejects for VPCs. Flow logs provide visibility into network traffic that traverses the VPC and can detect anomalous traffic or provide insight during security workflows. By default, the record includes values for the different components of the IP address flow, including the source, destination, and protocol.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: flow-logs-enabled
  description: VPC Flow Logs is a feature that enables you to capture information about the IP traffic going to and from network interfaces in your VPC. After you've created a flow log, you can view and retrieve its data in Amazon CloudWatch Logs. It is recommended that VPC Flow Logs be enabled for packet 'Rejects' for VPCs.
  resource: vpc
  filters:
    - not:
        - type: flow-logs
          enabled: true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  18.- Confirm the VPC default security group does not allow inbound and outbound traffic 🟩
&lt;/h3&gt;

&lt;p&gt;The rules for the default security group allow all outbound and inbound traffic from network interfaces (and their associated instances) that are assigned to the same security group.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We do not recommend using the default security group&lt;/strong&gt;. Because the default security group cannot be deleted, you should change the default security group rules setting to restrict inbound and outbound traffic. This prevents unintended traffic if the default security group is accidentally configured for resources, such as EC2 instances.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/AWS-security-best-practices-vpc.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0IDZmQ6N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/AWS-security-best-practices-vpc.png" alt="AWS security best practices VPC" width="880" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Get the description of the default security group within the selected region:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws ec2 describe-security-groups
--region REGION
--filters Name=group-name,Values='default'
--output table
--query 'SecurityGroups[*].IpPermissions[*].IpRanges'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If this command does not return any output, then the default security group does not allow public inbound traffic. Otherwise, it should return the inbound traffic source IPs defined, as in the following example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;------------------------
|DescribeSecurityGroups|
+----------------------+
|        CidrIp        |
+----------------------+
|  0.0.0.0/0           |
|  ::/0                |
|  1.2.3.4/32          |
|  1.2.3.5/32          |
+----------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the IPs returned are &lt;code&gt;0.0.0.0/0&lt;/code&gt; or &lt;code&gt;::/0&lt;/code&gt;, then the selected default security group is allowing public inbound traffic. We’ve explained previously &lt;a href="https://sysdig.com/blog/aws-secure-ssh-ec2-threats/"&gt;what the real threats are when securing SSH on EC2&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To remediate this issue, &lt;strong&gt;create new security groups and assign those security groups to your resources&lt;/strong&gt;. To prevent the default security groups from being used, remove their inbound and outbound rules.&lt;/p&gt;

&lt;h3&gt;
  
  
  19.- Enable EBS default encryption 🟥🟥🟥
&lt;/h3&gt;

&lt;p&gt;When encryption is enabled for your account, Amazon EBS volumes and snapshot copies are encrypted at rest. This adds an additional layer of protection for your data. For more information, see Encryption by default in the Amazon &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/data-protection.html"&gt;EC2 User Guide&lt;/a&gt; for Linux Instances.&lt;/p&gt;

&lt;p&gt;Note that following instance types do not support encryption: R1, C1, and M1.&lt;/p&gt;

&lt;p&gt;Run the &lt;em&gt;get-ebs-encryption-by-default&lt;/em&gt; command to know whether EBS encryption by default is enabled for your AWS cloud account in the selected region:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws ec2 get-ebs-encryption-by-default
--region REGION
--query 'EbsEncryptionByDefault'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the command returns false, the encryption of data at rest by default for new EBS volumes is not enabled in the selected AWS region. Fix it with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws ec2 enable-ebs-encryption-by-default
--region REGION
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  AWS Database Migration Service (DMS)
&lt;/h2&gt;

&lt;p&gt;AWS Database Migration Service (AWS DMS) is a cloud service that makes it easy to migrate relational databases, data warehouses, NoSQL databases, and other types of data stores. You can use AWS DMS to migrate your data into the AWS Cloud or between combinations of cloud and on-premises setups.&lt;/p&gt;

&lt;h3&gt;
  
  
  20.- Verify AWS Database Migration Service replication instances are not public 🟥🟥🟥
&lt;/h3&gt;

&lt;p&gt;Ensure that your Amazon Database Migration Service (DMS) is not publicly accessible from the Internet in order to avoid exposing private data and minimize security risks. &lt;strong&gt;A DMS replication instance should have a private IP address and the Publicly Accessible feature disabled&lt;/strong&gt; when both the source and the target databases are in the same network that is connected to the instance’s VPC through a VPN, VPC peering connection, or using an AWS Direct Connect dedicated connection.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Sign in to AWS Management Console at &lt;a href="https://console.aws.amazon.com/dms/"&gt;https://console.aws.amazon.com/dms/&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt; In the left navigation panel, choose &lt;strong&gt;Replication instances&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt; Select the DMS replication instance that you want to examine to open the panel with the resource configuration details.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select the &lt;strong&gt;Overview&lt;/strong&gt; tab from the dashboard bottom panel and check the &lt;strong&gt;Publicly accessible&lt;/strong&gt; configuration attribute value. If the attribute value is set to &lt;strong&gt;Yes&lt;/strong&gt;, the selected Amazon DMS replication instance is accessible outside the Virtual Private Cloud (VPC) and can be exposed to security risks. To fix it, do the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Click the &lt;strong&gt;Create replication instance&lt;/strong&gt; button from the dashboard top menu to initiate the launch process.&lt;/li&gt;
&lt;li&gt; On &lt;strong&gt;Create replication instance&lt;/strong&gt; page, perform the following:

&lt;ol&gt;
&lt;li&gt; Uncheck &lt;strong&gt;Publicly accessible&lt;/strong&gt; checkbox to disable the public access to the new replication instance. If this setting is disabled, Amazon DMS will not assign a public IP address to the instance at creation and you will not be able to connect to the source/target databases outside the VPC.&lt;/li&gt;
&lt;li&gt; Provide a unique name for the new replication instance within the &lt;strong&gt;Name&lt;/strong&gt; box, then configure the rest of the instance settings using the configuration information copied at step No. 5.&lt;/li&gt;
&lt;li&gt; Click &lt;strong&gt;Create replication instance&lt;/strong&gt; to launch your new Amazon DMS instance.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt; Update your database migration plan by developing a new migration task to include the newly created AWS DMS replication instance.&lt;/li&gt;
&lt;li&gt; To stop adding charges for the old replication instance:

&lt;ol&gt;
&lt;li&gt; Select the old DMS instance, then click the &lt;strong&gt;Delete&lt;/strong&gt; button from the dashboard top menu.&lt;/li&gt;
&lt;li&gt; Within the &lt;strong&gt;Delete replication instance&lt;/strong&gt; dialog box, review the instance details then click &lt;strong&gt;Delete&lt;/strong&gt; to terminate the selected DMS resource.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Repeat step Nos. 3 and 4 for each AWS DMS replication instance provisioned in the selected region.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Change the region from the console navigation bar and repeat the process for all the other regions.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Learn more about &lt;a href="https://docs.aws.amazon.com/dms/latest/userguide/CHAP_BestPractices.html"&gt;security best practices for AWS Database Migration Service&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Amazon Elastic Block Store (EBS)
&lt;/h2&gt;

&lt;p&gt;Amazon Elastic Block Store (Amazon EBS) provides block level storage volumes for use with EC2 instances. EBS volumes behave like raw, unformatted block devices. You can mount these volumes as devices on your instances. EBS volumes that are attached to an instance are exposed as storage volumes that persist independently from the life of the instance. You can create a file system on top of these volumes, or use them in any way you would use a block device (such as a hard drive).&lt;/p&gt;

&lt;p&gt;You can dynamically change the configuration of a volume attached to an instance.&lt;/p&gt;

&lt;h3&gt;
  
  
  21.- Ensure Amazon EBS snapshots are not public, or to be restored by anyone 🟥🟥🟥
&lt;/h3&gt;

&lt;p&gt;EBS snapshots are used to back up the data on your EBS volumes to Amazon S3 at a specific point in time. You can use the snapshots to restore previous states of EBS volumes. It is rarely acceptable to share a snapshot with the public. &lt;strong&gt;Typically, the decision to share a snapshot publicly was made in error or without a complete understanding of the implications&lt;/strong&gt;. This check helps ensure that all such sharing was fully planned and intentional.&lt;/p&gt;

&lt;p&gt;Get the list of all EBS volume snapshots:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws ec2 describe-snapshots
--region REGION
--owner-ids ACCOUNT_ID
--filters Name=status,Values=completed
--output table
--query 'Snapshots[*].SnapshotId'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For each snapshot, check its &lt;code&gt;createVolumePermission&lt;/code&gt; attribute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws ec2 describe-snapshot-attribute
--region REGION
--snapshot-id SNAPSHOT_ID
--attribute createVolumePermission
--query 'CreateVolumePermissions[]'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output from the previous command returns information about the permissions for creating EBS volumes from the selected snapshot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Group": "all"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the command output is &lt;code&gt;"Group": "all"&lt;/code&gt;, the snapshot is accessible to all AWS accounts and users. If this is the case, take your time to run this command to fix it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws ec2 modify-snapshot-attribute
--region REGION
--snapshot-id SNAPSHOT_ID
--attribute createVolumePermission
--operation-type remove
--group-names all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Amazon OpenSearch Service
&lt;/h2&gt;

&lt;p&gt;Amazon OpenSearch Service is a managed service that makes it easy to deploy, operate, and scale OpenSearch clusters in the AWS Cloud. Amazon OpenSearch Service is the successor to Amazon Elasticsearch Service and supports OpenSearch and legacy Elasticsearch OSS (up to 7.10, the final open source version of the software). When you create a cluster, you have the option of which search engine to use.&lt;/p&gt;

&lt;h3&gt;
  
  
  22.- Ensure Elasticsearch domains have encryption at rest enabled 🟥🟥🟥
&lt;/h3&gt;

&lt;p&gt;For an added layer of security for your sensitive data in OpenSearch, you should configure your OpenSearch to be encrypted at rest. Elasticsearch domains offer encryption of data at rest. The feature uses AWS KMS to store and manage your encryption keys. To perform the encryption, it uses the Advanced Encryption Standard algorithm with 256-bit keys (AES-256).&lt;/p&gt;

&lt;p&gt;List all Amazon OpenSearch domains currently available:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws es list-domain-names --region REGION
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now determine if &lt;code&gt;data-at-rest encryption&lt;/code&gt; feature is enabled with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws es describe-elasticsearch-domain
--region REGION
--domain-name DOMAIN_NAME
--query 'DomainStatus.EncryptionAtRestOptions'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the &lt;code&gt;Enabled&lt;/code&gt; flag is false, the data-at-rest encryption is not enabled for the selected Amazon ElasticSearch domain. Fix it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws es create-elasticsearch-domain
--region REGION
--domain-name DOMAIN_NAME
--elasticsearch-version 5.5
--elasticsearch-cluster-config InstanceType=m4.large.elasticsearch,InstanceCount=2
--ebs-options EBSEnabled=true,VolumeType=standard,VolumeSize=200
--access-policies file://source-domain-access-policy.json
--vpc-options SubnetIds=SUBNET_ID,SecurityGroupIds=SECURITY_GROUP_ID
--encryption-at-rest-options Enabled=true,KmsKeyId=KMS_KEY_ID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the new cluster is provisioned, upload the existing data (exported from the original cluster) to the newly created cluster.&lt;/p&gt;

&lt;p&gt;After all the data is uploaded, it is safe to remove the unencrypted OpenSearch domain to stop incurring charges for the resource:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws es delete-elasticsearch-domain
--region REGION
--domain-name DOMAIN_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Amazon SageMaker
&lt;/h2&gt;

&lt;p&gt;Amazon SageMaker is a fully-managed machine learning service. With Amazon SageMaker, data scientists and developers can quickly build and train machine learning models, and then deploy them into a production-ready hosted environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  23.- Verify SageMaker notebook instances do not have direct internet access 🟨🟨
&lt;/h3&gt;

&lt;p&gt;If you configure your SageMaker instance without a VPC, then, by default, direct internet access is enabled on your instance. You should configure your instance with a VPC and change the default setting to Disable — Access the internet through a VPC.&lt;/p&gt;

&lt;p&gt;To train or host models from a notebook, you need internet access. To enable internet access, &lt;strong&gt;make sure that your VPC has a NAT gateway and your security group allows outbound connections&lt;/strong&gt;. To learn more about how to connect a notebook instance to resources in a VPC, see “&lt;a href="https://docs.amazonaws.cn/en_us/sagemaker/latest/dg/notebook-interface-endpoint.html"&gt;Connect a notebook instance to resources in a VPC&lt;/a&gt;” in the Amazon SageMaker Developer Guide.&lt;/p&gt;

&lt;p&gt;You should also ensure that access to your SageMaker configuration is limited to only authorized users. Restrict users’ IAM permissions to modify SageMaker settings and resources.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Sign in to the AWS Management Console at &lt;a href="https://console.aws.amazon.com/sagemaker/"&gt;https://console.aws.amazon.com/sagemaker/&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt; In the navigation panel, under &lt;strong&gt;Notebook&lt;/strong&gt;, choose &lt;strong&gt;Notebook instances&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt; Select the SageMaker notebook instance that you want to examine and click on the instance name (link).&lt;/li&gt;
&lt;li&gt; On the selected instance configuration page, within the Network section, check for any VPC subnet IDs and security group IDs. If these network configuration details are not available, instead the following status is displayed: “&lt;strong&gt;No custom VPC settings applied&lt;/strong&gt;.” The notebook instance is not running inside a VPC network, therefore you can follow the steps described in this conformity rule to deploy the instance within a VPC. Otherwise, if the notebook instance is running inside a VPC, check the &lt;strong&gt;Direct internet access&lt;/strong&gt; configuration attribute value. If the attribute value is set to &lt;strong&gt;Enabled&lt;/strong&gt;, the selected Amazon SageMaker notebook instance is publicly accessible.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If the notebook has direct internet access enabled, fix it by recreating it with this CLI command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws sagemaker create-notebook-instance
--region REGION
--notebook-instance-name NOTEBOOK_INSTANCE_NAME
--instance-type INSTANCE_TYPE
--role-arn ROLE_ARN
--kms-key-id KMS_KEY_ID
--subnet-id SUBNET_ID
--security-group-ids SECURITY_GROUP_ID
--direct-internet-access Disabled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  AWS Lambda
&lt;/h2&gt;

&lt;p&gt;With AWS Lambda, you can run code without provisioning or managing servers. You pay only for the compute time that you consume — there’s no charge when your code isn’t running. You can run code for virtually any type of application or backend service — all with zero administration.&lt;/p&gt;

&lt;p&gt;Just upload your code and Lambda takes care of everything required to run and scale your code with high availability. You can set up your code to automatically trigger from other AWS services or call it directly from any web or mobile app.&lt;/p&gt;

&lt;p&gt;It is important to mention the problems that could occur if we do not secure or audit the code we execute in our lambda functions, as you could be the &lt;a href="https://sysdig.com/blog/exploit-mitigate-aws-lambdas-mitre/"&gt;initial access for attackers&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  24.- Use supported runtimes for Lambda functions 🟨🟨
&lt;/h3&gt;

&lt;p&gt;This AWS security best practice recommends checking that the Lambda function settings for runtimes match the expected values set for the supported runtimes for each language. This control checks function settings for the following runtimes: nodejs16.x, nodejs14.x, nodejs12.x, python3.9, python3.8, python3.7, ruby2.7, java11, java8, java8.al2, go1.x, dotnetcore3.1, and dotnet6.&lt;/p&gt;

&lt;p&gt;The AWS Config rule ignores functions that have a package type of image.&lt;/p&gt;

&lt;p&gt;Lambda runtimes are built around a combination of operating system, programming language, and software libraries that are subject to maintenance and security updates. When a runtime component is no longer supported for security updates, Lambda deprecates the runtime. Even though you cannot create functions that use the deprecated runtime, the function is still available to process invocation events. Make sure that your Lambda functions are current and do not use out-of-date runtime environments.&lt;/p&gt;

&lt;p&gt;Get the names of all Amazon Lambda functions available in the selected AWS cloud region:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws lambda list-functions
  --region REGION
  --output table
  --query 'Functions[*].FunctionName'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now examine the runtime information available for each functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws lambda get-function-configuration
  --region REGION
  --function-name FUNCTION_NAME
  --query 'Runtime'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compare the value returned with the updated list of Amazon Lambda runtimes supported by AWS, as well as the end of support plan listed in the AWS documentation.&lt;/p&gt;

&lt;p&gt;If the runtime is unsupported, fix it to use the latest runtime version. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws lambda update-function-configuration
  --region REGION
  --function-name FUNCTION_NAME
  --runtime "nodejs16.x"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  AWS Key Management Service (AWS KMS)
&lt;/h2&gt;

&lt;p&gt;AWS Key Management Service (AWS KMS) is an encryption and key management service scaled for the cloud. AWS KMS keys and functionality are used by other AWS services, and you can use them to protect data in your own applications that use AWS.&lt;/p&gt;

&lt;h3&gt;
  
  
  25.- Do not unintentionally delete AWS KMS keys 🟨🟨
&lt;/h3&gt;

&lt;p&gt;KMS keys cannot be recovered once deleted. Data encrypted under a KMS key is also permanently unrecoverable if the KMS key is deleted. If meaningful data has been encrypted under a KMS key scheduled for deletion, consider decrypting the data or re-encrypting the data under a new KMS key unless you are intentionally performing a cryptographic erasure.&lt;/p&gt;

&lt;p&gt;When a KMS key is scheduled for deletion, a mandatory waiting period is enforced to allow time to reverse the deletion if it was scheduled in error. The default waiting period is 30 days, but it can be reduced to as short as seven days when the KMS key is scheduled for deletion. During the waiting period, the scheduled deletion can be canceled and the KMS key will not be deleted.&lt;/p&gt;

&lt;p&gt;List all Customer Master keys available in the selected AWS region:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws kms list-keys --region REGION
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the describe-key command for each CMK to identify any keys scheduled for deletion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws kms describe-key --key-id KEY_ID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output for this command shows the selected key metadata. If the &lt;code&gt;KeyState&lt;/code&gt; value is set to &lt;code&gt;PendingDeletion&lt;/code&gt;, the key is scheduled for deletion. But if this is not what you actually want (the most common case), unschedule the deletion with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws kms cancel-key-deletion --key-id KEY_ID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Amazon GuardDuty
&lt;/h2&gt;

&lt;p&gt;Amazon GuardDuty is a continuous security monitoring service. Amazon GuardDuty can help to &lt;a href="https://sysdig.com/blog/hunting-malware-with-amazon-guardduty-and-sysdig/"&gt;identify unexpected and potentially unauthorized or malicious activity&lt;/a&gt; in your AWS environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  26.- Enable GuardDuty 🟨🟨
&lt;/h3&gt;

&lt;p&gt;It is highly recommended that you enable GuardDuty in all supported AWS Regions. Doing so allows GuardDuty to generate findings about unauthorized or unusual activity, even in Regions that you do not actively use. This also allows GuardDuty to monitor CloudTrail events for global AWS services, such as IAM.&lt;/p&gt;

&lt;p&gt;List the IDs of all the existing Amazon GuardDuty detectors. A detector is an object that represents the AWS GuardDuty service. A detector must be created in order for GuardDuty to become operational:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws guardduty list-detectors
--region REGION
--query 'DetectorIds'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the list-detectors command output returns an empty array, then there are no GuardDuty detectors available. In this instance, the Amazon GuardDuty service is not enabled within your AWS account. If this is the case, create a detector with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws guardduty create-detector
--region REGION
--enable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the detector is enabled, it will start to pull and analyze independent streams of data from AWS CloudTrail, VPC flow logs, and &lt;a href="https://sysdig.com/blog/dns-security-cloud-protection/"&gt;DNS logs in order to generate findings&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS compliance standards &amp;amp; benchmarks
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Setting up and maintaining your AWS infrastructure to keep it secure is a never-ending effort&lt;/strong&gt; that will require a lot of time.&lt;/p&gt;

&lt;p&gt;For this, you will be better off following the compliance standard(s) relevant to your industry, since they provide all the requirements needed to effectively secure your cloud environment.&lt;/p&gt;

&lt;p&gt;Because of the ongoing nature of securing your environment and complying with a security standard, you might also want to recurrently run policies, such as &lt;strong&gt;CIS Amazon Web Services Foundations Benchmark&lt;/strong&gt;, which will audit your system and report any non-conformity it finds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Going all cloud opens a new world of possibilities, but it also opens a wide door to attacking vectors. Each new AWS service you leverage has its own set of potential dangers you need to be aware of and well prepared for.&lt;/p&gt;

&lt;p&gt;Luckily, cloud native security tools like &lt;strong&gt;&lt;a href="http://falco.org/"&gt;Falco&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href="https://cloudcustodian.io/"&gt;Cloud Custodian&lt;/a&gt;&lt;/strong&gt; can guide you through these best practices, and help you meet your compliance requirements.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>security</category>
      <category>cloud</category>
      <category>devops</category>
    </item>
    <item>
      <title>Blackhat 2022 recap – Trends and highlights</title>
      <dc:creator>Miguel</dc:creator>
      <pubDate>Tue, 16 Aug 2022 12:59:41 +0000</pubDate>
      <link>https://dev.to/sysdig/blackhat-2022-recap-trends-and-highlights-59fb</link>
      <guid>https://dev.to/sysdig/blackhat-2022-recap-trends-and-highlights-59fb</guid>
      <description>&lt;p&gt;Blackhat 2022, on its 25th anniversary, took place this week in Las Vegas. It’s the most important event for the infosec community and the best place for security vendors to showcase all their innovations and products in this ever-growing ecosystem. This year, attendees come from 111 different countries.&lt;/p&gt;

&lt;p&gt;In 2020, Black Hat added the word Cloud to the existing track about Platform Security. Research on Kubernetes, containers, and other cloud technologies had been presented at Black Hat before 2020, but adding Cloud to the track title really highlighted the importance of securing the cloud that many corporations and individuals rely upon every day.&lt;/p&gt;

&lt;p&gt;In summary, we have cloud at the core of most of the talks, eBPF is growing in visibility, and attacking and defending the supply chain as a priority. As a threat, we could say ransomware in the cloud and global conflict management, and finally the importance of early detection of burnout.&lt;/p&gt;

&lt;p&gt;In this Blackhat 2022 recap, we’ll share our insights about the talks that we believe to be the most interesting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Blackhat 2022 – KEYNOTES
&lt;/h2&gt;

&lt;p&gt;In this edition, one of the main topics in the keynotes was the &lt;strong&gt;control of information&lt;/strong&gt;, the problem with how &lt;strong&gt;fake news is impacting our lives, and the difficulties of checking reliable information&lt;/strong&gt;. The solution, in some cases, is to intensify controls on information sharing, but this could be used for censorship. Now it’s not just governments and companies that are involved. New players in the field, individuals, are part of it, and like spam detectors, we need something ethical to protect us.&lt;/p&gt;

&lt;p&gt;The invasion of Ukraine is another topic mentioned in the first few minutes of Blackhat 2022. Some companies started to participate, and banned relations with Russian projects or affected domain renewal in Russia. So, the end of these conflicts is all but certain, and instead it seems that they are progressively more chaotic with increasing impacts on society.&lt;/p&gt;

&lt;p&gt;Chris Krebs, Director of CISA, explained in one of the Blackhat 2022 keynotes the main four reasons for why it is so bad right now and left us with an important lesson: “Life is too short to work for a**holes.”&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Technology&lt;/strong&gt;: More software means more complexity and, by default, more insecure code integration to maintain and update. In addition, Krebs emphasized how the lack of vision within the cloud causes complex risk management.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Bad actors&lt;/strong&gt;: Attackers know all this and know the profit is in the cloud. As we mentioned in the &lt;a href="https://dig.sysdig.com/c/pf-anatomy-of-cloud-attacks?x=EFtBL7"&gt;anatomy of cloud attacks&lt;/a&gt;, cloud ransomware is the future threat and is going to have a big impact. Attackers are betting on targeting &lt;a href="https://sysdig.com/blog/software-supply-chain-security/"&gt;the supply chain&lt;/a&gt; to gain access.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Government&lt;/strong&gt;: Regulation, economics, and innovation are growing, but it is very difficult to work with governments efficiently. Compliance must change to get more results than a checklist. We must watch out for future global incidents to be prepared.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;People&lt;/strong&gt;: How do we balance all this information? In most cases, people are the end users of all this technology and the victims of breaches and incidents.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Kim Zetter, investigative journalist, gave a good overview of the evolution of threats and how this impacts companies. The media has had to adapt when it comes to explaining new vulnerabilities or threats to the audience. She mentioned the Pre-Stuxnet and Post-Stuxnet eras, where everything has changed but the same actors remain. She started with ransomware, evolving into more sophisticated malware that modified code to eventually directly affect the supply chain with SolarWinds.&lt;/p&gt;

&lt;p&gt;In a real case, she explained that a company with a perfect backup system and everything prepared to be restored (in case it was affected by ransomware) paid the ransom when it happened. Why? It never tested the recovery process. Therefore, we should anticipate and perform simulations just like we do fire drills.&lt;/p&gt;

&lt;p&gt;Finally, we all know the good security practices, such as isolating networks, reinforcing perimeters, mfa, IR plan and backups, that protect us from most attacks. But, critical infrastructure is still not fully implemented, remaining exposed and without authentication on the internet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Blackhat 2022 – Top Briefings
&lt;/h2&gt;

&lt;p&gt;During two days of Blackhat 2022 USA trending sessions, we were able to enjoy several high-level talks on cybersecurity. These are, in our opinion, the most remarkable ones.&lt;/p&gt;

&lt;h3&gt;
  
  
  IAM The One Who Knocks
&lt;/h3&gt;

&lt;p&gt;One of the most important parts of securing your cloud account is how to manage identity access. In this talk, &lt;a href="https://twitter.com/IgalGofman"&gt;Igal&lt;/a&gt; and &lt;a href="https://twitter.com/NoamDahan"&gt;Noam&lt;/a&gt; provide a good explanation of how each public cloud (AWS, GCP, and Azure) implements access and authorization. Every cloud provider works differently but there isn’t one that is clearly better than the others; the major difference is the scope of the permission. AWS scope is part of the policy itself, and they recommend AWS SSO.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/backhat-2022-01.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TXHN87B8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/backhat-2022-01.png" alt="Blackhat 2022 IAM Cloud" width="880" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another important topic was the non-human identities. Each provider calls them something different, but the attackers don’t care. They only like to exploit the Cloud IAM weaknesses and the speakers explain how with different examples.&lt;/p&gt;

&lt;p&gt;Here are the takeaways.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Default is the best friend of attackers: Maintaining a good &lt;a href="https://sysdig.com/blog/cnapp-cloud-security-sysdig/"&gt;CSPM&lt;/a&gt; is crucial to stop the majority of attacker’s attempts to control all your accounts. Avoid temporary fixes that become permanent.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Monitor and protect credentials: Not only is the creation part relevant, but the modification of a compromised account is a huge threat.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Log everything but know the limits: the golden rule of security is to log everything, but in some cases we exceed the limits. Attackers use this to hide their actions and go unnoticed. At this point, we want to highlight another option. Try to detect at runtime or at the time when these logs occur to avoid the large amount of logs (only one window is sufficient if the initial compromise attack is detected). That is what &lt;a href="https://falco.org/"&gt;Falco&lt;/a&gt; open source tries to do.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, the speakers shared different open source tools that will help you manage excessive permissions. Two types of tools, the constructive (adding only the requirements, the principle of least privilege) and the reductive (default permission and remove from it).&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Constructive&lt;/td&gt;
&lt;td&gt;Reductive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://github.com/salesforce/policy_sentry"&gt;policy-sentry&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://github.com/duo-labs/cloudtracker"&gt;Cloudtracker&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://github.com/iann0036/iamlive"&gt;iamlive&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://github.com/Netflix/repokid"&gt;Repokid&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://github.com/ermetic/access-undenied-aws"&gt;access-undenied-aws&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://github.com/WithSecureLabs/IAMSpy"&gt;IamSpy&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://github.com/nccgroup/PMapper"&gt;PMapper&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;a rel="noopener nofollow noreferrer" href="https://github.com/salesforce/cloudsplaining"&gt;Cloudsplaining&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Trying to Be Everything to Everyone: Let’s Talk About Burnout
&lt;/h3&gt;

&lt;p&gt;Burnout is no joke. You have to take care of yourself and detect burnout before it is too late. This talk exposed the problems within the security industry, including the high levels of mental workload, the rapid response that security engineers are forced to have when a shortage occurs, and when they must anticipate cyber attacks that lead to maintaining a high level of stress.&lt;/p&gt;

&lt;p&gt;Of course, it’s very difficult to quantify security, so it’s hard to know if we’re investing our time and effort (and money!) well. For this reason, we can often feel that we are not doing our job well no matter how hard we try.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/blackhat-2022-02.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Mw2m_zH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/blackhat-2022-02.png" alt="blackhat 2022 burnout" width="880" height="754"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The speaker suggests good health, physical fitness, and relaxation techniques. The most common solutions for burnout are to work in short time slots, balance it with your personal life or, if you can, stop working and be free. Joking aside, ask for help at the slightest risk of burnout.&lt;/p&gt;

&lt;h3&gt;
  
  
  RCE-as-a-Service: Lessons Learned from 5 Years of Real-World CI/CD Pipeline Compromise
&lt;/h3&gt;

&lt;p&gt;We have to go back to basics; this is one of the points to keep in mind. The speakers explained different use cases and examples where the CI/CD pipeline was compromised based on issues that are not new. Examples include exposed credentials encoded in YAML or other configuration files, failure to isolate networks, or not following the principle of least privilege. One of the demonstrations focused on cloud-to-premises hopping, an increasingly common threat.&lt;/p&gt;

&lt;p&gt;To solve this problem, one of the things mentioned is the signing process, verify everything we are running. We explain in detail these procedures in &lt;a href="https://sysdig.com/blog/secure-kubernetes-deployment-signature-verification/"&gt;Kubernetes by using cosign and connaisseur&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Trace Me if You Can: Bypassing Linux Syscall Tracing
&lt;/h3&gt;

&lt;p&gt;System call traces are used to detect different behaviors within linux systems. There are several tools to obtain this data and process it to generate alerts when something strange happens. Like the Kubecon talk (&lt;a href="https://kccnceu2022.sched.com/event/ytl7/bypassing-falco-how-to-compromise-a-cluster-without-tripping-the-soc-shay-berkovich-blackberry"&gt;Bypassing Falco&lt;/a&gt;), this talk focuses on the &lt;a href="https://falco.org/"&gt;Falco&lt;/a&gt; tool and the TOCTOU problem solved in the current version.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.usenix.org/conference/fast-05/tocttou-vulnerabilities-unix-style-file-systems-anatomical-study"&gt;TOCTOU&lt;/a&gt;, or time-to-check to time-to-user, is a software bug caused by a race condition. In this talk, the speaker simulates how the attacker could modify the trace of a syscall in several scenarios. Here, we summarize two of them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The first uses delay injection in the communication between the client (or compromised device) and the server (in this scenario, the C2C). The technique is based on delaying the response in the handshake when the communication is initiated. The communication, when the exploit replaces the original IP with a fake one, is hidden from post-forensic analysis. If we check the network traces in Wireshark, we can discover the real IP of the C2C in the first packets.&lt;/li&gt;
&lt;li&gt;  The second scenario is the same idea but on the routes we like to modify. The attack is performed to store information inside GKE, avoiding detection by changing the path of the file we are writing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The demo is performed exploiting using &lt;a href="https://github.com/rexguowork/phantom-attack"&gt;Phantom-attack&lt;/a&gt;, presented at DefCon 29. The mitigation was using the new version of Falco (&amp;gt;0.32), and it is also recommended to use other methods to block the system call such as seccomp. This would affect its performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Kubernetes Privilege Escalation: Container Escape == Cluster Admin?
&lt;/h3&gt;

&lt;p&gt;This talk explains the same concept presented at the KubeCon EU with the talk &lt;a href="https://kccnceu2022.sched.com/event/ytlb/trampoline-pods-node-to-admin-privesc-built-into-popular-k8s-platforms-yuval-avrahami-shaul-ben-hai-palo-alto-networks"&gt;Trampoline Pods&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The scenario presented is as follows: inside our Kubernetes cluster we have containers running, but one of these containers is vulnerable and the attacker gains access to execute commands and control the entire node using container escape techniques.&lt;/p&gt;

&lt;p&gt;What is the next step to control the entire cluster? Kubelet’s credentials are not enough, and the node permissions are different to be admin. The goal is to get control of a trampoline pod in DaemonSets to perform lateral moves between nodes and obtain control of the whole cluster. There is no clear list of what permissions are required to carry out this type of attack, but depending on which ones are required, one or the other can be performed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/blackhat-2022-kubernetes.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NR7eO82x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/blackhat-2022-kubernetes.png" alt="blackhat 2022 kubernetes pod" width="880" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AuthN/AuthZ:&lt;/strong&gt; Impersonate to escalate roles.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Acquire Tokens&lt;/strong&gt;: Create new tokens for privilege escalation and, with the service account, enable secret list and use it to authenticate to the api-server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RCE&lt;/strong&gt;: You do not need to escalate privileges to run your code, it depends on your configuration. It controls Kubelet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Steal Pods&lt;/strong&gt;: Move the pod from one node to another with a powerful services account. Update nodes or delete other pods permission required.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This Trampoline pod affects all major cloud providers with the default behavior and, for this, escaping the container means managing the entire cluster. They shared the tool &lt;a href="https://github.com/PaloAltoNetworks/rbac-police"&gt;rbac-policy&lt;/a&gt; that was presented in KubeCon EU.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cautious: A New Exploitation Method! No Pipe but as Nasty as Dirty Pipe
&lt;/h3&gt;

&lt;p&gt;The new exploitation method presented by &lt;a href="https://twitter.com/Markak_"&gt;Zhenpeng Lin&lt;/a&gt; is called &lt;a href="https://github.com/Markakd/DirtyCred"&gt;DirtyCred&lt;/a&gt; and is based on swapping Linux Kernel credentials. It’s simple, effective and generic. This allows it to perform container escape and still be an actual threat.&lt;/p&gt;

&lt;p&gt;Exploitation is performed on a system vulnerable to CVE-2021-4154 or CVE-2022-2588, and the speaker explained two path attacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attacking task credentials&lt;/strong&gt; (&lt;em&gt;struct cred&lt;/em&gt;): Our un-privileged credentials inside the kernel heap are modified, free, and privileged credentials are put in the same place to impersonate them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attacking open file credentials&lt;/strong&gt; (struct file): Free the file after checks but before writing to memory. Allocate a read-only file object in the freed memory slot.&lt;/p&gt;

&lt;p&gt;To do this deterministic and not wait for privileged users to allocate task credentials, the attacker could trigger privileged processes in user space (executables with root SUIDs or daemons running as root). Finally, the attacker needs to stabilize the file exploit by extending userfaultfd or FUSE (pause kernel execution).&lt;/p&gt;

&lt;p&gt;It’s a very interesting exploitation method that requires further research.&lt;/p&gt;

&lt;h3&gt;
  
  
  DNSSEC Downgrade Attacks
&lt;/h3&gt;

&lt;p&gt;DNSSEC is the solution to DNS, based on cryptography signatures and verification of the resolver with a chain of trust. DNSSEC protects us from DNS Poisoning when we have a compromised application. DNSSEC provides data origin authenticity and integrity, but not confidentiality.&lt;/p&gt;

&lt;p&gt;The attack is based on making the resolver use the weakest security path and attacking that weakest link in the chain of trust. The final model is that the attacker, without knowing the cryptographic secrets, is able to activate the resolver, intercept it, and modify the records and signatures. The result? Successful impersonation of a real resolver.&lt;/p&gt;

&lt;p&gt;Countermeasures against this are to require the stronger DS and to drop SHA-1.&lt;/p&gt;

&lt;p&gt;If you are interested in knowing more about DNS and how to configure it in a secure way in the cloud, read the article &lt;a href="https://sysdig.com/blog/dns-security-cloud-protection/"&gt;How to protect DNS in the Cloud&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scaling the Security Researcher to Eliminate OSS Vulnerabilities Once and For All
&lt;/h3&gt;

&lt;p&gt;The speakers started with a simple concept. When we detect a vulnerability in open source code, how do we fix it? Well, fork the code and PR with changes inside that resolve the vulnerabilities. But what if this insecure code is in thousands of repositories?&lt;/p&gt;

&lt;p&gt;The first vulnerability that was fixed is the download or update of dependencies via HTTP, which are vulnerable to MiTM and not recommended at all. But is it a real problem? Well, Sonatype maven core downloads still use HTTP (25%).&lt;/p&gt;

&lt;p&gt;To solve this problem, the speaker creates a python bot with CodeQL and scans 100k with a simple regex.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/blackhat-2022-vulnerability-regex.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U0ftRZ6n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/blackhat-2022-vulnerability-regex.png" alt="blackhat 2022 vulnerabilities OSS" width="880" height="134"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this, the bot created over 1,400 pull requests with an acceptance rate of 40%. Pretty impressive. But this is just the beginning. How can it do the same with all the security vulnerabilities within the repository code on a massive scale?&lt;/p&gt;

&lt;p&gt;Well, &lt;a href="https://github.com/openrewrite/rewrite"&gt;openRewrite&lt;/a&gt; has been introduced, an automated software refactoring to keep up to date with API changes, fix vulnerabilities, and improve code quality and the &lt;a href="https://github.com/moderneinc"&gt;Moderne&lt;/a&gt; platform to manage the entire process. The talk explained three vulnerabilities (temporary directory hijacking, Partial path traversal, and Zip Slip) and focused on java language.&lt;/p&gt;

&lt;h2&gt;
  
  
  What’s next?
&lt;/h2&gt;

&lt;p&gt;This has been the most relevant at Blackhat 2022 USA. The main topics are still Kubernetes security, cloud security, and supply chain attacks, but we have a lot of global incident presence.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/BlackHat-2022-USA-featured_Blog-images_AgentlessFUD_featured.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nKOpmP3G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/BlackHat-2022-USA-featured_Blog-images_AgentlessFUD_featured.png" alt="Blackhat 2022 recap" width="880" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a few months, we will have the next Blackhat in Europe. We hope to be here with more great talks and demos.&lt;/p&gt;

</description>
      <category>events</category>
      <category>security</category>
      <category>discuss</category>
      <category>news</category>
    </item>
    <item>
      <title>Understanding CVSS score: Are vulnerability scores misleading you?</title>
      <dc:creator>Miguel</dc:creator>
      <pubDate>Wed, 20 Jul 2022 14:16:13 +0000</pubDate>
      <link>https://dev.to/sysdig/understanding-cvss-score-are-vulnerability-scores-misleading-you-345</link>
      <guid>https://dev.to/sysdig/understanding-cvss-score-are-vulnerability-scores-misleading-you-345</guid>
      <description>&lt;p&gt;&lt;strong&gt;Vulnerabilities are everywhere.&lt;/strong&gt; Vetting, mitigating, and remediating them at scale is exhausting for security practitioners. Let’s keep in mind that no organization has the capacity to find and fix all vulnerabilities. The key is to understand what a vulnerability is, interpret the meanings of the &lt;strong&gt;CVSS score&lt;/strong&gt;, and &lt;strong&gt;prioritize and effectively use&lt;/strong&gt; resources within constrained time limits or delivery windows.&lt;/p&gt;

&lt;p&gt;Since 2016, new &lt;a href="https://www.cvedetails.com/browse-by-date.php"&gt;vulnerabilities reported each year&lt;/a&gt; have nearly tripled. As of April 2022, &lt;strong&gt;predictions about the number of new vulnerabilities continue to come true&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The trend continues to increase. Basically, &lt;strong&gt;more code translates to more vulnerabilities&lt;/strong&gt;. And code now takes many forms beyond just applications or software. Code exists within embedded systems and IoT devices, resulting in hardware-born vulnerabilities, and code is also used to define and operate infrastructure as part of DevOps practices. It is now commonplace among security engineers or analysts to be accustomed to the Internet being broken every week. The &lt;a href="https://www.globenewswire.com/news-release/2022/02/10/2382917/0/en/New-Reveal-Survey-Finds-Skilled-Developer-Shortage-Among-Top-Challenges-for-2022.html"&gt;shortage of developers&lt;/a&gt; is not helping either.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/CVSS-Severity-Score-01.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0DOED-SB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/CVSS-Severity-Score-01.png" alt="Vulnerabilities by the last years" width="880" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.cvedetails.com/browse-by-date.php"&gt;Vulnerabilities by the last years&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All critical vulnerabilities are not the equivalent of &lt;strong&gt;log4j&lt;/strong&gt; or &lt;strong&gt;spring4shell&lt;/strong&gt; in terms of widespread adoption of a software package, exploitability, or impact.&lt;/p&gt;

&lt;p&gt;The ideal state for any cybersecurity program is to be able to quickly identify vulnerabilities that are truly impacting the organization and are actionable. Burning out IT teams and security teams by chasing all vulnerabilities is untenable.&lt;/p&gt;

&lt;p&gt;In this article, we want to explain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  What is a &lt;strong&gt;vulnerability&lt;/strong&gt;?&lt;/li&gt;
&lt;li&gt;  What is the &lt;strong&gt;meaning&lt;/strong&gt; of the &lt;strong&gt;CVSS score&lt;/strong&gt;?&lt;/li&gt;
&lt;li&gt;  What &lt;strong&gt;variables impact CVSS scores&lt;/strong&gt;?&lt;/li&gt;
&lt;li&gt;  Is CVSS the &lt;strong&gt;best way to prioritize&lt;/strong&gt; within vulnerability management?&lt;/li&gt;
&lt;li&gt;  Are there &lt;strong&gt;alternatives&lt;/strong&gt; to CVSS for &lt;strong&gt;risk-based prioritization&lt;/strong&gt;?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is the meaning of vulnerability?
&lt;/h2&gt;

&lt;p&gt;MITRE defines a &lt;a href="https://nvd.nist.gov/vuln"&gt;vulnerability&lt;/a&gt; as:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“A weakness in the computational logic (e.g., code) found in software and hardware components that, when exploited, results in a negative impact to confidentiality, integrity, or availability.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For this reason, it is possible to have a &lt;strong&gt;critical vulnerability in a code that does not affect you at all&lt;/strong&gt;, for example, because this code runs on an IoT device that relies on other security controls that effectively mitigate exploitability of a latent vulnerability in the embedded code.&lt;/p&gt;

&lt;p&gt;On the other hand, you may have a &lt;strong&gt;vulnerability of low severity that negatively impacts availability of your application&lt;/strong&gt;, such as a denial of service. You’d likely prioritize fixing it as soon as possible, because fixing the issue directly impacts your business model.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/CVSS-Severity-Score-featured.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Rm06UEOL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/CVSS-Severity-Score-featured.png" alt="Understanding CVSS score" width="880" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we mentioned before, the main problem is that &lt;strong&gt;we are continuously fed with new vulnerabilities while still wrestling with old vulnerabilities, and there is no easy way to manage them all&lt;/strong&gt;. We have to be quick in detection and resolution processes when something really critical is discovered and put a majority of our efforts there without forgetting the rest of the vulnerability ecosystem. It sounds simple in theory and underpins all modern security programs, but &lt;strong&gt;vulnerability prioritization in practice is now one of the biggest gaps in security&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To go deeper into vulnerability management, we will explain what the process is when a vulnerability is released.&lt;/p&gt;

&lt;h2&gt;
  
  
  The lifecycle of a vulnerability
&lt;/h2&gt;

&lt;p&gt;The origin of a vulnerability is not defined by anyone.&lt;/p&gt;

&lt;p&gt;Sometimes, it is large research by a company regularly testing their own code that spends great efforts to show the problem with an application or the abuse of a dependency. At other times, a vulnerability might be discovered as a result of an independent security researcher probing a system in their free time and reporting the findings as part of responsible disclosure, or by creating a proof of concept (PoC) to exploit a system and publishing the details on Twitter.&lt;/p&gt;

&lt;p&gt;These, before being officially published, are common examples of &lt;strong&gt;0-days&lt;/strong&gt;. It is an overloaded buzzword because if the vulnerability is already known, it is not a 0-day. This is why these types of &lt;strong&gt;vulnerabilities are gold in the &lt;a href="https://www.semanticscholar.org/paper/Understanding-Hidden-Information-Security-Threats%3A-Radianti-Gonzalez/ee98ff26eb43f2e834d6bc7b021f1a303bda6787"&gt;black markets&lt;/a&gt;&lt;/strong&gt;. If an attacker has intimate knowledge of a previously unidentified vuln, they can then exploit it readily since there’s likely a lack of detection and protection mechanisms in place for most organizations, at least in the initial access or exploitation phase.&lt;/p&gt;

&lt;p&gt;A good practice that is done by researchers is to give developers some time to start working on the patch to fix the vulnerability before registering. Otherwise, days could go by without a fix.&lt;/p&gt;

&lt;p&gt;What is the best thing to do then? Improve the process to be ready as soon as possible when a 0-day is disclosed and detect it from that moment on, providing the appropriate mitigations and in many cases, verifying that this vulnerability has not been used in the past (where it really was 0-day).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/CVSS-Severity-Score-02.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_2Wb2ehK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/CVSS-Severity-Score-02.png" alt="CVSS Severity Score Vulnerability lifecycle" width="880" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the vulnerability is registered, we have an ID that identifies it. This will help us to identify the vulnerability and check if we are being impacted or not. But where is it registered?&lt;/p&gt;

&lt;p&gt;One of the most common sites, but not the only one, is &lt;strong&gt;&lt;a href="https://cve.mitre.org/"&gt;Common Vulnerabilities and Exposures&lt;/a&gt;&lt;/strong&gt; (&lt;strong&gt;CVE&lt;/strong&gt;). &lt;strong&gt;MITRE Corporation&lt;/strong&gt; is the organization that identifies, defines, and catalogs publicly disclosed cybersecurity vulnerabilities and shares that information of &lt;strong&gt;CVE-IDs publicly&lt;/strong&gt;. &lt;strong&gt;Vulnerability information&lt;/strong&gt; is also shared with the &lt;strong&gt;NIST organization&lt;/strong&gt;, where additional information may be added on to provide further details or security guidance. That information lives within NIST’s &lt;strong&gt;&lt;a href="https://nvd.nist.gov/"&gt;National Vulnerability Database&lt;/a&gt;&lt;/strong&gt; (&lt;strong&gt;NVD&lt;/strong&gt;) and is organized by &lt;strong&gt;CVE-IDs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Other states have their own system to catalog and store their vulnerabilities, such as the &lt;a href="http://www.cnnvd.org.cn/"&gt;Chinese National Vulnerability Database&lt;/a&gt; (CNNVD) or &lt;a href="http://jvn.jp/en/"&gt;Japan Vulnerabilities Notes&lt;/a&gt; (JVN). But in this article, we focus on the &lt;strong&gt;NVD&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Once we have confirmation that the vulnerability is real, exploitable, and has an ID, the next process is to assess the severity.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the score of a vulnerability is calculated
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://www.first.org/cvss/"&gt;Common Vulnerability Scoring System&lt;/a&gt; (CVSS) provides a way to capture the key characteristics of a vulnerability and produce a numerical score that reflects its severity. Many security teams and SOCs use the CVSS to prioritize vulnerability management activities, such as incident response processes, defect tracking and resolution, or implementation of a mitigating control.&lt;/p&gt;

&lt;p&gt;The metrics used in &lt;strong&gt;CVSS v3.1&lt;/strong&gt;, the latest version, assess the different elements that depend on the &lt;strong&gt;exploitation process and the impact&lt;/strong&gt;, resulting in the final severity score. The first thing we can find in the documentation is that &lt;strong&gt;CVSS measures severity, not risk&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;CVSS, as scored, is an “objective” score when you set some attributes of the vulnerability without context, and a formula produces a score that also maps to a “Severity.” Below, we can see a real example of the &lt;a href="https://www.first.org/cvss/calculator/3.0#CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"&gt;CVSS&lt;/a&gt; of Spring4Shell vulnerability, which scores the severity in 9.8 CRITICAL.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/CVSS-Severity-Score-03.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SNsB9hC_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/CVSS-Severity-Score-03.png" alt="CVE-2022-22963 CVSS score example" width="880" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://www.first.org/cvss/v3.1/specification-document"&gt;base score is calculated&lt;/a&gt; with eight variables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Attack Vector (AV)&lt;/strong&gt;: There are four options that represent the access method to exploit the vulnerability. The network is the most valued because it allows the remote and that implies that the attacker can exploit it from any location. The rest go from highest to lowest in restriction. In the case of Local, the vulnerable component is not bound to the network stack and the attacker’s path is via hardware access, remote, or hijacking the identity of an authorized user through social engineering.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Attack complexity (AC)&lt;/strong&gt;: There are two options, low or high. In version 3.1, it was updated and depends on the system requirements to be vulnerable, where there can be a debate if a configuration is taken as likely or unlikely. In the case of &lt;strong&gt;high complexity&lt;/strong&gt;, it is defined as a successful attack which depends on conditions beyond the attacker’s control, but requires the attacker to expend a measurable amount of effort in preparation or execution against the vulnerable component. For example, the attacker needs to use &lt;strong&gt;brute force attacks&lt;/strong&gt; to win a &lt;strong&gt;race condition,&lt;/strong&gt; and not a silver bullet like &lt;strong&gt;log4j&lt;/strong&gt; with a single command.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Privileges Required (PR)&lt;/strong&gt;: There are three options. None is when the &lt;strong&gt;vulnerability&lt;/strong&gt; can be &lt;strong&gt;exploited without authentication&lt;/strong&gt;. This also makes it difficult for the attribution or the path followed by the attacker after exploitation. If this metric is high, the attacker requires admin privileges or something similar to affect allowing access to component-wide settings, for example.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;User interaction (UI)&lt;/strong&gt;: If it requires interaction, it is a lower score. This is common in mobile applications where the user needs to interact with the threat (malware) in order to breach their device. Another example, similar to a phishing attack, in itself is not a risk, but the attacker uses social engineering to get the victim to click on the link and be &lt;em&gt;pwned&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scope (S)&lt;/strong&gt;: The score will depend on whether the vulnerability affects only a specific component or affects the entire application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CIA (Confidentiality, Integrity and Availability)&lt;/strong&gt;: &lt;a href="https://www.nccoe.nist.gov/publication/1800-26/VolA/index.html#:~:text=The%20CIA%20triad%20represents%20the,%2C%20and%20availability%2C%20as%20follows."&gt;The CIA triad&lt;/a&gt;, a respected security model that forms the basis for the development of security systems and policies. Here is the real impact of the vulnerability. The other part is the process of exploitation. With an RCE, the attacker has full control of the victim machine, and if the privileges are sufficient, it affects all three parties with high severity.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The final format of &lt;a href="https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?name=CVE-2022-22965&amp;amp;vector=AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H&amp;amp;version=3.1&amp;amp;source=NIST"&gt;CVE-2022-22965&lt;/a&gt; is a vector with this information: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H&lt;/p&gt;

&lt;p&gt;This first part corresponds to &lt;strong&gt;the base score&lt;/strong&gt;, an objective value that should remain stable over time and consistent across organizations. As a supplement, there are two more metrics, temporal and environment; these values introduce more &lt;strong&gt;scoring complexity&lt;/strong&gt; though and may not be something your organization chooses to pay attention to in the early phases of vulnerability management.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Temporal metrics&lt;/strong&gt; measure &lt;strong&gt;the current state of exploit techniques or proof of concept code availability&lt;/strong&gt;, the existence of any patches or workarounds, and the confidence in the description of a vulnerability. It is something that will change along the lifecycle of the vulnerability because there’s a &lt;strong&gt;huge difference between having or not having the remediation ready&lt;/strong&gt;. &lt;strong&gt;Environment metrics&lt;/strong&gt; enable the practitioners to customize the CVSS score depending on the importance or business criticality of the affected IT asset to the impacted organization.&lt;/p&gt;

&lt;p&gt;Vendors, such as &lt;strong&gt;RedHat&lt;/strong&gt; or &lt;strong&gt;Debian&lt;/strong&gt; as the base distributor provider, will also evaluate the severity of the vulnerability in a specific context (i.e., the package inside the distribution). Customers may trust the score of the vendor more than the generic scores assigned by MITRE or NIST, as it is usually more accurate.&lt;/p&gt;

&lt;p&gt;As we can see, &lt;strong&gt;this score is not impacted by the remediation part or fix process&lt;/strong&gt;. If this vulnerability needs a great effort to be solved, it does not impact the final score. In addition, two vulnerabilities with the same score could have a very different impact or likelihood because they occur in the economic sector or business vertical.&lt;/p&gt;

&lt;p&gt;From the CVSS score calculation, several derivations appear that can be of help when evaluating the safety of a system. Some of them are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.nist.gov/publications/common-misuse-scoring-system-cmss-metrics-software-feature-misuse-vulnerabilities"&gt;Common Misuse Scoring System&lt;/a&gt;&lt;/strong&gt; (CMSS): It is a set of measures of the severity of software featuring misuse vulnerabilities. Misuse vulnerabilities allow attackers to use the functionality that was intended to be beneficial for malicious purposes. This score could assist companies to provide data to be used in quantitative assessments of the overall security posture of a system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.nist.gov/publications/common-configuration-scoring-system-ccss-metrics-software-security-configuration"&gt;Common Configuration Scoring System&lt;/a&gt;&lt;/strong&gt; (CCSS): CCSS is based on CVSS and CMSS. The most notable difference is the type of exploitation: active or passive. Active exploitation refers to an attacker performing actions to take advantage of a misconfiguration, while passive exploitation refers to a misconfiguration that prevents authorized actions from occurring, such as a configuration setting that prevents audit log records from being generated for security events.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a href="https://cwe.mitre.org/cwss/cwss_v1.0.1.html"&gt;Common Weakness Scoring System&lt;/a&gt;&lt;/strong&gt; (CWSS): Conceptually, CVSS and CWSS are quite similar. CWSS can be applied in the early process of releasing a new vulnerability. In addition, it can serve to supplement the lack of some information in the vulnerability report. Because the conservative approach is to inflate the scores, a deep understanding of the affected technology provides some of this unavailable information. When a new vulnerability is reported, it is possible to report it together with the exploited week, CWE-ID / CWSS in the same way as with CVSS.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is obvious that we must feed our systems with more information to correlate with the CVSS and improve our vulnerability management. Remember that risk-based prioritization is the goal of all modern cybersecurity programs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using CVSS Score Alternatives to Prioritize Security Risk
&lt;/h3&gt;

&lt;p&gt;If we &lt;strong&gt;dig deeper into the meaning of vulnerability severity&lt;/strong&gt;, we may be more interested in other characteristics when calculating the &lt;strong&gt;CVSS score&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Obviously, depending on the use case or business sector, it is possible to find alternatives to the &lt;strong&gt;CVSS&lt;/strong&gt; to help you prioritize the management of your vulnerabilities. It’s not always possible to patch quickly enough, especially in cases of third-party code or partner integrations. In this case, the &lt;strong&gt;shift-left approach is not enough&lt;/strong&gt; and we recommend the use of &lt;strong&gt;&lt;a href="https://sysdig.com/learn-cloud-native/kubernetes-security/runtime-security/"&gt;runtime security&lt;/a&gt;&lt;/strong&gt; as another layer of security that enables early detection and identification of affected software, expediting the implementation of a mitigating security control.&lt;/p&gt;

&lt;h4&gt;
  
  
  Exploit Prediction Scoring System
&lt;/h4&gt;

&lt;p&gt;What is the actual probability of a vulnerability being exploited by an attacker? That probability is explained by the &lt;a href="https://www.first.org/epss/model"&gt;Exploit Prediction Scoring System&lt;/a&gt; (EPSS). The EPSS model produces a probability score that, the higher the score, &lt;strong&gt;the greater the likelihood that a vulnerability will be exploited&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The score is maintained by the same organization as the &lt;strong&gt;CVSS&lt;/strong&gt;, &lt;strong&gt;MITRE&lt;/strong&gt;, which &lt;strong&gt;guarantees its consistency&lt;/strong&gt; with the above-mentioned vulnerability taxonomies and classification systems. If we look at the highest rated vulnerabilities of the last 30 days, we better understand the potential real impact of vulnerabilities. An example can be seen here with &lt;a href="https://nvd.nist.gov/vuln/detail/CVE-2022-0441"&gt;CVE-2022-0441&lt;/a&gt;, which relates to the MasterStudy LMS WordPress plugin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/CVSS-Severity-Score-04.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--stICk62M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/CVSS-Severity-Score-04.png" alt="EPSS Example CVSS Severity CVE " width="880" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To calculate the percentage, the &lt;strong&gt;EPSS&lt;/strong&gt; uses part of the &lt;strong&gt;CVSS&lt;/strong&gt; score but also uses threat intelligence to see how easy it is to exploit the vulnerability. For example, an &lt;strong&gt;exploit might enable exploitation of other vulnerabilities to increase impact&lt;/strong&gt;. As part of a complex attack chain, an attacker may achieve RCE by exploiting one vulnerability and can then exploit other vulnerabilities to elevate privileges, resulting in a much more significant impact. The score may also factor in availability of exploit tools or repositories, like &lt;a href="https://www.metasploit.com/"&gt;Metasploit&lt;/a&gt; or &lt;a href="https://www.exploit-db.com/"&gt;Exploit-db&lt;/a&gt;, which don’t require knowledge about the exploitation steps.&lt;/p&gt;

&lt;h4&gt;
  
  
  Stakeholder-specific Vulnerability Categorization
&lt;/h4&gt;

&lt;p&gt;The &lt;strong&gt;&lt;a href="https://github.com/CERTCC/SSVC"&gt;Stakeholder-specific Vulnerability Categorization&lt;/a&gt;&lt;/strong&gt; (&lt;strong&gt;SSVC&lt;/strong&gt;) is mostly a conceptual tool for vulnerability management. SSVC aims to avoid one-size-fits-all solutions in favor of a modular decision-making system with clearly defined and tested parts that vulnerability managers can select and use as appropriate to their context.&lt;/p&gt;

&lt;p&gt;The goal of &lt;strong&gt;SSVC is to be risk-oriented&lt;/strong&gt;, be more transparent in the calculation process, and be able to scale the quantification of vulnerability risk through automation.&lt;/p&gt;

&lt;h4&gt;
  
  
  Vendor’s scoring
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Vulnerability Priority Rating (VPR)&lt;/strong&gt; is maintained by &lt;a href="https://docs.tenable.com/tenablesc/Content/RiskMetrics.htm"&gt;Tenable&lt;/a&gt; and also uses the severity and the facility to be exploited, similar to &lt;strong&gt;EPSS&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The Vulnerability Priority Rating (VPR) is a dynamic companion to the data provided by the vulnerability’s CVSS score since &lt;a href="https://www.tenable.com/blog/what-is-vpr-and-how-is-it-different-from-cvss"&gt;Tenable updates the VPR&lt;/a&gt; to reflect the current threat landscape, such as the exploit code of a vulnerability becoming available or having escalated maturity. The VPR values range is from 0.1 to 10.0, with a higher value representing a higher likelihood of exploitation.&lt;/p&gt;

&lt;p&gt;Other vendors such as &lt;a href="https://docs.snyk.io/fixing-and-prioritizing-issues/starting-to-fix-vulnerabilities/snyk-priority-score"&gt;Snyk created their own score&lt;/a&gt; (&lt;strong&gt;Snyk Priority Score&lt;/strong&gt;) for prioritization by using &lt;strong&gt;CVSS&lt;/strong&gt; and other factors mentioned above, such as exploit maturity, remediation process, or mentions in the community even they &lt;strong&gt;rank vulnerabilities&lt;/strong&gt; as part of their own threat research that may not have &lt;strong&gt;CVE-IDs&lt;/strong&gt; associated but provide value in prioritization.&lt;/p&gt;

&lt;h4&gt;
  
  
  Vertical-specific approaches
&lt;/h4&gt;

&lt;p&gt;Relevant to the medical sector, &lt;a href="https://www.riskscoringsystem.com/medical/techspecmedical.pdf"&gt;Risk Scoring System for Medical Devices&lt;/a&gt; (&lt;strong&gt;RSS-MD&lt;/strong&gt;) is being considered and at a more generic level. As expected, a vulnerability in this industry directly affects people’s health or safety, so it is necessary to have a scale of its own to manage this type of vulnerability and relative impacts differently.&lt;/p&gt;

&lt;p&gt;Relevant to the manufacturing industry, &lt;a href="https://threatgen.com/resources/ivss/#:~:text=Overview,for%20industrial%20control%20systems%20vulnerabilities."&gt;Industrial Vulnerability Scoring System&lt;/a&gt; (&lt;strong&gt;IVSS&lt;/strong&gt;) incorporates part of its calculation factors such as physical security, among others. This score is specifically designed for vulnerabilities in industrial control systems that affect critical infrastructure where damage can impact entire cities and lives of citizens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next step? Incorporating vulnerability feeds and driving remediation
&lt;/h2&gt;

&lt;p&gt;The tendency, as seen above, is to &lt;strong&gt;calculate the best score for a vulnerability or the associated risk-based&lt;/strong&gt; on correlating as much information as possible that can be accessed and processed in order to “vitaminize” the final result.&lt;/p&gt;

&lt;p&gt;It is strange that one method contradicts another. Normally they will all have a similar view of the final severity, but these small differences are crucial in a huge scale of vulnerability management. The simplicity approach is worth stressing since some of these scoring mechanisms get incredibly complicated. Many orgs would benefit by keeping their risk-scoring simplified so they can focus their efforts on addressing security problems instead of burning cycles qualifying or quantifying risk.&lt;/p&gt;

&lt;p&gt;It is also necessary to &lt;strong&gt;have complete visibility of your situation at all times to know if we are being impacted as soon as possible and effectively reduce the risk caused&lt;/strong&gt; by them.&lt;/p&gt;

&lt;p&gt;With all this information, we now need to implement our vulnerability management processes and supporting tooling in our organization.&lt;/p&gt;

&lt;p&gt;These vulnerability scores can be viewed ad-hoc, but effective cybersecurity requires that you ingest vulnerability feeds into appropriate security tooling that serve the relevant stage of the system lifecycle.&lt;/p&gt;

&lt;p&gt;The key is to be prepared for a new vulnerability and be flexible to close the gap between the vulnerability release and the detection process in your environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/CVSS-Severity-Score-05.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i5rwOFxK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/CVSS-Severity-Score-05.png" alt="CVSS score lifecycle vulnerabilities " width="880" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the most famous feeds is &lt;a href="https://vulndb.cyberriskanalytics.com/"&gt;Vulndb&lt;/a&gt;, which uses &lt;strong&gt;&lt;a href="https://nvd.nist.gov/"&gt;National Vulnerability Database&lt;/a&gt;&lt;/strong&gt; (&lt;strong&gt;NVD&lt;/strong&gt;) as a trusted database of vulnerabilities and also owns registered vulnerabilities and collaborates with security companies to be as up-to-date as possible.&lt;/p&gt;

&lt;p&gt;If you’re missing the explicit details of a vulnerability, you must still acknowledge there is a potential risk and then accept, avoid, or mitigate it. &lt;strong&gt;You need to have an alternative to being sensitive with it&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A significant hurdle to overcome with respect to remediation is to be able to quickly patch every single asset or dependency that is impacted or potentially exploitable, and these processes also need to be able to scale. It’s not trivial to patch old versions that could impact new features or poor performance; do it in a massive way or have other implications. The problem is exacerbated with transitive dependencies. That is, your code or system likely relies on many other codebases or systems, and dependency chains become quite nested in practice. Sometimes, it is even necessary to patch old versions that are still being distributed. That is what &lt;strong&gt;RedHat&lt;/strong&gt; calls &lt;a href="https://access.redhat.com/security/updates/backporting"&gt;backporting&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Backporting
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Backporting&lt;/strong&gt; is essentially the management of updates through automation to minimize the associated risk. It is possible that a fix in a new version may adversely affect the previous version. You should be aware of when you want to upgrade as soon as possible.&lt;/p&gt;

&lt;p&gt;When a vendor offers to backport security fixes, we ensure that fixes do not introduce unwanted side effects and apply to previously released versions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons learned about cvss score
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Prioritization&lt;/strong&gt; in a world with hundreds of vulnerabilities every day is a necessity. We continuously develop more software that will be targeted by attackers and add to the libraries, firmware, or common dependencies that are already used by applications and systems.&lt;/p&gt;

&lt;p&gt;To help us, we need to &lt;strong&gt;ingest the vulnerability information&lt;/strong&gt; that organizations like MITRE share, &lt;strong&gt;generate better indicators through the correlation of other sources&lt;/strong&gt; of information, and &lt;strong&gt;maintain full visibility of our assets&lt;/strong&gt; (and associated attack vectors) to be quick in detecting the impact. Without this, it is impossible to both &lt;strong&gt;efficiently plan the vulnerability mitigation process to reduce the noise&lt;/strong&gt; and time in which we are vulnerable, and be effective in any cybersecurity program.&lt;/p&gt;

&lt;p&gt;Manual processes can’t scale to infinity, and you’ll never have enough headcount for all your security needs. &lt;strong&gt;Security needs to be seamless and automated&lt;/strong&gt;. Organizations must plan accordingly to keep ahead of the tide of critical vulnerabilities, like &lt;strong&gt;log4j&lt;/strong&gt; and &lt;strong&gt;spring4shell&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>security</category>
      <category>cvss</category>
      <category>cve</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Trends at Blackhat Asia 2022</title>
      <dc:creator>Miguel</dc:creator>
      <pubDate>Wed, 25 May 2022 10:25:19 +0000</pubDate>
      <link>https://dev.to/sysdig/trends-at-blackhat-asia-2022-12nh</link>
      <guid>https://dev.to/sysdig/trends-at-blackhat-asia-2022-12nh</guid>
      <description>&lt;p&gt;This week, &lt;a href="https://www.blackhat.com/asia-22/"&gt;BlackHat Asia 2022&lt;/a&gt; took place in hybrid mode. It’s one of the most important events within the #infosec community, where security experts show how far they can go. In this edition, the trend of talks and tools focused on improving the &lt;a href="https://sysdig.com/learn-cloud-native/kubernetes-security/kubernetes-security-101/"&gt;security of Kubernetes&lt;/a&gt;, &lt;a href="https://sysdig.com/learn-cloud-native/cloud-security/visibility-infrastructure-security/"&gt;Cloud Security&lt;/a&gt;, and &lt;a href="https://sysdig.com/blog/software-supply-chain-security/"&gt;Supply Chain&lt;/a&gt;, either from the perspective of the blue team or the red team.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/blackhatasia.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VeyzzjX9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/blackhatasia.png" alt="BlackHat Asia 2022" width="782" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this article, we’ll share our insights about a few talks and tools presented that we liked, and we’ll give you an idea of the future trends this year in cybersecurity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Briefings
&lt;/h2&gt;

&lt;p&gt;During two days of Blackhat Asia informative sessions, we were able to enjoy several high-level talks on cybersecurity. These are, in our opinion, the most remarkable ones.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Backdoor Investigation and Incident Response: From Zero to Profit&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Managing a security incident where a backdoor takes place is not trivial. This talk explains the &lt;a href="https://www.researchgate.net/publication/357081889_Backdoor_Investigation_and_Incident_Response_From_Zero_to_Profit"&gt;Backdoor Incidence Response Matrix&lt;/a&gt; (BDIRM) framework based on a triangle (server, backdoor, and network) for the acquisition and analysis of data to understand the attacker’s access. This allows us to make a better attribution and generate the best indicators of compromise or detection techniques.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;The Firmware Supply-Chain Security Is Broken: Can We Fix It?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Dependencies are the headache of any security auditor or developer, and even more so when you don’t have full visibility. In some cases, firmware components are vulnerable and continue to be used because they are not exploitable on their own. That is why when another vulnerability appears in a different component, it makes a previous one possible, making it much more complex to see the risk of old &lt;a href="https://sysdig.com/blog/vulnerability-score-cvss-meaning/"&gt;vulnerabilities that remained latent and badly scored&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Using Zero to Attack Zero-Knowledge Proof (ZKP) PLONK&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  This talk reviews an incredible but real case of theoretical vs practice. The speaker discusses a critical issue in a cutting-edge &lt;a href="https://cryptosubtlety.medium.com/00-8d4adcf4d255"&gt;ZKP PLONK C++ implementation&lt;/a&gt; which allows an attacker to create a forged proof that all verifiers will accept.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Quantify Security Effectively – Moving the Security Needle From the Security Trenches to the Boardroom&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  One of the keynotes. The speaker shared attracting ideas such as the definition of a &lt;strong&gt;shared responsibility model between developers and the cybersecurity team&lt;/strong&gt;. Understanding who &lt;strong&gt;owns the vulnerability&lt;/strong&gt; and who owns the mitigation is key to avoiding future incidents, loss of time, and money. It is necessary to escalate and &lt;a href="https://sysdig.com/blog/eliminate-noise-prioritize-risk-spotlight-sysdig/"&gt;prioritize&lt;/a&gt;, otherwise it is not achievable.&lt;/li&gt;
&lt;li&gt;  Another impressive concept is to &lt;strong&gt;quantify success in cybersecurity&lt;/strong&gt;. It is necessary to measure it and thus be able to check if the measures are being effective.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Like Lightning From the Cloud: Finding RCEs in an Embedded TLS Library and Toasting a Popular Cloud-connected UPS&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  This talk explains the importance of handling errors in code. The presenters explained how the exploitation of this would allow an attacker to control switches and systems such as UPS (controls system power if the network goes down), and how to replicate the exploit in different vendors because they use the same implementation. During the demonstration, they provoked the burning of the device.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Dynamic Process Isolation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Explanation of a remote Spectre attack using amplification techniques in combination with a remote timing server. The authors contribute with a process isolation mechanism that only isolates suspicious worker scripts following a detection mechanism. The &lt;a href="https://arxiv.org/pdf/2110.04751.pdf"&gt;Dynamic Process Isolation&lt;/a&gt; paper demonstrates a solution to detect all state-of-art of this kind of attack.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Arsenal
&lt;/h2&gt;

&lt;p&gt;Several tools were presented at Blackhat Asia this time. Although not necessarily new, it is always interesting to see the latest features or discover unknown tools. Something to mention are the differences when changing the point of view. For instance, considering Kubernetes tools as intended for red teams against those of the supply chain where the focus is its usage by blue teams.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://github.com/cyberark/kubesploit"&gt;Kubesploit&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  An open source penetration testing framework that can improve your cybersecurity posture scanning your cluster and also post-exploitation attacks. This tool is a must in your repository.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;a href="https://github.com/quarkslab/kdigger"&gt;Kdigger&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  This &lt;a href="https://blog.quarkslab.com/kdigger-a-context-discovery-tool-for-kubernetes.html"&gt;CLI tool&lt;/a&gt; is similar to the first one, but also recommended as it keeps adding improvements. To present the features, the demo shows a &lt;a href="https://github.com/quarkslab/minik8s-ctf"&gt;minik8s-ctf&lt;/a&gt; environment. It is really great to test and implement the new features.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;a href="https://github.com/Rnalter/ThunderCloud"&gt;ThunderCloud&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  This tool is a compilation of other techniques focused on AWS. Two of them are especially interesting: creating a &lt;a href="https://blog.christophetd.fr/phishing-for-aws-credentials-via-aws-sso-device-code-authentication/"&gt;SSO phishing to steal the access token&lt;/a&gt; and the simple code to collect the ACCESS KEYs when the &lt;a href="https://www.youtube.com/watch?v=_Ek0F-Xh57w&amp;amp;ab_channel=BlackHat"&gt;Cognito endpoint is known and misconfigured&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In Supply Chain Attacks, three tools were presented. &lt;a href="https://github.com/apiiro/combobulator"&gt;Dependency Combobulator&lt;/a&gt; detects dependency confusion using heuristics; for example, if the repository is public or time since last change. Similar to &lt;a href="https://github.com/ossillate-inc/packj"&gt;packj&lt;/a&gt; but in this case, it implements metadata (if the repository activates 2FA) or typosquatting detection, finding packages with similar names to avoid errors. &lt;a href="https://github.com/Checkmarx/chainalert-github-action"&gt;ChainAlert&lt;/a&gt; focuses on automation and detection of dependency commitment using the difference of tags between Github and NPM, but detection is very low.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/muraenateam/pwnppeteer"&gt;Pwnppeteer&lt;/a&gt; is an offensive tool to manage the phishing attacks with lambda functions to automate the process&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/Telegrip/Telegrip"&gt;Telegrip&lt;/a&gt; assists in obtaining evidence from telegrams for android devices with an autopsy-like UI, a great &lt;a href="https://sysdig.com/blog/guide-kubernetes-forensics-dfir/"&gt;forensic&lt;/a&gt; tool.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>blackhat</category>
      <category>security</category>
      <category>hacking</category>
      <category>news</category>
    </item>
    <item>
      <title>CSPM, CIEM, CWPP, and CNAPP: Guess who in cloud security landscape</title>
      <dc:creator>Miguel</dc:creator>
      <pubDate>Thu, 05 May 2022 13:35:17 +0000</pubDate>
      <link>https://dev.to/sysdig/cspm-ciem-cwpp-and-cnapp-guess-who-in-cloud-security-landscape-2ohb</link>
      <guid>https://dev.to/sysdig/cspm-ciem-cwpp-and-cnapp-guess-who-in-cloud-security-landscape-2ohb</guid>
      <description>&lt;p&gt;Your organization may be trying services in the cloud, running a few applications, or totally embracing this new era of cloud. Regardless if you are in the early stages or running all of your workloads in production, you have likely already noticed that cloud-native security is different from IT-managed data center security.&lt;/p&gt;

&lt;p&gt;A recent &lt;a href="https://www.gartner.com/en/documents/4008415-emerging-technologies-future-of-cloud-native-security-operations"&gt;Gartner survey&lt;/a&gt; found that 50 percent of participating organizations indicated that there is a lack of internal knowledge about cloud-native security.&lt;/p&gt;

&lt;p&gt;Security teams are trying to figure out the right security solutions to use in the cloud, but the market is evolving too fast for them to keep up. So, what are those terms you keep hearing from vendors, cloud providers, and security training courses? What are the things you should focus on?&lt;/p&gt;

&lt;p&gt;Gartner, Forrester, IDC, and 451 Group are some of the most well-known analyst firms that identify and describe emerging trends in the market and create definitions for new technologies. They have coined terms you know, like SIEM, CRM, and WAF. But we want to introduce you to new terms, such as &lt;a href="https://sysdig.com/products/secure/cspm-cloud-security-posture-management/"&gt;CSPM&lt;/a&gt;, &lt;a href="https://sysdig.com/products/secure/cwpp-cloud-workload-protection-platform/"&gt;CWPP&lt;/a&gt;, and &lt;a href="https://sysdig.com/use-cases/ciem-cloud-infrastructure-entitlements-management/"&gt;CIEM&lt;/a&gt;, among others.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/CNAPP-cloud-01.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Cuix6VaV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/CNAPP-cloud-01.png" alt="CNAPP CIEM CSPM CWAPP Gartner terms" width="880" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the latest categories mentioned in Gartner’s &lt;em&gt;Emerging Technologies: Future of Cloud-Native Security Operations&lt;/em&gt; is CNAPP. Where does this new term fit in? We can think of CNAPP as the convergence of CWPP, CSPM, and CIEM, plus some other goodies. I know that’s not a very helpful definition since you may not know what CWPP, CSPM, and CIEM mean yet, right?&lt;/p&gt;

&lt;p&gt;Let’s find out step by step.&lt;/p&gt;

&lt;h2&gt;
  
  
  CWPP
&lt;/h2&gt;

&lt;p&gt;It all started with &lt;strong&gt;DevOps teams moving their workloads&lt;/strong&gt; to the cloud.&lt;/p&gt;

&lt;p&gt;In order to &lt;strong&gt;secure the whole DevOps workflow&lt;/strong&gt;, security leaders need to fulfill some specific use cases, and that’s what Cloud Workload Protection Platform (CWPP) tools focus on. They secure workloads, typically providing cloud-based security solutions that protect instances on AWS, Microsoft Azure, Google Cloud Platform (GCP), and other cloud vendors.&lt;/p&gt;

&lt;p&gt;What are these use cases?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://sysdig.com/products/secure/runtime-security/"&gt;Runtime detection&lt;/a&gt;: Prevent and detect suspicious behavior at runtime in containers and microservices. Automate response for container threats.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://sysdig.com/blog/cve-2021-33909-sequoia-falco-linux-filesystem/"&gt;System hardening&lt;/a&gt;: Detect anomalous activity inside of Linux hosts or VM-based workloads running on top of the host.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://sysdig.com/blog/vulnerability-assessment/"&gt;Vulnerability management&lt;/a&gt;: Detect OS and non-OS vulnerabilities from container images stored in CI/CD and registries before deploying to production.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://sysdig.com/use-cases/network-security/"&gt;Network security&lt;/a&gt;: Visualize network traffic inside containers and Kubernetes, and enforce Kubernetes-native network segmentation.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://sysdig.com/blog/nist-800-53-compliance/"&gt;Compliance&lt;/a&gt;: Validate container compliance and ensure File Integrity Monitoring inside containers.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://sysdig.com/products/secure/container-forensics/"&gt;Incident Response&lt;/a&gt;: Conduct forensics and incident response for containers and Kubernetes even after the container is gone.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those are the use cases that would fall under a &lt;strong&gt;Cloud Workload Protection Platform (CWPP)&lt;/strong&gt; solution, and what a CWPP solution will handle, securing workloads across the application lifecycle.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSPM
&lt;/h2&gt;

&lt;p&gt;As the workloads moved to the cloud and DevOps teams started to provision their own infrastructure, &lt;strong&gt;security teams&lt;/strong&gt; that were used to having a controlled environment in local data centers realized their perimeter had widened.Thus, security teams in charge of securing cloud infrastructure need a different approach. They must also quickly adapt to the dynamic nature of the ephemeral infrastructure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloud-bound teams&lt;/strong&gt; must also quickly adapt to the new paradigm of the cloud infrastructure environment &lt;strong&gt;(immutable infra, the policy as code, and identity as the new perimeter, among others).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Like in local data centers, &lt;strong&gt;security professionals&lt;/strong&gt; had to be sure to meet compliance in the hosts instances, user accounts, and data privacy. But the &lt;strong&gt;&lt;a href="https://sysdig.com/blog/sysdig-visibility-security-platform/"&gt;lack of visibility&lt;/a&gt;&lt;/strong&gt; to know what assets they have in the cloud makes it really difficult to keep track of misconfigurations in those assets.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/learn-cloud-native/cloud-security/cloud-security-posture-management/"&gt;&lt;strong&gt;Cloud Security Posture Management&lt;/strong&gt; (CSPM)&lt;/a&gt; is the solution that unifies the different use cases aimed to protect the cloud control plane, basically tracking cloud resources and verifying the static configuration of the cloud. Some &lt;a href="https://sysdig.com/blog/cloud-security-posture-aws/"&gt;CSPM&lt;/a&gt; solutions will add extended capabilities, like providing remediation.&lt;/p&gt;

&lt;p&gt;Also, one of the main use cases of CSPM is to check that cloud settings are following &lt;a href="https://sysdig.com/blog/bad-guys-openings-in-your-cloud/"&gt;best practices&lt;/a&gt;. Having mapped &lt;strong&gt;out-of-the-box frameworks controls and benchmarks&lt;/strong&gt; can save cloud teams time when addressing things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Data storage &lt;strong&gt;exposed&lt;/strong&gt; directly to the &lt;strong&gt;internet&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;  Lack of encryption on databases.&lt;/li&gt;
&lt;li&gt;  Lack of multi-factor authentication enabled on critical system accounts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Getting &lt;strong&gt;notified if a violation occurs&lt;/strong&gt; lets teams take action to prioritize its remediation.&lt;/p&gt;

&lt;h2&gt;
  
  
  CIEM
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Identity Management&lt;/strong&gt; and &lt;strong&gt;data privacy&lt;/strong&gt; are also important aspects of a cloud security program.&lt;/p&gt;

&lt;p&gt;As mentioned before, when the perimeter was the local data center, it was easier to control who had access to what. Now, even serverless functions can act like users who access data.&lt;/p&gt;

&lt;p&gt;To address the &lt;a href="https://sysdig.com/blog/ciem-security-sysdig-secure/"&gt;cloud permissions gap&lt;/a&gt;, we have &lt;a href="https://sysdig.com/learn-cloud-native/cloud-security/what-is-cloud-infrastructure-entitlements-management-ciem/"&gt;&lt;strong&gt;Cloud Infrastructure Entitlement Management&lt;/strong&gt; (CIEM)&lt;/a&gt;. With CIEM, you would not only know which human and non-human identities can access which resource, but what permission they are using on a daily basis, and suggest policy modifications to enforce least privilege access.&lt;/p&gt;

&lt;p&gt;Let’s say we have a group of users who are part of a project. These users are responsible for uploading images into an ECR repository and running those containers in EC2 instances, as well as a number of auto-scaling actions. There’s no need for them to have all the permissions an administrator has, even though that approach may be the simplest to configure. Are they going to be deleting VPCs? That is not one of their tasks. Getting rid of excessive permissions is the first step to &lt;strong&gt;reducing collateral damage from credential theft&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finally CNAPP
&lt;/h2&gt;

&lt;p&gt;If you make it here, &lt;strong&gt;congratulations!&lt;/strong&gt; You are about to uncover the figure after connecting the dots.&lt;/p&gt;

&lt;p&gt;We were saying &lt;a href="https://sysdig.com/learn-cloud-native/cloud-security/cloud-native-application-protection-platform-cnapp-fundamentals/"&gt;CNAPP&lt;/a&gt; is the combination of different use cases that fall into the CWPP, CSPM, and CIEM categories, but let’s go to the source:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“Cloud-native application protection platform (CNAPP) provides more than CWPP-CSPM convergence: There are two important drivers for CNAPP. Firstly, CWPP vendors are looking to posture to provide workload context. Secondly, CSPMs are challenged to provide more and more visibility while “drilling down” into the workload. CNAPP integrates CSPM and CWPP to offer both, and potentially augments them with additional cloud security capabilities.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gartner, Inc., How to Protect Your Clouds with CSPM, CWPP, CNAPP, and CASB, 2021, Richard Bartley, May 6, 2021&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/CNAPP-cloud-05.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zxRea-Ve--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/CNAPP-cloud-05.png" alt="DIAGRAM CNAPP, CWPP, CSPM and CIEM" width="880" height="509"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We hope CNAPP and the rest of the terms make more sense now than when you started reading the article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;CNAPP solutions will promote collaboration between teams (SecDevOps, DevOps, and cloud security operations) by incorporating common workflows, data correlations, meaningful insights, and remediation that’d reduce friction between the personas.&lt;/p&gt;

&lt;p&gt;True CNAPP solutions will provide interrelationships between the different insights of the use cases. It’s totally useless to have a nice UI that provides vulnerability scanning if you don’t enrich it with the cloud context of where those images are stored/running. We are not talking about isolated tools put together to call it a day.&lt;/p&gt;

</description>
      <category>gartner</category>
      <category>cnapp</category>
      <category>compliance</category>
      <category>devops</category>
    </item>
    <item>
      <title>Introduction to Adversarial Machine Learning</title>
      <dc:creator>Miguel</dc:creator>
      <pubDate>Thu, 09 Dec 2021 13:59:03 +0000</pubDate>
      <link>https://dev.to/miguel000/introduction-to-adversarial-machine-learning-500p</link>
      <guid>https://dev.to/miguel000/introduction-to-adversarial-machine-learning-500p</guid>
      <description>&lt;p&gt;&lt;strong&gt;Adversarial machine learning&lt;/strong&gt; is concerned with the design of ML algorithms that can resist security challenges, the study of the capabilities of attackers, and the understanding of attack consequences.&lt;/p&gt;

&lt;p&gt;Adversarial Machine Learning states that there are &lt;a href="https://nvlpubs.nist.gov/nistpubs/ir/2019/NIST.IR.8269-draft.pdf" rel="noopener noreferrer"&gt;four types of attacks&lt;/a&gt; that ML models can suffer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjiep%2Fadversarial-machine-learning%2Fraw%2Fmain%2Fdocs%2Fen%2Ftaxonomy-v2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjiep%2Fadversarial-machine-learning%2Fraw%2Fmain%2Fdocs%2Fen%2Ftaxonomy-v2.png" alt="Taxonomy"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Extraction attacks
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjiep%2Fadversarial-machine-learning%2Fraw%2Fmain%2Fdocs%2Fen%2FExtraction.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjiep%2Fadversarial-machine-learning%2Fraw%2Fmain%2Fdocs%2Fen%2FExtraction.png" alt="Extraction attacks"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a model &lt;strong&gt;extraction attack&lt;/strong&gt;, an adversary steals a copy of a remotely deployed machine learning model, given oracle prediction access.&lt;/p&gt;

&lt;p&gt;It is produced by making requests to the target model with inputs to extract as much information as possible and with the set of inputs and outputs train a model called substitute model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extract model is hard&lt;/strong&gt;, the attacker needs a huge compute capacity to re-training the new model with accuracy and fidelity, and substitute model is equivalen to training a model from the ground up.&lt;/p&gt;

&lt;h3&gt;
  
  
   Defenses
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Limit the output information when the model classifies a given input.&lt;/li&gt;
&lt;li&gt;Differential Privacy.&lt;/li&gt;
&lt;li&gt;Use &lt;em&gt;ensembles&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Proxy between end-user and model like &lt;a href="https://arxiv.org/abs/1805.02628" rel="noopener noreferrer"&gt;PRADA&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Limit the number of requests.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Inference attacks
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjiep%2Fadversarial-machine-learning%2Fraw%2Fmain%2Fdocs%2Fen%2FInference.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjiep%2Fadversarial-machine-learning%2Fraw%2Fmain%2Fdocs%2Fen%2FInference.png" alt="Inference attack"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inference attack aim to reverse the information flow of a machine learning model. They allow an adversary to have knowledge of the model that was not explicitly intended to be shared.&lt;/p&gt;

&lt;p&gt;Inference attacks pose severe privacy and security threats to individuals and systems. They are successful because private data are statistically correlated with public data, and ML classifiers can capture such statistical correlations. &lt;/p&gt;

&lt;p&gt;Includes three types of attacks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Membership Inference Attack (MIA).&lt;/li&gt;
&lt;li&gt;Property Inference Attack (PIA).&lt;/li&gt;
&lt;li&gt;Recovery training data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
   Defenses
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use advanced cryptography.

&lt;ul&gt;
&lt;li&gt;Differential cryptography.&lt;/li&gt;
&lt;li&gt;Homomorphic cryptography.&lt;/li&gt;
&lt;li&gt;Secure Multi-party Computation.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Techniques such as Dropout.&lt;/li&gt;

&lt;li&gt;Model compression.&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
   Poisoning attacks
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjiep%2Fadversarial-machine-learning%2Fraw%2Fmain%2Fdocs%2Fen%2FPoisoning.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjiep%2Fadversarial-machine-learning%2Fraw%2Fmain%2Fdocs%2Fen%2FPoisoning.png" alt="Poisoning attacks"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This technique involves an &lt;strong&gt;attacker inserting corrupt data&lt;/strong&gt; in the training dataset to compromise a target machine learning model during training. &lt;/p&gt;

&lt;p&gt;Some data &lt;strong&gt;poisoning techniques&lt;/strong&gt; aim to trigger a specific behavior in a computer vision system when it faces a specific pattern of pixels at inference time. Other data poisoning techniques aim to reduce the accuracy of a machine learning model on one or more output classes. &lt;/p&gt;

&lt;p&gt;This attack is difficult to detect when performed on training data, since the attack can propagate between different models using the same data.&lt;/p&gt;

&lt;p&gt;The adversary seeks to destroy the availability of the model by modifying the decision boundary and, as a result, producing incorrect predictions.&lt;/p&gt;

&lt;p&gt;Finally, the attacker could create a &lt;strong&gt;backdoor in a model&lt;/strong&gt;.  The model behaves correctly (returning the desired predictions) in most cases, except for certain inputs specially created by the adversary that produce undesired results. The &lt;strong&gt;adversary can manipulate&lt;/strong&gt; the results of the predictions and launch future attacks. &lt;/p&gt;

&lt;h3&gt;
  
  
   Defenses
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Protect the integrity of training data.&lt;/li&gt;
&lt;li&gt;Protect the algorithms, use robust methods to train models.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
   Evasion attacks
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjiep%2Fadversarial-machine-learning%2Fraw%2Fmain%2Fdocs%2Fen%2FEvasion.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjiep%2Fadversarial-machine-learning%2Fraw%2Fmain%2Fdocs%2Fen%2FEvasion.png" alt="Evasion attacks"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An &lt;strong&gt;adversary inserts a small perturbation&lt;/strong&gt; (in the form of noise) into the input of a machine learning model to make it &lt;strong&gt;classify incorrectly&lt;/strong&gt; (example adversary).&lt;/p&gt;

&lt;p&gt;They are similar to poisoning attacks, but their main difference is that evasion attacks try to exploit weaknesses of the model in the inference phase, not in the training.&lt;/p&gt;

&lt;p&gt;Attacker’s knowledge of the target system is important. The more they know about your model and how its built — the easier it is for them to mount an attack on it.&lt;/p&gt;

&lt;p&gt;An evasion attack happens when the network is fed an “adversarial example” — a carefully perturbed input that looks and feels exactly the same as its &lt;strong&gt;untampered copy to a human&lt;/strong&gt; — but that completely &lt;strong&gt;throws off the classifier&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
   Defenses
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Training with adversarial examples which robust the model.&lt;/li&gt;
&lt;li&gt;Transform the input to the model (Input sanitization).&lt;/li&gt;
&lt;li&gt;Gradient regularization.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tools
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Adversarial Robustness Toolbox (ART)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/Trusted-AI/adversarial-robustness-toolbox" rel="noopener noreferrer"&gt;Adversarial Robustness Toolbox (ART)&lt;/a&gt; is a Python library for Machine Learning Security. ART provides tools that enable developers and researchers to defend and evaluate Machine Learning models and applications against the adversarial threats of &lt;strong&gt;Evasion&lt;/strong&gt;, &lt;strong&gt;Poisoning&lt;/strong&gt;, &lt;strong&gt;Extraction&lt;/strong&gt;, and &lt;strong&gt;Inference&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjiep%2Fadversarial-machine-learning%2Fraw%2Fmain%2Fdocs%2Fen%2Fblue-red-art.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjiep%2Fadversarial-machine-learning%2Fraw%2Fmain%2Fdocs%2Fen%2Fblue-red-art.png" alt="ART"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ART supports all popular machine learning frameworks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TensorFlow&lt;/li&gt;
&lt;li&gt;Keras&lt;/li&gt;
&lt;li&gt;PyTorch&lt;/li&gt;
&lt;li&gt;scikit-learn&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All data types: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Images&lt;/li&gt;
&lt;li&gt;Tables&lt;/li&gt;
&lt;li&gt;Audio&lt;/li&gt;
&lt;li&gt;Video&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And machine learning tasks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Classification&lt;/li&gt;
&lt;li&gt;Object detection&lt;/li&gt;
&lt;li&gt;Speech recognition&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;pip installation&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install adversarial-robustness-toolbox&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Attack example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from art.attacks.evasion import FastGradientMethod
attack_fgm = FastGradientMethod(estimator = classifier, eps = 0.2)
x_test_fgm = attack_fgm.generate(x=x_test)
predictions_test = classifier.predict(x_test_fgm)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Defense example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from art.defences.trainer import AdversarialTrainer
model.compile(loss=keras.losses.categorical_crossentropy, optimizer=tf.keras.optimizers.Adam(lr=0.01), metrics=["accuracy"])
defence = AdversarialTrainer(classifier=classifier, attacks=attack_fgm, ratio=0.6)
(x_train, y_train), (x_test, y_test), min_pixel_value, max_pixel_value = load_mnist()
defence.fit(x=x_train, y=y_train, nb_epochs=3)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
   Counterfit
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/Azure/counterfit" rel="noopener noreferrer"&gt;Counterfit&lt;/a&gt; is a command-line tool and generic automation layer for assessing the security of machine learning systems.&lt;/p&gt;

&lt;p&gt;Developed for security audits on ML models. Implements black box evasion algorithms and based on ART and TextAttack.&lt;/p&gt;

&lt;p&gt;Command list&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---------------------------------------------------
Microsoft
                          __            _____ __
  _________  __  ______  / /____  _____/ __(_) /_
 / ___/ __ \/ / / / __ \/ __/ _ \/ ___/ /_/ / __/
/ /__/ /_/ / /_/ / / / / /_/  __/ /  / __/ / /
\___/\____/\__,_/_/ /_/\__/\___/_/  /_/ /_/\__/

                                        #ATML

---------------------------------------------------

list targets

list frameworks

load &amp;lt;framework&amp;gt; 

list attacks

interact &amp;lt;target&amp;gt;

predict -i &amp;lt;ind&amp;gt;

use &amp;lt;attack&amp;gt;

run

scan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final words
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;"If you use machine learning, there is the risk for exposure, even though the threat does not currently exist in your space."&lt;/em&gt; and &lt;em&gt;"The gap between machine learning and security is definitely there."&lt;/em&gt; by &lt;a href="https://www.usenix.org/conference/enigma2021/presentation/anderson" rel="noopener noreferrer"&gt;Hyrum Anderson, Microsoft&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
   References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/mitre/advmlthreatmatrix/blob/master/pages/adversarial-ml-threat-matrix.md#adversarial-ml-threat-matrix" rel="noopener noreferrer"&gt;Towards Security Threats of DL Systems&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/mitre/advmlthreatmatrix/blob/master/pages/adversarial-ml-threat-matrix.md#adversarial-ml-threat-matrix" rel="noopener noreferrer"&gt;Adversarial Matrix Mitre&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://venturebeat.com/2021/04/21/adversarial-machine-learning-underrated-threat-data-poisoning/" rel="noopener noreferrer"&gt;Poisoning attacks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://towardsdatascience.com/evasion-attacks-on-machine-learning-or-adversarial-examples-12f2283e06a1" rel="noopener noreferrer"&gt;Evasion attacks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Thanks
&lt;/h3&gt;

&lt;p&gt;Special thanks to &lt;a href="https://www.linkedin.com/in/jos%C3%A9-ignacio-escribano-pablos/" rel="noopener noreferrer"&gt;@jiep&lt;/a&gt; as a co-writer this article.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>beginners</category>
      <category>security</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>GCP security best practices</title>
      <dc:creator>Miguel</dc:creator>
      <pubDate>Mon, 29 Nov 2021 18:22:50 +0000</pubDate>
      <link>https://dev.to/sysdig/gcp-security-best-practices-566f</link>
      <guid>https://dev.to/sysdig/gcp-security-best-practices-566f</guid>
      <description>&lt;p&gt;You’ve got a problem to solve and turned to Google Cloud Platform and follow &lt;strong&gt;GCP security best practices&lt;/strong&gt; to build and host your solution. You create your account and are all set to brew some coffee and sit down at your workstation to architect, code, build, and deploy. Except… you aren’t.&lt;/p&gt;

&lt;p&gt;There are many knobs you must tweak and practices to put into action if you want your &lt;strong&gt;solution&lt;/strong&gt; to be &lt;strong&gt;operative, secure, reliable, performant, and cost effective&lt;/strong&gt;. First things first, the best time to do that is now – right from the beginning, before you start to design and engineer.&lt;/p&gt;

&lt;h2&gt;
  
  
  GCP shared responsibility model
&lt;/h2&gt;

&lt;p&gt;The scope of Google Cloud products and services ranges from conventional &lt;a href="https://cloud.google.com/learn/what-is-iaas"&gt;Infrastructure as a Service&lt;/a&gt; (IaaS) to Platform as a Service (PaaS) and &lt;a href="https://cloud.google.com/marketplace/docs/partners/integrated-saas"&gt;Software as a Service&lt;/a&gt; (SaaS). As shown in the figure, the traditional boundaries of responsibility between users and cloud providers change based on the service they choose.&lt;/p&gt;

&lt;p&gt;At the very least, as part of their &lt;strong&gt;common responsibility for security&lt;/strong&gt;, public cloud providers need to be able to provide you with a solid and secure foundation. Also, providers need to empower you to understand and implement your own parts of the shared responsibility model.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/GCP-security-Best-practices-02.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--231F7Tal--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/GCP-security-Best-practices-02.png" alt="Shared responsibility model for On-prem, Iaas, Paas and saas." width="880" height="557"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Initial setup GCP security best practices
&lt;/h2&gt;

&lt;p&gt;First, a word of caution: &lt;strong&gt;Never use a non-corporate account.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead, use a fully managed corporate Google account to improve visibility, auditing, and control of access to Cloud Platform resources. &lt;strong&gt;Don’t use email accounts outside of your organization&lt;/strong&gt;, such as personal accounts, for business purposes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cloud.google.com/identity"&gt;Cloud Identity&lt;/a&gt; is a stand-alone Identity-as-a-Service (IDaaS) that gives Google Cloud users access to many of the identity management features that &lt;a href="https://workspace.google.com/"&gt;Google Workspace&lt;/a&gt; provides. It is a suite of secure cloud-native collaboration and productivity applications from Google. Through the Cloud Identity management layer, you can enable or disable access to various Google solutions for members of your organization, including Google Cloud Platform (GCP).&lt;/p&gt;

&lt;p&gt;Signing up for Cloud Identity also creates an organizational node for your domain. This helps you map your corporate structure and controls to Google Cloud resources through the Google Cloud resource hierarchy.&lt;/p&gt;

&lt;p&gt;Now, &lt;strong&gt;activating Multi-Factor Authentication (MFA) is the most important thing you want to do&lt;/strong&gt;. Do this for every user account you create in your system if you want to have a security-first mindset, especially crucial for administrators. MFA, along with strong passwords, are the most effective way to secure user’s accounts against improper access.&lt;/p&gt;

&lt;p&gt;Now that you are set, let’s dig into the &lt;strong&gt;GCP security best practices&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Identity and Access Management (IAM)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://cloud.google.com/iam"&gt;GCP Identity and Access Management (IAM)&lt;/a&gt; helps enforce least privilege access control to your cloud resources. You can use IAM to restrict who is authenticated (signed in) and authorized (has permissions) to use resources.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Ensure that MFA is enabled for all user accounts
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Multi-factor authentication&lt;/strong&gt; requires more than one mechanism to authenticate a user. This secures user logins from attackers exploiting stolen or weak credentials. By default, multi-factor authentication is not set.&lt;/p&gt;

&lt;p&gt;Make sure that for each Google Cloud Platform project, folder, or organization, multi-factor authentication for each account is set and, if not, &lt;a href="https://support.google.com/accounts/answer/185839"&gt;set it up&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Ensure Security Key enforcement for admin accounts
&lt;/h3&gt;

&lt;p&gt;GCP users with Organization Administrator roles have the highest level of privilege in the organization.&lt;/p&gt;

&lt;p&gt;These accounts should be protected with the strongest form of two-factor authentication: &lt;strong&gt;Security Key Enforcement&lt;/strong&gt;. Ensure that admins use Security Keys to log in instead of weaker second factors, like SMS or &lt;a href="https://pages.nist.gov/800-63-3/sp800-63b.html#singlefactorOTP"&gt;one-time passwords&lt;/a&gt; (OTP). Security Keys are actual &lt;strong&gt;physical keys&lt;/strong&gt; used to access Google Organization Administrator Accounts. They send an encrypted signature rather than a code, ensuring that logins cannot be phished.&lt;/p&gt;

&lt;p&gt;Identify users with &lt;em&gt;Organization Administrator&lt;/em&gt; privileges:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud organizations get-iam-policy ORGANIZATION\_ID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look for members granted the role &lt;em&gt;”roles/resourcemanager.organizationAdmin”&lt;/em&gt; and then manually verify that &lt;strong&gt;Security Key Enforcement&lt;/strong&gt; has been enabled for each account. If not enabled, take it seriously and &lt;a href="https://cloud.google.com/titan-security-key"&gt;enable it immediately&lt;/a&gt;. By default, Security Key Enforcement is not enabled for Organization Administrators.&lt;/p&gt;

&lt;p&gt;If an organization administrator loses access to their security key, the user may not be able to access their account. For this reason, it is important to &lt;a href="https://workspace.google.com/learn-more/key_for_working_smarter_faster_and_more_securely.html"&gt;configure backup security keys&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
   Other GCP security IAM best practices include:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;  Service accounts should not have Admin privileges.&lt;/li&gt;
&lt;li&gt;  IAM users should not be assigned the &lt;strong&gt;Service Account User&lt;/strong&gt; or &lt;strong&gt;Service Account Token Creator&lt;/strong&gt; roles at project level.&lt;/li&gt;
&lt;li&gt;  User-managed / external keys for service accounts should be rotated every 90 days or less.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Separation of duties&lt;/strong&gt; should be enforced while assigning service account related roles to users.&lt;/li&gt;
&lt;li&gt;  Separation of duties should be enforced while assigning KMS related roles to users.&lt;/li&gt;
&lt;li&gt;  API keys should not be created for a project.&lt;/li&gt;
&lt;li&gt;  API keys should be restricted to use by only specified Hosts and Apps.&lt;/li&gt;
&lt;li&gt;  API keys should be restricted to only APIs that the application needs access to.&lt;/li&gt;
&lt;li&gt;  API keys should be rotated every 90 days or less.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Management Service (KMS)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://cloud.google.com/security-key-management"&gt;GCP Cloud Key Management Service&lt;/a&gt; (KMS) is a cloud-hosted key management service that allows you to manage symmetric and asymmetric encryption keys for your cloud services in the same way as onprem. It lets you create, use, rotate, and destroy AES 256, RSA 2048, RSA 3072, RSA 4096, EC P256, and EC P384 encryption keys.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Check for anonymously or publicly accessible Cloud KMS keys
&lt;/h3&gt;

&lt;p&gt;Anyone can access the dataset by granting permissions to &lt;code&gt;allUsers&lt;/code&gt; or &lt;code&gt;allAuthenticatedUsers&lt;/code&gt;. Such access may not be desirable if sensitive data is stored in that location.&lt;/p&gt;

&lt;p&gt;In this case, make sure that &lt;strong&gt;anonymous and/or public access&lt;/strong&gt; to a Cloud KMS encryption key &lt;strong&gt;is not allowed&lt;/strong&gt;. By default, Cloud KMS does not allow access to &lt;code&gt;allUsers&lt;/code&gt; or &lt;code&gt;allAuthenticatedUsers&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;List all Cloud KMS keys:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud kms keys list --keyring=KEY\_RING\_NAME --location=global --format=json | jq '.\[\].name'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remove IAM policy binding for a KMS key to remove access to &lt;code&gt;allUsers&lt;/code&gt; and &lt;code&gt;allAuthenticatedUsers&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud kms keys remove-iam-policy-binding KEY\_NAME --keyring=KEY\_RING\_NAME --location=global --member=allUsers --role=ROLE
gcloud kms keys remove-iam-policy-binding KEY\_NAME --keyring=KEY\_RING\_NAME --location=global --member=allAuthenticatedUsers --role=ROLE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The following is a &lt;a href="https://cloudcustodian.io/docs/gcp/examples/kms-cryptokey.html"&gt;Cloud Custodian rule&lt;/a&gt; for detecting the existence of anonymously or publicly accessible Cloud KMS keys:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\- name: anonymously-or-publicly-accessible-cloud-kms-keys
  description: |
    It is recommended that the IAM policy on Cloud KMS cryptokeys should
    restrict anonymous and/or public access.
  resource: gcp.kms-cryptokey
  filters:
    - type: iam-policy
      key: "bindings\[\*\].members\[\]"
      op: intersect
      value: \["allUsers", "allAuthenticatedUsers"\]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Cloud Storage
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://cloud.google.com/storage"&gt;Google Cloud Storage&lt;/a&gt; lets you store any amount of data in namespaces called &lt;em&gt;“buckets&lt;/em&gt;.&lt;em&gt;”&lt;/em&gt; These buckets are an appealing target for any attacker who wants to get hold of your data, so you must take great care in securing them.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Ensure that Cloud Storage buckets are not anonymously or publicly accessible
&lt;/h3&gt;

&lt;p&gt;Allowing anonymous or public access gives everyone permission to access bucket content. Such access may not be desirable if you are storing sensitive data. Therefore, make sure that &lt;strong&gt;anonymous or public access to the bucket is not allowed&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;List all buckets in a project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gsutil ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Check the IAM Policy&lt;/strong&gt; for each bucket returned from the above command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gsutil iam get gs://BUCKET\_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No role should contain &lt;code&gt;allUsers&lt;/code&gt; or &lt;code&gt;allAuthenticatedUsers&lt;/code&gt; as a member. If that’s not the case, you’ll want to remove them with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gsutil iam ch -d allUsers gs://BUCKET\_NAME
gsutil iam ch -d allAuthenticatedUsers gs://BUCKET\_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, you might want to prevent Storage buckets from becoming publicly accessible by &lt;a href="https://console.cloud.google.com/projectselector/iam-admin/orgpolicies/iam-allowedPolicyMemberDomains?supportedpurview=project,folder,organizationId&amp;amp;orgonly=true"&gt;setting up the Domain restricted sharing organization policy&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compute Engine
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://cloud.google.com/compute"&gt;Compunte Engine&lt;/a&gt; provides security and customizable compute service that lets you create and run virtual machines on Google’s infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Ensure VM disks for critical VMs are encrypted with Customer-Supplied Encryption Keys (CSEK)
&lt;/h3&gt;

&lt;p&gt;By default, the Compute Engine service &lt;strong&gt;encrypts all data at rest&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Cloud services manage this type of encryption without any additional action from users or applications. However, if you want full control over instance disk encryption, you can provide your own encryption key.&lt;/p&gt;

&lt;p&gt;These custom keys, also known as &lt;a href="https://cloud.google.com/security/encryption/customer-supplied-encryption-keys"&gt;Customer-Supplied Encryption Keys&lt;/a&gt; (CSEKs), are used by Google Compute Engine to protect the Google-generated keys used to encrypt and decrypt instance data. The Compute Engine service does not store CSEK on the server and cannot access protected data unless you specify the required key.&lt;/p&gt;

&lt;p&gt;At the very least, &lt;strong&gt;business critical VMs should have VM disks encrypted with CSEK&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;By default, VM disks are encrypted with Google-managed keys. They are not encrypted with Customer-Supplied Encryption Keys.&lt;/p&gt;

&lt;p&gt;Currently, there is no way to update the encryption of an existing disk, so you should create a new disk with &lt;code&gt;Encryption&lt;/code&gt; set to &lt;code&gt;Customer supplied&lt;/code&gt;. A word of caution is necessary here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚠️ If you lose your encryption key, you will not be able to recover the data&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://cloud.google.com/compute/docs/gcloud-compute"&gt;gcloud compute tool&lt;/a&gt;, encrypt a disk using the &lt;code&gt;--csek-key-file&lt;/code&gt; flag during instance creation. If you are using an RSA-wrapped key, use the gcloud beta component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud beta compute instances create INSTANCE\_NAME --csek-key-file=key-file.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To encrypt a standalone persistent disk use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud beta compute disks create DISK\_NAME --csek-key-file=key-file.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is your duty to generate and manage your key. You must provide a key that is a 256-bit string encoded in RFC 4648 standard base64 to the Compute Engine. A sample &lt;code&gt;key-file.json&lt;/code&gt; looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\[
  {
    "uri": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-
central1-a/disks/example-disk",
    "key": "acXTX3rxrKAFTF0tYVLvydU1riRZTvUNC4g5I11NY-c=",
    "key-type": "raw"
  },
  {
    "uri":
"https://www.googleapis.com/compute/v1/projects/myproject/global/snapshots/my
-private-snapshot",
    "key":
"ieCx/NcW06PcT7Ep1X6LUTc/hLvUDYyzSZPPVCVPTVEohpeHASqC8uw5TzyO9U+Fka9JFHz0mBib
XUInrC/jEk014kCK/NPjYgEMOyssZ4ZINPKxlUh2zn1bV+MCaTICrdmuSBTWlUUiFoDD6PYznLwh8
ZNdaheCeZ8ewEXgFQ8V+sDroLaN3Xs3MDTXQEMMoNUXMCZEIpg9Vtp9x2oeQ5lAbtt7bYAAHf5l+g
JWw3sUfs0/Glw5fpdjT8Uggrr+RMZezGrltJEF293rvTIjWOEB3z5OHyHwQkvdrPDFcTqsLfh+8Hr
8g+mf+7zVPEC8nEbqpdl3GPv3A7AwpFp7MA=="
    "key-type": "rsa-encrypted"
  }
\]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
   Other GCP security best practices for Compute Engine include:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;  Ensure that instances are not configured to use the default service account.&lt;/li&gt;
&lt;li&gt;  Ensure that instances are not configured to use the default service account with full access to all Cloud APIs.&lt;/li&gt;
&lt;li&gt;  Ensure oslogin is enabled for a Project.&lt;/li&gt;
&lt;li&gt;  Ensure that IP forwarding is not enabled on Instances.&lt;/li&gt;
&lt;li&gt;  Ensure Compute instances are launched with Shielded VM enabled.&lt;/li&gt;
&lt;li&gt;  Ensure that Compute instances do not have public IP addresses.&lt;/li&gt;
&lt;li&gt;  Ensure that App Engine applications enforce HTTPS connections.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Google Kubernetes Engine Service (GKE)
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://cloud.google.com/kubernetes-engine"&gt;Google Kubernetes Engine&lt;/a&gt; (GKE) provides a managed environment for deploying, managing, and scaling containerized applications using the Google infrastructure. A GKE environment consists of multiple machines (specifically, Compute Engine instances) grouped together to form a cluster.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Enable application-layer secrets encryption for GKE clusters
&lt;/h3&gt;

&lt;p&gt;Application-layer secret encryption provides an &lt;strong&gt;additional layer of security&lt;/strong&gt; for sensitive data, such as Kubernetes secrets stored on &lt;code&gt;etcd&lt;/code&gt;. This feature allows you to use Cloud KMS managed encryption keys to encrypt data at the application layer and protect it from attackers accessing offline copies of &lt;code&gt;etcd&lt;/code&gt;. Enabling application-layer secret encryption in a GKE cluster is considered a security best practice &lt;strong&gt;for applications that store sensitive data&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Create a key ring to store the CMK:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud kms keyrings create KEY\_RING\_NAME --location=REGION --project=PROJECT\_NAME --format="table(name)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, create a new Cloud KMS Customer-Managed Key (CMK) within the KMS key ring created at the previous step:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud kms keys create KEY\_NAME --location=REGION --keyring=KEY\_RING\_NAME --purpose=encryption --protection-level=software --rotation-period=90d --format="table(name)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And lastly, assign the Cloud KMS &lt;em&gt;“CryptoKey Encrypter/Decrypter”&lt;/em&gt; role to the appropriate service account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud projects add-iam-policy-binding PROJECT\_ID --member=serviceAccount:service-PROJECT\_NUMBER@container-engine-robot.iam.gserviceaccount.com --role=roles/cloudkms.cryptoKeyEncrypterDecrypter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The final step is to enable application-layer secrets encryption for the selected cluster, using the Cloud KMS Customer-Managed Key (CMK) created in the previous steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud container clusters update CLUSTER --region=REGION --project=PROJECT\_NAME --database-encryption-key=projects/PROJECT\_NAME/locations/REGION/keyRings/KEY\_RING\_NAME/cryptoKeys/KEY\_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7. Enable GKE cluster node encryption with customer-managed keys
&lt;/h3&gt;

&lt;p&gt;To give you more control over the GKE data encryption / decryption process, make sure your Google Kubernetes Engine (GKE) cluster node is &lt;strong&gt;encrypted with a customer-managed key&lt;/strong&gt; (CMK). You can use the Cloud Key Management Service (Cloud KMS) to create and manage your own customer-managed keys (CMKs). Cloud KMS provides secure and efficient cryptographic key management, controlled key rotation, and revocation mechanisms.&lt;/p&gt;

&lt;p&gt;At this point, you should already have a key ring where you store the CMKs, as well as customer-managed keys. You will use them here too.&lt;/p&gt;

&lt;p&gt;To enable GKE cluster node encryption, &lt;strong&gt;you will need to re-create the node pool&lt;/strong&gt;. For this, use the name of the cluster node pool that you want to re-create as an identifier parameter and custom output filtering to describe the configuration information available for the selected node pool:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud container node-pools describe NODE\_POOL --cluster=CLUSTER\_NAME --region=REGION --format=json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, using the information returned in the previous step, create a new Google Cloud GKE cluster node pool, encrypted with your customer-managed key (CMK):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud beta container node-pools create NODE\_POOL --cluster=CLUSTER\_NAME --region=REGION --disk-type=pd-standard --disk-size=150 --boot-disk-kms-key=projects/PROJECT/locations/REGION/keyRings/KEY\_RING\_NAME/cryptoKeys/KEY\_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once your new cluster node pool is working properly, you can delete the original node pool to stop adding invoices to your Google Cloud account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚠️ Take good care to delete the old pool and not the new one!&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud container node-pools delete NODE\_POOL --cluster=CLUSTER\_NAME --region=REGION
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8. Restrict network access to GKE clusters
&lt;/h3&gt;

&lt;p&gt;To limit your exposure to the Internet, make sure your Google Kubernetes Engine (GKE) cluster is configured with a master authorized network. Master authorized networks allow you to &lt;strong&gt;whitelist specific IP addresses and/or IP address ranges to access cluster master endpoints&lt;/strong&gt; using HTTPS.&lt;/p&gt;

&lt;p&gt;Adding a master authorized network can provide &lt;strong&gt;network-level protection&lt;/strong&gt; and additional security benefits to your GKE cluster. Authorized networks allow access to a particular set of trusted IP addresses, such as those originating from a secure network. This helps protect access to the GKE cluster if the cluster’s authentication or authorization mechanism is vulnerable.&lt;/p&gt;

&lt;p&gt;Add authorized networks to the selected GKE cluster to grant access to the cluster master from the trusted IP addresses / IP ranges that you define:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud container clusters update CLUSTER\_NAME --zone=REGION --enable-master-authorized-networks --master-authorized-networks=CIDR\_1,CIDR\_2,...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the previous command, you can specify multiple CIDRs (up to 50) separated by a comma.&lt;/p&gt;

&lt;p&gt;The above are the most important best practices for GKE, since not adhering to them poses a high risk, but there are other security best practices you might want to adhere to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Enable auto-repair for GKE cluster nodes.&lt;/li&gt;
&lt;li&gt;  Enable auto-upgrade for GKE cluster nodes.&lt;/li&gt;
&lt;li&gt;  Enable integrity monitoring for GKE cluster nodes.&lt;/li&gt;
&lt;li&gt;  Enable secure boot for GKE cluster nodes.&lt;/li&gt;
&lt;li&gt;  Use shielded GKE cluster nodes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cloud Logging
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://cloud.google.com/logging"&gt;Cloud Logging&lt;/a&gt; is a fully managed service that allows you to store, search, analyze, monitor, and alert log data and events from Google Cloud and Amazon Web Services. You can collect log data from over 150 popular application components, onprem systems, and hybrid cloud systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. Ensure that Cloud Audit Logging is configured properly across all services and all users from a project
&lt;/h3&gt;

&lt;p&gt;Cloud Audit Logging maintains two audit logs for each project, folder, and organization:&lt;/p&gt;

&lt;p&gt;Admin Activity and Data Access. Admin Activity logs contain log entries for API calls or other administrative actions that modify the configuration or metadata of resources. These are enabled for all services and cannot be configured. On the other hand, &lt;strong&gt;Data Access audit logs&lt;/strong&gt; record API calls that create, modify, or read user-provided data. These are disabled by default and &lt;strong&gt;should be enabled&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is recommended to have an effective default audit config configured in such a way that you can log user activity tracking, as well as changes (tampering) to user data. Logs should be captured for all users.&lt;/p&gt;

&lt;p&gt;For this, you will need to edit the project’s policy. First, download it as a &lt;code&gt;yaml&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud projects get-iam-policy PROJECT\_ID &amp;gt; /tmp/project\_policy.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, edit &lt;code&gt;/tmp/project_policy.yaml&lt;/code&gt; adding or changing only the audit logs configuration to the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;auditConfigs:
- auditLogConfigs:
  - logType: DATA\_WRITE
  - logType: DATA\_READ
  service: allServices
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please note that &lt;code&gt;exemptedMembers&lt;/code&gt; is not set as audit logging should be enabled for all the users. Last, update the policy with the new changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud projects set-iam-policy PROJECT\_ID /tmp/project\_policy.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;⚠️ Enabling the Data Access audit logs might result in your project being charged for the additional logs usage.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  10. Enable logs router encryption with customer-managed keys
&lt;/h3&gt;

&lt;p&gt;Make sure your Google Cloud Logs Router data is encrypted with a customer-managed key (CMK) to give you &lt;strong&gt;complete control over the data encryption and decryption&lt;/strong&gt; process, as well as to meet your compliance requirements.&lt;/p&gt;

&lt;p&gt;You will want to add a policy, binding to the IAM policy of the CMK, to assign the Cloud KMS &lt;em&gt;“CryptoKey Encrypter/Decrypter”&lt;/em&gt; role to the necessary service account.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud kms keys add-iam-policy-binding KEY\_ID --keyring=KEY\_RING\_NAME --location=global --member=serviceAccount:PROJECT\_NUMBER@gcp-sa-logging.iam.gserviceaccount.com --role=roles/cloudkms.cryptoKeyEncrypterDecrypter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Cloud SQL
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://cloud.google.com/sql"&gt;Cloud SQL&lt;/a&gt; is a fully managed relational database service for MySQL, PostgreSQL, and SQL Server. Run the same relational databases you know with their rich extension collections, configuration flags and developer ecosystem, but without the hassle of self management.&lt;/p&gt;

&lt;h3&gt;
  
  
  11. Ensure that Cloud SQL database instances are not open to the world
&lt;/h3&gt;

&lt;p&gt;Only trusted / known required IPs should be whitelisted to connect in order to minimize the attack surface of the database server instance. The allowed networks must not have an IP / network configured to 0.0.0.0/0 that allows access to the instance from anywhere in the world. Note that allowed networks apply only to instances with public IPs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud sql instances patch INSTANCE_NAME --authorized-networks=IP_ADDR1,IP_ADDR2...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To prevent new SQL instances from being configured to accept incoming connections from any IP addresses, set up a Restrict Authorized Networks on Cloud SQL instances Organization Policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  BigQuery
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://cloud.google.com/bigquery"&gt;BigQuery&lt;/a&gt; is a serverless, highly-scalable, and cost-effective cloud data warehouse with an in-memory BI Engine and machine learning built in.&lt;/p&gt;

&lt;h3&gt;
  
  
  12. Ensure that BigQuery datasets are not anonymously or publicly accessible
&lt;/h3&gt;

&lt;p&gt;You don’t want to allow anonymous or public access in your BigQuery dataset’s IAM policies. Anyone can access the dataset by granting permissions to &lt;code&gt;allUsers&lt;/code&gt; or &lt;code&gt;allAuthenticatedUsers&lt;/code&gt;. &lt;strong&gt;Such access may not be desirable if sensitive data is stored&lt;/strong&gt; on the dataset. Therefore, make sure that anonymous and/or public access to the dataset is not allowed.&lt;/p&gt;

&lt;p&gt;To do this, you will need to edit the data set information. First you need to retrieve said information into your local filesystem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bq show --format=prettyjson PROJECT\_ID:DATASET\_NAME &amp;gt; dataset\_info.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, in the access section of &lt;code&gt;dataset_info.json&lt;/code&gt;, update the dataset information to remove all roles containing &lt;code&gt;allUsers&lt;/code&gt; or &lt;code&gt;allAuthenticatedUsers&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Finally, update the dataset:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bq update --source=dataset\_info.json PROJECT\_ID:DATASET\_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can prevent BigQuery dataset from becoming publicly accessible by &lt;a href="https://console.cloud.google.com/projectselector2/iam-admin/orgpolicies/iam-allowedPolicyMemberDomains"&gt;setting up the Domain restricted sharing organization policy&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compliance Standards &amp;amp; Benchmarks
&lt;/h2&gt;

&lt;p&gt;Setting up all the detection rules and maintaining your GCP environment to keep it secure is an ongoing effort that can take a big chunk of your time – even more so if you don’t have some kind of roadmap to guide you during this continuous work.&lt;/p&gt;

&lt;p&gt;You will be better off following the compliance standard(s) relevant to your industry, since they provide all the requirements needed to effectively secure your cloud environment.&lt;/p&gt;

&lt;p&gt;Because of the ongoing nature of securing your infrastructure and complying with a security standard, you might also want to recurrently run benchmarks, such as CIS Google Cloud Platform Foundation Benchmark, which will audit your system and report any unconformity it might find.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Jumping to the cloud opens a new world of possibilities, but it also requires learning a new set of &lt;strong&gt;Google Cloud Platform security best practices&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Each new cloud service you leverage has its own set of potential dangers you need to be aware of.&lt;/p&gt;

&lt;p&gt;Luckily, cloud native security tools like &lt;a href="http://falco.org/"&gt;Falco&lt;/a&gt; and &lt;a href="https://cloudcustodian.io/"&gt;Cloud Custodian&lt;/a&gt; can guide you through these &lt;strong&gt;Google Cloud Platform security best practices&lt;/strong&gt;, and help you meet your compliance requirements.&lt;/p&gt;

</description>
      <category>gcp</category>
      <category>cloud</category>
      <category>security</category>
      <category>devops</category>
    </item>
    <item>
      <title>Container security best practices: Comprehensive guide</title>
      <dc:creator>Miguel</dc:creator>
      <pubDate>Tue, 16 Nov 2021 13:49:32 +0000</pubDate>
      <link>https://dev.to/sysdig/container-security-best-practices-comprehensive-guide-1d2d</link>
      <guid>https://dev.to/sysdig/container-security-best-practices-comprehensive-guide-1d2d</guid>
      <description>&lt;p&gt;Sticking to &lt;a href="https://sysdig.com/learn-cloud-native/container-security/what-is-container-security/"&gt;container security&lt;/a&gt; best practices is critical for successfully delivering verified software, as well as preventing severe security breaches and its consequences.&lt;/p&gt;

&lt;p&gt;According to the &lt;a href="https://www.cncf.io/wp-content/uploads/2020/11/CNCF_Survey_Report_2020.pdf"&gt;2020 CNFC Survey&lt;/a&gt;, &lt;strong&gt;92 percent of companies are using containers in production&lt;/strong&gt;, a 300 percent increase since 2016. Thus, Kubernetes, Openshift, and other container technologies are present everywhere.&lt;/p&gt;

&lt;p&gt;But aren’t containers meant to be safe and isolated? Well, kind of.&lt;/p&gt;

&lt;p&gt;For example, an exploitable vulnerability inside a container, combined with exposed metadata and a wrong credentials configuration, &lt;strong&gt;can compromise your whole cloud infrastructure&lt;/strong&gt;. As described in our &lt;a href="https://sysdig.com/blog/lateral-movement-cloud-containers/"&gt;Cloud lateral movement post&lt;/a&gt;, a hacker can use this chain of exploits and wrong configurations to run crypto mining applications in your cloud account.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/learn-cloud-native/container-security/orchestration-containerized-architecture/"&gt;Containers were designed&lt;/a&gt; as a distribution mechanism for self-contained applications, allowing them to execute processes in an isolated environment. For isolation purposes, they employ a lightweight mechanism using kernel namespaces, removing the requirement of several additional layers in VMs, like a full operating system, CPU and hardware virtualization, etc.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;lack&lt;/strong&gt; of these additional abstraction layers, as well as tightly coupling with the kernel, operating system, and container runtime, make it &lt;strong&gt;easier&lt;/strong&gt; to use exploits to jump from inside the container to the outside and vice versa.&lt;/p&gt;

&lt;p&gt;Container security best practices don’t just include the delivered applications and the container image itself, but also the full component stack used for building, distributing, and specially executing the container.&lt;/p&gt;

&lt;p&gt;This includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The host or VM&lt;/li&gt;
&lt;li&gt;  The container runtime&lt;/li&gt;
&lt;li&gt;  Cluster technology&lt;/li&gt;
&lt;li&gt;  Cloud provider configuration&lt;/li&gt;
&lt;li&gt;  And more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Security can be applied at each of the different phases: development, distribution, execution, detection and response to threats.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_01.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lIUbeOxl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_01.png" alt="Diagram security container" width="880" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s dive into the interesting details, breaking down the general ideas into 18 concrete container security best practices that you can apply in your DevOps workflows.&lt;/p&gt;

&lt;h2&gt;
  
  
  A complex stack
&lt;/h2&gt;

&lt;p&gt;Containers’ success is often fueled by two really useful features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  They are &lt;strong&gt;a really convenient way to distribute and execute software&lt;/strong&gt;, as a self-contained executable image which includes all libraries and dependencies, while being much lighter than classical VM images.&lt;/li&gt;
&lt;li&gt;  They offer a &lt;strong&gt;good level of security and isolation&lt;/strong&gt; by using kernel namespaces to execute processes in their own “jail”, including mounts, PID, network, IPC, etc., and also resource limiting CPU usage and memory via kernel cgroups. Memory protection, permission enforcement, etc. are still provided via the standard kernel security mechanisms.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_02.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VtdpN8SZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_02.png" alt="VM vs Container" width="880" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The container security model might be enough in most cases, but for example, AWS adds additional security for their serverless solution. It does so by running containers inside &lt;a href="https://firecracker-microvm.github.io/"&gt;Firecracker&lt;/a&gt;, a micro virtual machine that adds another level of virtualization to prevent cross-customer breaches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does this mean containers are not safe?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can see it as a double-edged sword.&lt;/p&gt;

&lt;p&gt;An application running inside a container is no different than an application running directly in a machine, sharing a file-system and processes with many other applications. In a sense, they are just applications that could contain exploitable vulnerabilities.&lt;/p&gt;

&lt;p&gt;Running inside a container won’t prevent this, but will make it much harder to jump from the application exploit to the host system, or access data from other applications.&lt;/p&gt;

&lt;p&gt;On the other hand, containers depend on another set of kernel features, a container runtime, and usually a cluster or orchestrator that might be exploited too.&lt;/p&gt;

&lt;p&gt;So, &lt;strong&gt;we need to take the whole stack into account&lt;/strong&gt;, and we can apply container security best practices at the different phases of the container lifecycle. &lt;/p&gt;

&lt;p&gt;There will be cases like the serverless compute engine ECS Fargate, Google Cloud Run, etc., where some of these pieces are out of our control, so &lt;a href="https://sysdig.com/blog/ecs-fargate-threat-modeling/"&gt;we work on a shared responsibility model&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The &lt;strong&gt;provider&lt;/strong&gt; is responsible for keeping the base pieces working and secured&lt;/li&gt;
&lt;li&gt;  And &lt;strong&gt;you&lt;/strong&gt; can focus on the upper layers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_03.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JChrd-Be--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_03.png" alt="Shared Responsibility Model" width="880" height="557"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prevention: 8 steps for shift left security
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-security-best-practices_04.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lxeDLJPc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-security-best-practices_04.png" alt="Shift Left Security" width="880" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before your application inside a container is executed, there are several places where you can start applying different techniques to prevent threats from happening.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prevention&lt;/strong&gt; and applying security as early as possible is key and will save you a lot of trouble, time, and money with minimal effort if you apply some good practices during the development and distribution of the container images.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Integrate Code Scanning at the CI/CD Process
&lt;/h3&gt;

&lt;p&gt;Security scanning is the process of analyzing your software, configuration or infrastructure, and detecting potential issues or known vulnerabilities. Scanning can be done at different stages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Code&lt;/li&gt;
&lt;li&gt;  Dependencies&lt;/li&gt;
&lt;li&gt;  Infrastructure as code&lt;/li&gt;
&lt;li&gt;  Container Images&lt;/li&gt;
&lt;li&gt;  Hosts&lt;/li&gt;
&lt;li&gt;  Cloud configuration&lt;/li&gt;
&lt;li&gt;  … and more&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s focus on the first stage: &lt;strong&gt;code&lt;/strong&gt;. Before you ship the application or even build your application, you can &lt;a href="https://sysdig.com/learn-cloud-native/container-security/cicd-pipeline/"&gt;scan your code&lt;/a&gt; to detect bugs or potentially exploitable code (a new vulnerability).&lt;/p&gt;

&lt;p&gt;For application code, there are different SAST (Static Application Security Testing) tools like &lt;a href="https://github.com/SonarSource/sonarqube"&gt;sonarqube&lt;/a&gt;, which provide vulnerability scanners for different languages, &lt;a href="https://github.com/securego/gosec"&gt;gosec&lt;/a&gt; for analyzing go code and detecting issues based on rules, linters, etc.&lt;/p&gt;

&lt;p&gt;You can run them at the developer machine, but integrating code scanning tools at the CI/CD process can make sure that a minimum level of code quality is assured. For example, you can block pull requests by default if some checks are failing.&lt;/p&gt;

&lt;p&gt;A Github Action running gosec:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: "Security Scan"
on:
  push:
jobs:
  tests:
    runs-on: ubuntu-latest
    env:
      GO111MODULE: on
    steps:
      - name: Checkout Source
        uses: actions/checkout@v2
      - name: Run Gosec Security Scanner
        uses: securego/gosec@master
        with:
          args: ./...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the corresponding output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_05.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tcmf1-33--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_05.png" alt="Github Actions Output" width="880" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Reduce external vulnerabilities via dependency scanning
&lt;/h3&gt;

&lt;p&gt;Only very minimal and toy applications are free of third-party libraries or frameworks. But reusing code from external dependencies means you will be including bugs and vulnerabilities from these dependencies as part of your application. Dependency scanning should be included as a best practice in any application build process.&lt;/p&gt;

&lt;p&gt;Package management tools, like &lt;a href="https://docs.npmjs.com/auditing-package-dependencies-for-security-vulnerabilities"&gt;npm&lt;/a&gt;, &lt;a href="https://jeremylong.github.io/DependencyCheck/dependency-check-maven/"&gt;maven&lt;/a&gt;, go, etc., can match vulnerability databases with your application dependencies and provide useful warning.&lt;/p&gt;

&lt;p&gt;For example, enabling the dependency-check plugin in Maven requires just adding a plugin to the pom.xml:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;project&amp;gt;
    ...
    &amp;lt;build&amp;gt;
        ...
        &amp;lt;plugins&amp;gt;
            ...
            &amp;lt;plugin&amp;gt;
              &amp;lt;groupId&amp;gt;org.owasp&amp;lt;/groupId&amp;gt;
              &amp;lt;artifactId&amp;gt;dependency-check-maven&amp;lt;/artifactId&amp;gt;
              &amp;lt;version&amp;gt;6.2.2&amp;lt;/version&amp;gt;
              &amp;lt;executions&amp;gt;
                  &amp;lt;execution&amp;gt;
                      &amp;lt;goals&amp;gt;
                          &amp;lt;goal&amp;gt;check&amp;lt;/goal&amp;gt;
                      &amp;lt;/goals&amp;gt;
                  &amp;lt;/execution&amp;gt;
              &amp;lt;/executions&amp;gt;
            &amp;lt;/plugin&amp;gt;
            ...
        &amp;lt;/plugins&amp;gt;
        ...
    &amp;lt;/build&amp;gt;
    ...
&amp;lt;/project&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And every time maven is executed, it will generate a vulnerability report:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_06.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4s4faotu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_06.png" alt="Dependencies check" width="880" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Avoid introducing vulnerabilities through dependencies by updating them to newer versions with fixes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_07.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l4lhobTA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_07.png" alt="Dependences tree" width="880" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In some cases, this might not be possible because the fix is not available, or bumping the version would require a lot of refactoring due to breaking changes. Analyze the vulnerabilities revealed by dependency scanning to evaluate the impact and exploitability, and introduce additional measures like checks in your code or protection mechanisms to prevent the vulnerability from being exploited.&lt;/p&gt;

&lt;p&gt;Note that although it is possible to also scan dependencies later, once the application is built, dependency scanning will be less accurate as some metadata information is not available, and it might be impossible for statically linked applications like Go or Rust.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Use image scanning to analyze container images
&lt;/h3&gt;

&lt;p&gt;Once your application is built and packaged, it is common to copy it inside a container with a minimal set of libraries, dependent frameworks (like Python, Node, etc.), and configuration files. You can read our &lt;a href="https://sysdig.com/blog/dockerfile-best-practices/"&gt;Top 20 Dockerfile best practices&lt;/a&gt; to learn about the best practices focused in container building and runtime.&lt;/p&gt;

&lt;p&gt;Use an image scanner to analyze your container images. The &lt;a href="https://sysdig.com/learn-cloud-native/container-security/docker-vulnerability-scanning/"&gt;image scanning&lt;/a&gt; tool will discover vulnerabilities in the operating system packages (rpm, dpkg, apk, etc.) provided by the container image base distribution. It will also reveal vulnerabilities in package dependencies for Java, Node, Python, and others, even if you didn’t apply dependency scanning in the previous stages.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_08.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EX74yCQe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_08.png" alt="Image Scanning Schema" width="880" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Image Scanning is easy to automate and enforce. It can be &lt;a href="https://sysdiglabs.github.io/secure-inline-scan-examples/"&gt;included as part of your CI/CD pipelines&lt;/a&gt;, &lt;a href="https://sysdig.com/blog/harbor-registry-scanning/"&gt;triggered when new images are pushed to a registry&lt;/a&gt;, or verified in a &lt;a href="https://sysdig.com/blog/kubernetes-admission-controllers/"&gt;cluster admission controller&lt;/a&gt; to make sure that non-compliant images are now allowed to run. Another option is installing &lt;a href="https://docs.sysdig.com/en/scan-running-images.html"&gt;Sysdig Node Image Analyzer&lt;/a&gt; to scan images as soon as they start running in the hosts where it is running.&lt;/p&gt;

&lt;p&gt;An example is &lt;a href="https://sysdig.com/blog/image-scanning-github-actions/"&gt;Github Action&lt;/a&gt; integration with the &lt;a href="https://sysdig.com/products/secure/"&gt;Sysdig Secure&lt;/a&gt; Inline Scan Action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: "Security Scan"
on:
  push:
jobs:
  build-and-scan:
    runs-on: ubuntu-latest
    steps:
    - name: Build the Docker image
      run: docker build . --file Dockerfile --tag my-image:latest
    - name: Scan image
      id: scan
      uses: sysdiglabs/scan-action@v3
      with:
        image-tag: my-image:latest
        sysdig-secure-token: ${{ secrets.SYSDIG\_SECURE\_TOKEN }}
        input-type: docker-daemon
        run-as-user: root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The previous example builds a Docker image and then scans it locally, from the Docker daemon.&lt;/p&gt;

&lt;p&gt;Scan results are provided directly as part of the action output, and pull-request can be blocked from merging depending on the check status:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_09.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KaH1j3pe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_09.png" alt="List vulnerabilities" width="880" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Enforce image content trust
&lt;/h3&gt;

&lt;p&gt;Container image integrity can be enforced by adding digital signatures via Docker Notary or similar, which then can be verified in the Admission Controller or the container runtime.&lt;/p&gt;

&lt;p&gt;Let’s see a quick example:&lt;/p&gt;

&lt;p&gt;$ docker trust key generate example1&lt;br&gt;
Generating key for example1...&lt;br&gt;
Enter passphrase for new example1 key with ID 7d7b320:&lt;br&gt;
Repeat passphrase for new example1 key with ID 7d7b320:&lt;br&gt;
Successfully generated and loaded private key. Corresponding public key available: /Users/airadier/example1.pub&lt;/p&gt;

&lt;p&gt;Now, we have a signing key called “example1”. The public part is located in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$HOME/example1.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and the private counterpart will be located in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$HOME/.docker/trust/private/&amp;lt;key ID&amp;gt;.key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other developers can also generate their keys and share the public part.&lt;/p&gt;

&lt;p&gt;Now, we enable a &lt;em&gt;signed&lt;/em&gt; repository by adding the keys of the allowed signers to the repository (airadier/alpine in the example):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker trust signer add --key example1.pub example1 airadier/alpine
Adding signer "example1" to airadier/alpine...
Initializing signed repository for airadier/alpine...
...
Enter passphrase for new repository key with ID 16db658:
Repeat passphrase for new repository key with ID 16db658:
Successfully initialized "airadier/alpine"
Successfully added signer: example1 to airadier/alpine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we can sign an image in the repository with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker trust sign airadier/alpine:latest
Signing and pushing trust data for local image airadier/alpine:latest, may overwrite remote trust data
The push refers to repository \[docker.io/airadier/alpine\]
bc276c40b172: Layer already exists
latest: digest: sha256:be9bdc0ef8e96dbc428dc189b31e2e3b05523d96d12ed627c37aa2936653258c size: 528
Signing and pushing trust metadata
Enter passphrase for example1 key with ID 7d7b320:
Successfully signed docker.io/airadier/alpine:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the &lt;code&gt;DOCKER_CONTENT_TRUST&lt;/code&gt; environment variable is set to &lt;code&gt;1&lt;/code&gt;, then pushed images will be automatically signed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ export DOCKER\_CONTENT\_TRUST=1
$ docker push airadier/alpine:3.11
The push refers to repository \[docker.io/airadier/alpine\]
3e207b409db3: Layer already exists
3.11: digest: sha256:39eda93d15866957feaee28f8fc5adb545276a64147445c64992ef69804dbf01 size: 528
Signing and pushing trust metadata
Enter passphrase for example1 key with ID 7d7b320:
Successfully signed docker.io/airadier/alpine:3.11
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can check the signers of an image with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker trust inspect --pretty airadier/alpine:latest
Signatures for airadier/alpine:latest
SIGNED TAG   DIGEST                                                             SIGNERS
latest       be9bdc0ef8e96dbc428dc189b31e2e3b05523d9...   example1
List of signers and their keys for airadier/alpine:latest
SIGNER     KEYS
example1   7d7b320791b7
Administrative keys for airadier/alpine:latest
  Repository Key:       16db658159255bf0196...
  Root Key:             2308d2a487a1f2d499f184ba...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the environment variable &lt;code&gt;DOCKER_CONTENT_TRUST&lt;/code&gt; is set to &lt;code&gt;1&lt;/code&gt;, the Docker CLI will refuse to pull images without trust information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ export DOCKER\_CONTENT\_TRUST=1
$ docker pull airadier/alpine-ro:latest
Error: remote trust data does not exist for docker.io/airadier/alpine-ro: notary.docker.io does not have trust data for docker.io/airadier/alpine-ro
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can enforce content trust in a Kubernetes cluster by using an &lt;a href="https://github.com/sse-secure-systems/connaisseur"&gt;Admission controller like Connaisseur&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Common security misconfigurations and remediations
&lt;/h3&gt;

&lt;p&gt;Wrongly configured hosts, container runtimes, clusters, or cloud resources can leave a door open to an attack, or create an easy way to escalate privileges and perform lateral movement.&lt;/p&gt;

&lt;p&gt;Benchmarks, best practices, and hardening guides provide you with information about how to spot those misconfigurations, why they are a problem, and how to remediate them. Among different sources of information, the &lt;a href="https://www.cisecurity.org/"&gt;Center for Internet Security (CIS)&lt;/a&gt; is paramount. It’s a non-profit organization that publishes free &lt;a href="https://www.cisecurity.org/cis-benchmarks/"&gt;benchmarks&lt;/a&gt; for many different environments, where any person and company can contribute with their knowledge. It has become a de facto standard for security benchmarking.&lt;/p&gt;

&lt;p&gt;The best way to make sure you can check this kind of setting for container security is to automate it as much as possible. Several tools exist for this, mainly based on static configuration analysis, allowing you to check configuration parameters at different levels and provide guidance in fixing them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.sysdig.com/en/benchmarks.html"&gt;Sysdig Secure includes a Compliance and Benchmarks feature&lt;/a&gt; which can help you schedule, execute, and analyze all of your infrastructure (Linux hosts, Docker, Kubernetes, EKS, GKE, Openshift clusters, etc.) based on CIS Benchmarks, as well as compliance standards, like &lt;a href="https://sysdig.com/blog/container-pci-compliance/"&gt;PCI DSS&lt;/a&gt;, &lt;a href="https://sysdig.com/blog/soc-2-compliance/"&gt;SOC 2&lt;/a&gt;, &lt;a href="https://sysdig.com/blog/nist-800-53-compliance/"&gt;NIST 800-53&lt;/a&gt;, &lt;a href="https://sysdig.com/blog/nist-sp-800-190-compliance-assurance-with-sysdig-secure/"&gt;NIST 800-190&lt;/a&gt;, &lt;a href="https://sysdig.com/blog/hipaa-compliance-with-sysdig/"&gt;HIPAA&lt;/a&gt;, &lt;a href="https://sysdig.com/blog/iso-27001-compliance-sysdig/"&gt;ISO 27001&lt;/a&gt;, &lt;a href="https://sysdig.com/blog/aws-gdpr-compliance-secure/"&gt;GDPR&lt;/a&gt; and others, all in a single centralized dashboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_10.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hIWh_9RK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_10.png" alt="Sysdig secure dashboard" width="880" height="583"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Other tools you can use are &lt;a href="https://github.com/aquasecurity/linux-bench"&gt;linux-bench&lt;/a&gt;, &lt;a href="https://github.com/docker/docker-bench-security"&gt;docker-bench&lt;/a&gt;, &lt;a href="https://github.com/aquasecurity/kube-bench"&gt;kube-bench&lt;/a&gt;, &lt;a href="https://github.com/aquasecurity/kube-hunter"&gt;kube-hunter&lt;/a&gt;, &lt;a href="https://github.com/vchinnipilli/kubestriker"&gt;kube-striker&lt;/a&gt;, &lt;a href="https://cloudcustodian.io/"&gt;Cloud Custodian&lt;/a&gt;, &lt;a href="https://oval.cisecurity.org/"&gt;OVAL&lt;/a&gt;, and &lt;a href="https://github.com/osquery/osquery"&gt;OS Query&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example host benchmark control
&lt;/h4&gt;

&lt;p&gt;A physical machine where you just installed Linux, a virtual machine provisioned on a cloud provider, or on-prem may contain several insecure out-of-the-box configurations that you are not aware of. If you plan to use it for a prolonged period, with a production workload or exposure to the internet, you have to take special care of them. This is also true for Kubernetes or OpenShift nodes. After all, they are virtual machines; don’t assume that if you are using a cluster provisioned by your cloud provider that they come perfectly secured.&lt;/p&gt;

&lt;p&gt;CIS has a benchmark for Distribution Independant Linux, and one specifically for Debian, CentOs, Red Hat, and many other distributions.&lt;/p&gt;

&lt;p&gt;Examples of misconfigurations you can detect:&lt;/p&gt;

&lt;h4&gt;
  
  
  Example linux distribution
&lt;/h4&gt;

&lt;p&gt;The following figure is provided by &lt;a href="https://www.cisecurity.org/benchmark/distribution_independent_linux/"&gt;CIS Benchmark for Distribution Independant Linux&lt;/a&gt;, the configuration is to ensure rsh server is not enabled.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_11-e1633969083645.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0nxyxSC5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_11-e1633969083645.png" alt="CIS best practice example 1" width="817" height="424"&gt;&lt;/a&gt; &lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_12.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XSyB3BfL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_12.png" alt="" width="773" height="169"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Example container runtime benchmark control
&lt;/h4&gt;

&lt;p&gt;If you install a container runtime like Docker by yourself in a server you own, it’s essential you use a benchmark to make sure any default insecure configuration is remediated. The next figure shows the configuration to ensure that authorization for Docker client commands is enabled.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_13.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oPGkoO2G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_13.png" alt="CIS best practice example 2" width="880" height="663"&gt;&lt;/a&gt; &lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_14.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sSN-ir79--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_14.png" alt="" width="880" height="647"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Example orchestrator benchmark control
&lt;/h4&gt;

&lt;p&gt;Kubernetes, by default, leaves many authentication mechanisms to be managed by third-party integrations. A benchmark will ensure all possible insecurities are dealt with. The image below show us the configuration to ensure that the &lt;em&gt;–anonymous-auth&lt;/em&gt; argument is set to false.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_15.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dGugyWit--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_15.png" alt="CIS best practice example 3" width="880" height="574"&gt;&lt;/a&gt; &lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_16.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JEDtXduT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_16.png" alt="" width="880" height="113"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Example cloud benchmark control
&lt;/h4&gt;

&lt;p&gt;Benchmarks on cloud provider accounts, also called &lt;a href="https://sysdig.com/products/secure/cspm-cloud-security-posture-management/"&gt;Cloud Security Posture Management&lt;/a&gt; (CSPM), are essential, as they will check the security on every single asset on the account. All settings that could lead to an attack, resources that should be private but are made public (e.g., S3 buckets), or storage that lacks encryption are defined in this kind of benchmark. This is a benchmark that is essential to automate, as the assets in the cloud account change all the time, and you have to constantly watch that everything is as secure as possible. The following image is an example of configuration check that ensures credentials unused for 90 days or greater are disabled.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_17.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4ZQlVU4u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_17.png" alt="CIS best practice example 4 part 1" width="797" height="445"&gt;&lt;/a&gt; &lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_18.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MuZXfhFC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_18.png" alt="CIS best practice example 4 part 2" width="806" height="501"&gt;&lt;/a&gt; &lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_19.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xBk4muNi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_19.png" alt="" width="802" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Incorporate IaC scanning
&lt;/h3&gt;

&lt;p&gt;Cloud resource management is a complex task, and tools like Terraform or CloudFormation can help leverage this burden. Infrastructure is &lt;em&gt;declared&lt;/em&gt; as code – aka “Infrastructure as Code” – stored and versioned in a repository, and automation takes care of applying the changes in the definition to keep the existing infrastructure up to date with the declaration.&lt;/p&gt;

&lt;p&gt;If you are using infrastructure as code, incorporate IaC scanning tools like &lt;a href="https://sysdig.com/blog/sysdig-and-apolicy-join-forces-to-help-customer-secure-infrastructure-as-code/"&gt;Apolicy&lt;/a&gt;, &lt;a href="https://www.checkov.io/"&gt;Checkov&lt;/a&gt;, &lt;a href="https://github.com/aquasecurity/tfsec"&gt;tfsec&lt;/a&gt;, or &lt;a href="https://github.com/stelligent/cfn_nag"&gt;cfn_nag&lt;/a&gt; to validate the configuration of your infrastructure &lt;em&gt;before&lt;/em&gt; it is created or updated. Similar to other linting tools, apply IaC scanning tools locally and in your pipeline, and consider blocking changes that introduce security issues.&lt;/p&gt;

&lt;p&gt;An example of a checkov execution:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pip install checkov
$ checkov --quiet -d .
       \_               \_
   \_\_\_| |\_\_   \_\_\_  \_\_\_| | \_\_\_\_\_\_\_   \_\_
  / \_\_| '\_ \\ / \_ \\/ \_\_| |/ / \_ \\ \\ / /
 | (\_\_| | | |  \_\_/ (\_\_|   &amp;lt; (\_) \\ V /
  \\\_\_\_|\_| |\_|\\\_\_\_|\\\_\_\_|\_|\\\_\\\_\_\_/ \\\_/
By bridgecrew.io | version: 2.0.346
terraform scan results:
Passed checks: 314, Failed checks: 57, Skipped checks: 0
Check: CKV\_AWS\_108: "Ensure IAM policies does not allow data exfiltration"
        FAILED for resource: aws\_iam\_policy\_document.cloudtrail\_ingestor
        File: /modules/ingestor/main.tf:17-31
        Guide: https://docs.bridgecrew.io/docs/ensure-iam-policies-do-not-allow-data-exfiltration
                17 | data "aws\_iam\_policy\_document" "ingestor" {
                18 |   statement {
                19 |     effect = "Allow"
                20 |     actions = \[
                21 |       "s3:Get\*",
                22 |       "s3:List\*",
                23 |       "s3:Put\*",
                24 |       "s3:Head\*",
                25 |       "sqs:DeleteMessage",
                26 |       "sqs:DeleteMessageBatch",
                27 |       "sqs:ReceiveMessage",
                28 |     \]
                29 |     resources = \["\*"\]
                30 |   }
                31 | }
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7. Secure your host with host scanning
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/blog/vulnerability-assessment/#host"&gt;Securing your host&lt;/a&gt; is just as important as securing the containers. The host where the containers are running is usually composed of an operating system with a Linux kernel, a set of libraries, a container runtime, and other common services and helpers running in the background. Any of these components can be vulnerable or misconfigured, and could be used as the entry point to access the running containers or cause a denial of service attack.&lt;/p&gt;

&lt;p&gt;For example, issues in the container runtime itself can cause an impact in your running containers, like this &lt;a href="https://sysdig.com/blog/cve-2021-20291-cri-o-podman/"&gt;DoS attack that prevents creating new containers in a host.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We already talked about hardening host configuration in the “Unsafe configuration” section. But how do we detect vulnerable components? A &lt;a href="https://sysdig.com/blog/vulnerability-assessment/#host"&gt;host scanning&lt;/a&gt; tool can detect known vulnerabilities in the kernel, standard libraries like glibc, services, and even the container runtime living in the host (quite similar to what image scanning does for a container image).&lt;/p&gt;

&lt;p&gt;Sysdig Host Analyzer will transparently scan your hosts and report found vulnerabilities, The following figure shows how easy it is to detect risks at a glance on the dashboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_20.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pUECubR---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_20.png" alt="" width="880" height="445"&gt;&lt;/a&gt; &lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_21.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A8j_FdtC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_21.png" alt="" width="880" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use this information to update the operating system, kernel, packages, etc. Get rid of the most critical and exploitable vulnerabilities, or at least be aware of them, and apply other protection mechanisms like firewalls, restricting user access to the host, stopping unused services, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Prevent unsafe containers from running
&lt;/h3&gt;

&lt;p&gt;As a last line of defense, &lt;a href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/"&gt;Kubernetes Admission Controllers&lt;/a&gt; can block unsafe containers from running in the cluster.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.sysdig.com/en/admission-controller.html"&gt;Sysdig Admission Controller&lt;/a&gt; allows you to deny the creation of pods running images that don’t pass your security policies, based on the scanning results.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/open-policy-agent/gatekeeper"&gt;Gatekeeper&lt;/a&gt; provides a powerful language that can be used to define flexible rules to accept or reject containers based on the pod specification (e.g., enforce annotations, detect privileged pods, or using host paths) and the status of the cluster (e.g.m, require all ingress hosts to be unique within the cluster).&lt;/p&gt;

&lt;p&gt;As an example, the following Gatekeeper ConstrainsTemplate (some data is ellipsed) defines a template for detecting required annotations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: templates.gatekeeper.sh/v1beta1
kind: ConstraintTemplate
metadata:
  name: k8srequiredannotations
  annotations:
    description: Requires all resources to contain a specified annotation(s) with a value
      matching a provided regular expression.
spec:
 ...
  targets:
    - target: admission.k8s.gatekeeper.sh
      rego: |
        package k8srequiredannotations
        violation\[{"msg": msg, "details": {"missing\_annotations": missing}}\] {
            provided := {annotation | input.review.object.metadata.annotations\[annotation\]}
            required := {annotation | annotation := input.parameters.annotations\[\_\].key}
            missing := required - provided
            count(missing) &amp;gt; 0
            msg := sprintf("you must provide annotation(s): %v", \[missing\])
        }
        violation\[{"msg": msg}\] {
          value := input.review.object.metadata.annotations\[key\]
          expected := input.parameters.annotations\[\_\]
          expected.key == key
          expected.allowedRegex != ""
          not re\_match(expected.allowedRegex, value)
          msg := sprintf("Annotation &amp;lt;%v: %v&amp;gt; does not satisfy allowed regex: %v", \[key, value, expected.allowedRegex\])
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using that template, we can enforce that all services have some annotations with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sRequiredAnnotations
metadata:
  name: all-must-have-certain-set-of-annotations
spec:
  match:
    kinds:
      - apiGroups: \[""\]
        kinds: \["Service"\]
  parameters:
    message: "All services must have a \`a8r.io/owner\` and \`a8r.io/runbook\` annotations."
    annotations:
      - key: a8r.io/owner
        # Matches email address or github user
        allowedRegex: ^(\[A-Za-z0-9.\_%+-\]+@\[A-Za-z0-9.-\]+\\.\[A-Za-z\]{2,6}|\[a-z\]{1,39})$
      - key: a8r.io/runbook
        # Matches urls including or not http/https
        allowedRegex: ^(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/)?\[a-z0-9\]+(\[\\-\\.\]{1}\[a-z0-9\]+)\*\\.\[a-z\]{2,5}(:\[0-9\]{1,5})?(\\/.\*)?$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Many more examples are available in the &lt;a href="https://github.com/open-policy-agent/gatekeeper-library"&gt;OPA Gatekeeper library project&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;We already mentioned &lt;a href="https://github.com/sse-secure-systems/connaisseur"&gt;Connaisseur Admission Controller&lt;/a&gt; as a way to enforce content trust and reject images that are not signed by trusted sources.&lt;/p&gt;

&lt;h2&gt;
  
  
  Protection – Running your containers safely
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_22.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vGgmIOHN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_22.png" alt="Protection" width="880" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Adhering to build time and configuration container security best practices right before runtime still won’t make your container 100 percent safe. New container vulnerabilities are discovered daily, so your actual container, quite safe today, can become a potential victim of new disclosed exploits tomorrow.&lt;/p&gt;

&lt;p&gt;In this section, we will introduce container security best practices for including container vulnerability management and protection measures in your workload.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. Protect your resources
&lt;/h3&gt;

&lt;p&gt;Your containers and host might contain vulnerabilities, and new ones are discovered continually. However, the danger is not in the host or container vulnerability itself, but rather the attack vector and exploitability.&lt;/p&gt;

&lt;p&gt;For example, you can protect from a network exploitable vulnerability by impeding connections to the running container or the vulnerable service. And if the attack vector requires local access to the host (being logged in the host), you can restrict the access to that host.&lt;/p&gt;

&lt;p&gt;So, limit the number of &lt;strong&gt;users that have access to your hosts&lt;/strong&gt;, cloud accounts, and resources, and &lt;strong&gt;block unnecessary network traffic&lt;/strong&gt; by using different mechanisms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  VPCs, Security groups, network rules, firewall rules, etc. in cloud providers to restrict communication between VMs, VPCs, and the Internet.&lt;/li&gt;
&lt;li&gt;  Firewalls at hosts levels to expose only the minimal set of required services.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://sysdig.com/blog/kubernetes-native-network-security/"&gt;Kubernetes Network Policies&lt;/a&gt; for clusters, and additional tools, like Service Mesh or API Gateways, can add an additional security layer for filtering network requests.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  10. Verify image signatures
&lt;/h3&gt;

&lt;p&gt;As described in “Image content trust”, image signatures are a protection mechanism to guarantee that the image has not been tampered. Verifying image signatures can also prevent some attacks with &lt;a href="https://sysdig.com/blog/toctou-tag-mutability/"&gt;tag mutability&lt;/a&gt;, assuring that the tag corresponds to a specific digest that has been signed by the publisher. The figure below shows an example of this attack.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_23.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VaR0LGmQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_23.png" alt="Tag mutability attack" width="880" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  11. Restrict container privileges at runtime
&lt;/h3&gt;

&lt;p&gt;The scope or “blast radius” of an exploited vulnerability inside a container largely depends on the privileges of the container, and the level of isolation from the host and other resources. Runtime configuration can mitigate the impact of existing and future vulnerabilities in the following ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Effective user:&lt;/strong&gt; Don’t run the container as &lt;em&gt;root&lt;/em&gt;. Even better, use randomized UIDs (like Openshift) that don’t map to real users in the host, or use the &lt;a href="https://docs.docker.com/engine/security/userns-remap/"&gt;user namespace feature&lt;/a&gt; in Docker and in &lt;a href="https://github.com/kubernetes/enhancements/issues/127"&gt;Kubernetes when ready&lt;/a&gt; (not available at time of publish).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Restrict container privileges:&lt;/strong&gt; Docker and &lt;a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/"&gt;Kubernetes offer ways to drop capabilities and don’t allow privileged&lt;/a&gt; containers. &lt;a href="https://kubernetes.io/docs/tutorials/clusters/seccomp/"&gt;Seccomp&lt;/a&gt; and &lt;a href="https://kubernetes.io/docs/tutorials/clusters/apparmor/"&gt;AppArmor&lt;/a&gt; can add more restrictions to the range of actions a container can perform.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Add &lt;a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/"&gt;resource limits&lt;/a&gt;&lt;/strong&gt;: Avoid container consuming all the memory or CPUs and starve other applications.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Be careful with shared storage or volumes:&lt;/strong&gt; Specifically, things like &lt;a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath"&gt;hostPath&lt;/a&gt;, and sharing the filesystem from the host.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Other options like &lt;em&gt;hostNetwork&lt;/em&gt;, &lt;em&gt;hostPID&lt;/em&gt; or &lt;em&gt;hostIPC:&lt;/em&gt;&lt;/strong&gt; Kubernetes will make the container share a namespace with the host, reducing isolation.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Define &lt;a href="https://kubernetes.io/docs/concepts/policy/pod-security-policy/"&gt;Pod Security Policies&lt;/a&gt; (PSPs) and &lt;a href="https://docs.openshift.com/container-platform/4.8/authentication/managing-security-context-constraints.html"&gt;Security Context Constraints&lt;/a&gt; (SCCs for Openshift):&lt;/strong&gt; Set guardrails in your cluster and prevent misconfigured containers. PSPs and SCCs are Admission Controllers that will reject pods in case their security context does not comply with the defined policies.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  12. Manage container vulnerabilities wisely
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/blog/vulnerability-assessment/"&gt;Manage and assess your vulnerabilities wisely&lt;/a&gt;. Not all vulnerabilities have fixes available, or may now be able to be applied easily.&lt;/p&gt;

&lt;p&gt;However, not all of them might be easily exploitable, or they may require local or even physical access to the hosts to be exploited.&lt;/p&gt;

&lt;p&gt;You need to have a good strategy, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Prioritize what needs to be fixed:&lt;/strong&gt; You should focus on host and container vulnerabilities with higher score or severity, which often means that they are remotely exploitable and that a public exploit is available. If they are old and well known, the chances are high that they are being actively exploited in an automated way.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Evaluate the severity of vulnerabilities in your environment:&lt;/strong&gt; The score or severity provided by the vendor or your linux distribution is a good starting point. But a vulnerability can have a high score if it is remotely exploitable, and then exist in an unused package in an internal host which is not exposed to the internet. And it can be in a production environment, or a developers’ playground and experimental cluster. Evaluate the impact in context, and plan accordingly.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Plan applying fixes as countermeasures to protect your containers and hosts:&lt;/strong&gt; Create and track tickets, making vulnerability management part of your standard development workflows.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Create exceptions for vulnerabilities when you conclude that you are not impacted:&lt;/strong&gt; This will reduce the noise. Consider snoozing instead of permanently adding an exception, so you can reevaluate later.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your strategy should translate in policies that a container vulnerability scanner can use to trigger alerts for detected vulnerabilities according to some criteria, and to apply prevention and protection at different levels, like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Ticketing:&lt;/strong&gt; Notify developers of detected vulnerabilities so they can apply the fixes.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Image registry:&lt;/strong&gt; Prevent vulnerable images from being pulled at all.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Host / kernel / container:&lt;/strong&gt; Block running containers, add additional protection measures or respond by killing, quarantine or shut down hosts or containers for critical issues.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is also important to perform continuous vulnerability scanning and reevaluation to make sure that you get alerts when new vulnerabilities that apply to running containers are discovered. &lt;a href="https://sysdig.com/products/secure/"&gt;Sysdig Secure&lt;/a&gt; can help here, as it will reevaluate your scanning policies every time the vulnerability feeds are updated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Detection – Alerts for abnormal behavior
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_24.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E-L2ng3F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_24.png" alt="Monitoring" width="880" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So far, we put the focus on prevention and protection, getting your containers up and running in the best possible shape, and anticipating potential and known attacks. Applying prevention techniques when building, distributing, and running your container with the correct privileges and protections, as well as ensuring the underlying stack, will limit the range of action that an attacker can take. But that doesn’t mean you can just forget about running containers and trust the applied security measures. Once the security measures are running, &lt;strong&gt;they can be attacked&lt;/strong&gt;. We need to &lt;a href="https://sysdig.com/learn-cloud-native/container-security/threat-detection/"&gt;detect abnormal and unexpected behavior&lt;/a&gt; in our applications in order to take corrective action and prevent security incidents from happening again.&lt;/p&gt;

&lt;p&gt;Many different attack vectors exist. For example &lt;a href="https://attack.mitre.org/"&gt;MITRE ATT&amp;amp;CK provides an extensive list of tactics and techniques “based on real world observations”&lt;/a&gt;, which can be used both to apply prevention measures and to analyze the activity to detect abnormal behaviors, which can mean an attack or intrusion is being performed. The &lt;a href="https://attack.mitre.org/matrices/enterprise/containers/"&gt;MITRE ATT&amp;amp;CK Matrix for Containers&lt;/a&gt; covers techniques specifically targeted against container technologies.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Blog-images-Container-security-best-practices_MITRE.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b-bLUZlP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Blog-images-Container-security-best-practices_MITRE.png" alt="Mitre Schema" width="880" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  13. Set up real-time event and log auditing
&lt;/h3&gt;

&lt;p&gt;Threats to container security can be detected by auditing different sources of logs and events, and analyzing abnormal activity. Sources of events include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Host and Kubernetes logs&lt;/li&gt;
&lt;li&gt;  Cloud logs (CloudTrail in AWS, Activity Audit in GCP, etc.)&lt;/li&gt;
&lt;li&gt;  System calls in containers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://falco.org/"&gt;Falco&lt;/a&gt; is capable of monitoring the executed system calls and generating alerts for suspicious activity. It includes a community-contributed library of rules, and you can create your own by using a simple syntax. Kubernetes audit log is also supported.&lt;/p&gt;

&lt;p&gt;You can see nice examples of Falco in action in our Detecting MITRE ATT&amp;amp;CK articles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://sysdig.com/blog/mitre-privilege-escalation-falco/"&gt;Privilege escalation with Falco&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://sysdig.com/blog/mitre-defense-evasion-falco/"&gt;Defense evasion techniques with Falco&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sysdig Secure extends the capabilities of Falco and can also &lt;a href="https://cloudsec.sysdig.com/"&gt;ingest events from different cloud providers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As an example, the following rule would trigger an alert whenever a new ECS Task is executed in the account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rule: ECS Task Run or Started
condition: aws.eventSource="ecs.amazonaws.com" and (aws.eventName="RunTask" or aws.eventName="StartTask") and not aws.errorCode exists
output: A new task has been started in ECS (requesting user=%aws.user, requesting IP=%aws.sourceIP, AWS region=%aws.region, cluster=%jevt.value\[/requestParameters/cluster\], task definition=%aws.ecs.taskDefinition)
source: aws\_cloudtrail
description: Detect a new task is started in ECS.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sysdig also includes an ever growing set of rules tagged with the corresponding compliance standards and controls, and provides a centralized dashboard for exploring all security events in your infrastructure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_26.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oHR0DfV5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_26.png" alt="Sysdig Secure dashboard" width="880" height="546"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  14. Monitor your resources
&lt;/h3&gt;

&lt;p&gt;Excessive resource usage (CPU, memory, network), quick decrease in available disk space, over-average error rate, or increased latency might be signals that something strange is happening in your system.&lt;/p&gt;

&lt;p&gt;Collect metrics, like with &lt;a href="https://sysdig.com/opensource/prometheus/"&gt;Prometheus&lt;/a&gt;. Configure alerts to quickly get notified when the values exceed the expected thresholds. Use meaningful dashboards to explore the evolution of metrics, and correlate with changes in other metrics and events happening in your system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_27.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TMYlK-fe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_27.png" alt="Sysdig Monitor metrics" width="865" height="673"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, we notice a sudden increase in request latency and the request rate falling. This could mean something is happening in your containers (e.g., a &lt;a href="https://sysdig.com/blog/crypto-sysrv-hello-wordpress/"&gt;cryptominer consuming all the available CPU&lt;/a&gt;), or an exploit causing response slowness and potentially a DoS. Checking the related cluster events around that time frame, we see a pod has been replaced, so it is also possible that a malicious or simply incorrectly configured version was deployed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Incident response and forensics
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_28.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j9Ng7l5B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_28.png" alt="Response" width="880" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you detect a security incident is happening in your system, take action to stop the threat and limit any additional harm. Instead of just killing the container or shutting down a host, consider isolating it, pausing it, or taking a snapshot. A good forensics analysis will provide many clues and reveal what, when, and how it happened. It is critical to identify:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  If the security incident was a real attack or just a component malfunction.&lt;/li&gt;
&lt;li&gt;  What exactly happened, where did it occur, and are any other potentially impacted components?&lt;/li&gt;
&lt;li&gt;  How can you prevent the security incident from happening again?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  15. Isolate and investigate
&lt;/h3&gt;

&lt;p&gt;When a security incident is detected, you should quickly stop it first to limit any further damage.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Stop and snapshot:&lt;/strong&gt; When possible, isolate the host or container. Container runtimes’ offer was to “pause” the container (i.e., “docker pause” command) or take a snapshot and then stop it. For hosts, you might take a snapshot at the filesystem level, then shut it down. For EC2 or VM instances, you can also take a snapshot of the instance. Then, proceed to isolation. You can copy the snapshot to a safe sandbox environment, without networking, and resume the host or container.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Explore and forensics:&lt;/strong&gt; Once isolated, you can ideally explore the live container or host, and investigate running processes. If the host or container is not alive, then you can just focus on the snapshot of the filesystem. Explore the logs and modified files. There are tools like, Sysdig Secure &lt;strong&gt;captures&lt;/strong&gt;, that greatly enhance forensics capabilities by recording all the system calls around an event and allowing you to explore even after the container or host is dead.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Kill the compromised container and/or host as a last resource:&lt;/strong&gt; Simply destroying the suspicious activity will prevent any additional harm in the short term. But missing details about what happened will make it impossible to prevent it from happening again, and you can end up in a never ending &lt;em&gt;whack-a-mole&lt;/em&gt; situation, repeatedly waiting for the next attack to happen just to kill it again.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check out a great example of forensics investigation in &lt;a href="https://sysdig.com/blog/rinbot-discord-bot-crypto-miner/"&gt;THREAT ALERT: Crypto miner attack involving RinBot’s server, a popular Discord bot&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  16. Fix misconfigurations
&lt;/h3&gt;

&lt;p&gt;Investigation should reveal what made the attack possible. Once you have discovered the attack source, take security measures to prevent it from happening again. The cause of a host, container, or application being compromised can be a bad configuration, like excessive permissions, exposed ports or services, or an exploited vulnerability.&lt;/p&gt;

&lt;p&gt;In the case of the former, fix the misconfigurations to keep it from happening again. In the latter case, it might be possible to prevent a vulnerability from being exploited (or at least limit its scope) by making changes in configurations, like firewalls, using a more restrictive user, and protecting files or directories with additional permissions or ACLs, etc.&lt;/p&gt;

&lt;p&gt;If the issue applies to other assets in your environment, apply the fix in all of them. It’s especially important to do so in those that might be exposed, like applications that are reachable from the internet if the exploit can be executed over a remote network connection.&lt;/p&gt;

&lt;h3&gt;
  
  
  17. Patch vulnerabilities
&lt;/h3&gt;

&lt;p&gt;When possible, fix the vulnerability itself:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;For operating system packages (dpkg, rpm, etc.):&lt;/strong&gt; First check if the distribution vendor is offering an updated version of the package containing a fix. Just update the package or the container base image.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Older distribution versions:&lt;/strong&gt; The vendor will stop providing updated versions and security fixes. Keep your hosts and images using supported versions before it is too late.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;For language packages, like NodeJS, Go, Java, etc.:&lt;/strong&gt; Check for updated versions of the dependencies. Search for minor updates or patch versions that simply fix security issues if you can’t spend additional time planning and testing for breaking changes that can happen on bigger version updates. But plan ahead: old versions won’t be maintained forever.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;In case the distribution does not offer a patched version or there is no fix for unmaintained packages:&lt;/strong&gt; It is still possible that a fix exists and can be manually applied or backported. This will require some additional work but it can be necessary for packages that are critical for your system and when there is no official fixed version yet. Check the vulnerability links in databases like NVD, vendor feeds and sources, public information in bug reports, etc. If a fix is available, you should be able to locate it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If there is no fix available that you can apply on the impacted package, it might still be possible to prevent exploiting the vulnerability with configuration or protection measures (e.g., firewalls, isolation, etc.). Also, it might be complex and require a deep knowledge of the vulnerability, but you can add additional checks in your own code. For example, a vulnerability caused by an overflow in a JSON processing library that is used by a web API server could be prevented by adding some checks at the HTTP request level, blocking requests that contain strings that could potentially lead to the overflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  18. Close the loop
&lt;/h3&gt;

&lt;p&gt;Unfortunately, host and container security is not a one way trip where you just apply a set of security containers good practices once and can forget forever. Software and infrastructure are evolving everyday, and so complexity increases and new errors are introduced. This leads to vulnerabilities and configuration issues. New attacks and exploits are discovered continuously.&lt;/p&gt;

&lt;p&gt;Start by including prevention and security best practices. Then, apply protection measures to your resources, mostly hosts and workloads, but also cloud services. Continue monitoring and detecting anomalous behavior to take action, respond, investigate and report the discovered incidents. Forensics evidence will close the loop: fix discovered vulnerabilities and improve protection to start over again, rebuilding your images, updating packages, reconfiguring your resources, and create incident reports to the future security incidents.&lt;/p&gt;

&lt;p&gt;In the middle, you need to assess risk and manage vulnerabilities. The number of inputs to manage in a complex and big environment can be overwhelming, so classify and prioritize to focus on the highest risks first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_01.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lIUbeOxl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/Container-Security-Best-Practices_01.png" alt="Diagram security container" width="880" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We’ve reviewed how container security best practices can be easily applied to your DevOps workflows. In particular, remember to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Shift left security, the first step is prevention.&lt;/li&gt;
&lt;li&gt;  Protect all your assets.&lt;/li&gt;
&lt;li&gt;  Know everything that happens in your organization, monitoring and detecting issues as fast as possible.&lt;/li&gt;
&lt;li&gt;  Plan for incident response, because attacks are inevitable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remember that container security best practices don’t just include the delivered applications and container images themselves. You also need to include the full component stack used for building, distributing, and specifically executing the container.&lt;/p&gt;

&lt;p&gt;54 percent of containers live for five minutes or less, which makes investigating anomalous behavior and breaches extremely challenging.&lt;/p&gt;

&lt;p&gt;One of the key points of cloud-native security is addressing container security risks as soon as possible. Doing it later in the development life cycle slows down the pace of cloud adoption, while raising security and compliance risks.&lt;/p&gt;

</description>
      <category>security</category>
      <category>docker</category>
      <category>kubernetes</category>
      <category>devops</category>
    </item>
    <item>
      <title>Secure software supply chain: why every link matters</title>
      <dc:creator>Miguel</dc:creator>
      <pubDate>Tue, 16 Nov 2021 10:23:06 +0000</pubDate>
      <link>https://dev.to/sysdig/secure-software-supply-chain-why-every-link-matters-bna</link>
      <guid>https://dev.to/sysdig/secure-software-supply-chain-why-every-link-matters-bna</guid>
      <description>&lt;p&gt;The &lt;strong&gt;new threats&lt;/strong&gt; in software development are not only related to the specific company itself. The &lt;strong&gt;whole software supply chain is a target&lt;/strong&gt; for attackers and it is really important to make sure that we put all our effort into securing each link because &lt;strong&gt;if one fails, everything will be affected&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Supply chain activities include each step of the transformation of raw materials, components, and resources into a completed product, and its delivery to the end customer.&lt;/p&gt;

&lt;p&gt;Each step could be a complex process itself and cause a security incident.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a software supply chain
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The software supply chain&lt;/strong&gt; is similar to other activities or industries. Some &lt;strong&gt;resources are consumed&lt;/strong&gt;, then &lt;strong&gt;transformed&lt;/strong&gt;, through a series of steps and &lt;strong&gt;processes&lt;/strong&gt;, and finally &lt;strong&gt;&lt;em&gt;supplied&lt;/em&gt;&lt;/strong&gt; as a product or service to a customer.&lt;/p&gt;

&lt;p&gt;In software, the raw materials are common libraries, code, hardware, and tools that transform code into a final deliverable. This deliverable can be deployed as either a user-facing application, a service (starting over with the same supply chain loop), or another package artifact that is included as a dependency, part of a different product.&lt;/p&gt;

&lt;p&gt;The chain can be long and quite complex, so let’s try an extremely &lt;strong&gt;simplified example&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/SupplyChain-02.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j_I9Qgdu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/SupplyChain-02.png" alt="Simplified example of dependences" width="880" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order to produce the final “web application” for our customer, we need to transform (compile) a source code and consume information from third-party services. The source code itself depends on external libraries, which are produced from another code, etc.&lt;/p&gt;

&lt;p&gt;Software supply chain &lt;strong&gt;attack&lt;/strong&gt; happens when some malicious element is introduced in this chain.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;successful attack in any link&lt;/strong&gt; of the supply &lt;strong&gt;can propagate the&lt;/strong&gt; &lt;strong&gt;compromised&lt;/strong&gt; code or component downstream, completely unnoticed, and cause mayhem across different stages.&lt;/p&gt;

&lt;p&gt;In fact, many of these attacks focus on compromising a software vendor by injecting some &lt;strong&gt;malware or vulnerability&lt;/strong&gt; at an intermediate step in order to exploit the final customers with fatal consequences.&lt;/p&gt;

&lt;p&gt;As your company or product is just a piece in the overall software supply chain, security measures related to the supply chain can be applied on three different points:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Inputs&lt;/strong&gt;: Library and package dependencies, third-party tools, software, services, or any artifact you are consuming, either public or from a private vendor.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Outputs&lt;/strong&gt;: Guarantee the integrity of your deliverables and provide ways to verify the components downstream.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Processes and infrastructure&lt;/strong&gt;: Protect your network, identities, credentials, signature keys, repositories, and processes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We will explain some of the &lt;strong&gt;common supply chain attacks&lt;/strong&gt;, with recent examples, and provide &lt;strong&gt;tips and practices that you can apply to mitigate the risks&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a supply chain attack
&lt;/h2&gt;

&lt;p&gt;We already gave a definition of the &lt;strong&gt;Software supply chain&lt;/strong&gt; with a simplified example, talking about code, libraries, and services. But let’s &lt;strong&gt;dig a bit deeper&lt;/strong&gt; and put the focus on the source code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/SupplyChain-03.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QW_0WY1o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/SupplyChain-03.png" alt="Focus example source code" width="880" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Zooming in on any link on the chain will reveal additional details:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/SupplyChain-04.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UEVW_BxY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/SupplyChain-04.png" alt="Zoom source code dependeces" width="880" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example, your source code will live in a &lt;strong&gt;private git repository&lt;/strong&gt;, which could be part of your infrastructure or SaaS provided by a vendor, as well as compiler tools, base container image registries, etc.&lt;/p&gt;

&lt;p&gt;Some dependencies are hosted in &lt;strong&gt;public repositories&lt;/strong&gt;, like Docker Hub or Quay.io, and could be compromised. Also, we are publishing our application as a container image in a public repository too.&lt;/p&gt;

&lt;p&gt;Some of the components in the chain (&lt;em&gt;blue&lt;/em&gt;) are under your umbrella, like your &lt;strong&gt;private source code&lt;/strong&gt; git repository, the application code itself, and the final &lt;strong&gt;binary or container image&lt;/strong&gt; that is produced. But many other components or services (in &lt;em&gt;green&lt;/em&gt;) are public services and resources, or provided by other companies, totally &lt;strong&gt;out of your control&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So a software supply chain &lt;strong&gt;attack&lt;/strong&gt; can target you directly, or it can target any &lt;em&gt;upstream&lt;/em&gt; element (like external dependencies or provided services), so you become a victim, either by directly suffering the attack, or by becoming a supplier of compromised resources.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/SupplyChain-05.gif"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BANoHp8S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://sysdig.com/wp-content/uploads/SupplyChain-05.gif" alt="Infection process in the supply chain" width="880" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples of supply chain attacks
&lt;/h2&gt;

&lt;p&gt;Trends show that &lt;a href="https://www.sonatype.com/hubfs/Q3%202021-State%20of%20the%20Software%20Supply%20Chain-Report/SSSC-Report-2021_0913_PM_2.pdf?hsLang=en-us"&gt;supply chain attacks are increasing&lt;/a&gt; at an exponential rate of 4-5x per year, with several thousand last year, the most common being related to dependency confusion or &lt;a href="https://sysdig.com/blog/malicious-python-libraries-jeilyfish-dateutil/"&gt;typosquatting&lt;/a&gt;, followed by malicious source code injection.&lt;/p&gt;

&lt;p&gt;Fortunately, not every attack has a big enough impact to appear in the newspaper, but let’s analyze some of the most relevant and recent ones. Many other examples of different &lt;a href="https://attack.mitre.org/techniques/T1195/"&gt;types of supply chain attacks&lt;/a&gt; are also collected by the CNCF in their &lt;a href="https://github.com/cncf/tag-security/tree/main/supply-chain-security/compromises"&gt;Catalog of Supply Chain Compromises&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  CodeCov
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://about.codecov.io/security-update/"&gt;Leaked credentials in a Docker image from CodeCov allowed the attackers to modify a bash script&lt;/a&gt;. This script was downloaded and executed by customers, resulting in &lt;a href="https://blog.gitguardian.com/codecov-supply-chain-breach/"&gt;leaked customer credentials and attackers getting access to their git repositories&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Multiple customers like &lt;a href="https://www.bleepingcomputer.com/news/security/codecov-hackers-gained-access-to-mondaycom-source-code/"&gt;Monday.com&lt;/a&gt;, &lt;a href="https://www.bleepingcomputer.com/news/security/hashicorp-is-the-latest-victim-of-codecov-supply-chain-attack/"&gt;Hashicorp&lt;/a&gt;, &lt;a href="https://www.bleepingcomputer.com/news/security/twilio-discloses-impact-from-codecov-supply-chain-attack/"&gt;Twilio&lt;/a&gt;, or &lt;a href="https://www.confluent.co.uk/blog/confluent-update-regarding-codecov-incident/"&gt;Confluent&lt;/a&gt; were affected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/SupplyChain-06.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UqoP-Kuk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/SupplyChain-06.png" alt="" width="880" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Solarwinds
&lt;/h3&gt;

&lt;p&gt;The attackers &lt;a href="https://www.solarwinds.com/sa-overview/securityadvisory"&gt;infiltrated Solarwinds’ network and managed to inject malicious software&lt;/a&gt; into their build process. This malware (related to &lt;a href="https://attack.mitre.org/groups/G0016/"&gt;APT29&lt;/a&gt;, Nobelium) was bundled as part of Orion (a Network Management System) product updates. As part of the build process, the artifact was digitally signed and then downloaded by hundreds of customers.&lt;/p&gt;

&lt;p&gt;Once the malware was running in the customer networks, the attackers spied and stole their information.&lt;/p&gt;

&lt;p&gt;This incident also shows how a supply chain attack can propagate downstream and impact multiple customers: as part of the compromised Orion software, a &lt;a href="https://www.mimecast.com/blog/important-security-update/"&gt;TLS certificate private key for a mail server in Mimecast (a cloud cybersecurity services company) was leaked&lt;/a&gt;. This allowed attackers to perform a man-in-the-middle attack on the mail server and access customer emails.&lt;/p&gt;

&lt;p&gt;We might never know the real impact of the Solarwinds attack, as the compromised software was &lt;a href="https://www.sans.org/blog/what-you-need-to-know-about-the-solarwinds-supply-chain-attack/"&gt;running for several weeks or months inside networks of potentially thousands of customers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And it is not yet finished: the attackers behind Solarwinds have been recently &lt;a href="https://blogs.microsoft.com/on-the-issues/2021/10/24/new-activity-from-russian-actor-nobelium/"&gt;attempting to replicate similar attacks but to different parts of the supply chain&lt;/a&gt;, like &lt;em&gt;resellers and other technology service providers that customize, deploy, and manage cloud services and other technologies on behalf of their customers&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/SupplyChain-07.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ygl79hou--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/SupplyChain-07.png" alt="" width="880" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Kaseya
&lt;/h3&gt;

&lt;p&gt;It’s quite similar to the Solarwinds attack, but in this case, the attackers exploited a zero-day vulnerability in &lt;a href="https://helpdesk.kaseya.com/hc/en-gb/articles/4403440684689"&gt;Kaseya systems&lt;/a&gt;. Once they took control of the systems, they &lt;a href="https://www.nytimes.com/2021/07/02/technology/cyberattack-businesses-ransom.html"&gt;executed remote commands in the customers’ systems&lt;/a&gt; using VSA, a remote management and monitoring tool.&lt;/p&gt;

&lt;h3&gt;
  
  
  Apple Xcode and XcodeGhost
&lt;/h3&gt;

&lt;p&gt;In this attack, &lt;a href="https://www.securemac.com/news/xcodespy-mac-malware-targets-developers"&gt;a trojanized version of the legitimate Xcode project “TabBarInteraction”&lt;/a&gt; was published in a public repository. Developers using the fake version of the project were inadvertently executing a script on each project build. The script opened a connection to a C2 (command and control) server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/SupplyChain-08.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AutpJeDO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/SupplyChain-08.png" alt="" width="880" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can find another example where &lt;a href="https://unit42.paloaltonetworks.com/novel-malware-xcodeghost-modifies-xcode-infects-apple-ios-apps-and-hits-app-store/"&gt;repackaged versions of Xcode, with malicious code, were uploaded to Chinese file hosting services&lt;/a&gt;. Developers downloading the compromised version from these mirrors ended up with a modified object file. The object file is linked in the final executable when creating iOS applications. At least two well-known applications reached the official Apple AppStore, successfully passing Apple certification and code review.&lt;/p&gt;

&lt;h3&gt;
  
  
  NPM package ua-parser-js
&lt;/h3&gt;

&lt;p&gt;On Oct. 22, 2021, developers of a very common NPM package, &lt;a href="https://github.com/faisalman/ua-parser-js"&gt;ua-parser-js&lt;/a&gt;, discovered that &lt;a href="https://hackaday.com/2021/10/22/supply-chain-attack-npm-library-used-by-facebook-and-others-was-compromised/"&gt;some attackers uploaded a compromised version of the package&lt;/a&gt; containing malware for Linux and Windows, and were capable of stealing data (at least passwords and cookies from the browser).&lt;/p&gt;

&lt;p&gt;This &lt;em&gt;ua-parser-js&lt;/em&gt; library is part of the supply chain for a large list of software and companies, including Facebook, for some of its user-facing applications in millions of computers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Unicode and code compilers – Invisible vulnerabilities
&lt;/h3&gt;

&lt;p&gt;Some researchers at the University of Cambridge claim the &lt;a href="https://www.trojansource.codes/"&gt;discovery of a novel supply-chain attack&lt;/a&gt; targeting source code in the subtleties of text-encoding standards, such as Unicode. The way Unicode works, it is possible to add special characters to the comments or some parts of the code that make the “logical encoding” of the code work in a &lt;strong&gt;different order from the way it is displayed&lt;/strong&gt;. This makes it possible to &lt;a href="https://krebsonsecurity.com/2021/11/trojan-source-bug-threatens-the-security-of-all-code/"&gt;hide malicious code inside code that looks correct to humans, bypassing review procedures&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But before panicking, please note the &lt;a href="https://research.swtch.com/trojan"&gt;issue might not be that new and invisible,&lt;/a&gt; and it can be prevented by establishing trust in the code contributors and doing proper reviews.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Huawei Ban
&lt;/h3&gt;

&lt;p&gt;Finally, we include this example not as a known software supply chain attack, but as a demonstration of the importance of trusting providers in every single link of the chain. Even the &lt;a href="https://attack.mitre.org/techniques/T1195/003/"&gt;hardware supply chain can be a target&lt;/a&gt;. For years, the U.S. government &lt;a href="https://www.theguardian.com/technology/2012/oct/08/china-huawei-zte-security-threat"&gt;warned the world and American companies about security threats in Chinese network equipment&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Based on available classified and unclassified information, Huawei and ZTE cannot be trusted to be free of foreign state influence and thus pose a security threat to the United States and to our systems.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The warning seems to be based on the lack of information and the inability to satisfy some security concerns, and not on real evidence of any existing backdoor in the systems.&lt;/p&gt;

&lt;p&gt;So we might never get real evidence, but the lack of confidence was so severe that &lt;a href="https://www.androidauthority.com/huawei-google-android-ban-988382/"&gt;Huawei was banned in May 2019&lt;/a&gt; from doing business with any organization that operates in the United States.&lt;/p&gt;

&lt;h2&gt;
  
  
  Supply chain taxonomy (and controversy)
&lt;/h2&gt;

&lt;p&gt;Not everybody agrees that an attack targeting any stage of the software supply chain falls into the category of “supply chain attack”. The European Union Agency for Cybersecurity (ENISA) in the &lt;a href="https://www.enisa.europa.eu/publications/threat-landscape-for-supply-chain-attacks"&gt;Threat Landscape for Supply Chain Attacks report&lt;/a&gt; &lt;em&gt;“proposes a taxonomy to characterize supply chain attacks and structure their subsequent analysis”&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/SupplyChain-09.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AUsE2bHJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/SupplyChain-09.png" alt="" width="880" height="573"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But on the same report, they add:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“If no customer is attacked, or no supplier attacked, then it is probably not a supply chain attack.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Explicitly, they mention some examples that don’t meet the requirements, like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Some &lt;a href="https://blog.sonatype.com/damaging-linux-mac-malware-bundled-within-browserify-npm-brandjack-attempt"&gt;name-squatting or brand-hijacking&lt;/a&gt; packages were uploaded to public repositories because they &lt;strong&gt;did not compromise existing packages or the software repositories&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;  Discovered &lt;a href="https://habr.com/en/post/486856/"&gt;vulnerabilities&lt;/a&gt; or &lt;a href="https://thehackernews.com/2021/06/unpatched-critical-flaw-affects-pling.html"&gt;unintentional errors&lt;/a&gt; that &lt;strong&gt;were not used in &lt;em&gt;known&lt;/em&gt; attacks&lt;/strong&gt;, because they &lt;strong&gt;don’t target a supplier or a customer.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;  Public-facing vulnerable versions of software that allowed exfiltration of customer data, but &lt;a href="https://www.cert.ssi.gouv.fr/uploads/CERTFR-2021-CTI-005.pdf"&gt;in this case the supplier was not compromised (the attack was targeted as French IT providers)&lt;/a&gt; and the vulnerabilities were not intentional nor specifically crafted for this attack.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So for some incidents, &lt;strong&gt;there is not even a global consensus whether it can be classified as a supply chain attack or not&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Securing the software supply chain
&lt;/h2&gt;

&lt;p&gt;Attacks to the software supply chain are broadening the attack surface of companies, as their security does not only depend on internal procedures. Now, they also need to ensure that third parties (including software, hardware, services, etc.) are not a gateway to attackers who can affect them.&lt;/p&gt;

&lt;p&gt;Like traditional security, it is impossible to secure everything, especially as new kinds of software supply chain attacks are being discovered continuously.&lt;/p&gt;

&lt;p&gt;Let’s explain where you need to focus on each of the layers to be as protected as possible.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inputs of your software development
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/SupplyChain-10.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s-Nvt2rG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/SupplyChain-10.png" alt="" width="880" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a consumer of software artifacts, hardware, and services from multiple providers, ensure that your providers apply a high level of security.&lt;/p&gt;

&lt;p&gt;The software supply chain is becoming so critical that in May 2021, the president of the United States issued an &lt;a href="https://www.federalregister.gov/documents/2021/05/17/2021-10460/improving-the-nations-cybersecurity"&gt;Executive Order targeted to improve the nation’s cybersecurity&lt;/a&gt;. As a result of the order, the NIST produced the &lt;a href="https://www.nist.gov/itl/executive-order-improving-nations-cybersecurity/recommended-minimum-standards-vendor-or"&gt;Recommended Minimum Standards for Vendor or Developer Verification (Testing) of Software Under Executive Order (EO) 14028&lt;/a&gt; guide, which recommends minimum standards for verification by software vendors or developers.&lt;/p&gt;

&lt;p&gt;Because it is impossible to achieve and guarantee 100 percent security, please also &lt;strong&gt;pay attention to any risks or incidents impacting your providers, and be ready to take quick corrective action&lt;/strong&gt; in case a compromised component is either detected or reported.&lt;/p&gt;

&lt;h3&gt;
  
  
  Software development in your company
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/SupplyChain-11.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--itDzEqZe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/SupplyChain-11.png" alt="" width="880" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With regard to &lt;strong&gt;code and development processes&lt;/strong&gt;, the mentioned &lt;a href="https://www.nist.gov/itl/executive-order-improving-nations-cybersecurity/recommended-minimum-standards-vendor-or"&gt;Recommended Minimum Standards for Vendor or Developer Verification (Testing) of Software Under Executive Order (EO) 14028&lt;/a&gt; includes the following set of techniques as the &lt;strong&gt;minimal safety requirements for software development life cycle&lt;/strong&gt;. Make sure you don’t miss any of them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Apply threat modeling to identify key or potentially overlooked testing targets.&lt;/li&gt;
&lt;li&gt;  Automated testing.&lt;/li&gt;
&lt;li&gt;  Code-based (static) analysis, using a code-scanner, and review for hard-coded secrets.&lt;/li&gt;
&lt;li&gt;  Dynamic analysis, with built-in checks and protections, black-box and fuzzy testing, web-app scanner, etc.&lt;/li&gt;
&lt;li&gt;  Apply similar checks to included software (third-party dependencies).&lt;/li&gt;
&lt;li&gt;  Fix critical bugs as soon as possible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With &lt;strong&gt;Infrastructure as Code (IaC)&lt;/strong&gt;, threats in the software supply chain now potentially target not just software and applications, but the underlying infrastructure too.&lt;/p&gt;

&lt;p&gt;The same software verification principles should be applied to the deployment and management of infrastructure as code, shifting left security. Sysdig’s acquisition of Apolicy was intended to improve our customer’s KSPM (Kubernetes Security Posture Management) and CSPM (Cloud Security Posture Management) use-cases by &lt;a href="https://sysdig.com/blog/sysdig-apolicy-infrastructure-as-code-security-and-auto-remediation/"&gt;addressing IAC security in a unique and highly differentiated manner&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But &lt;strong&gt;security must be pervasive in all development stages and the whole company culture and practices&lt;/strong&gt;. Securing the code and the development process is clearly not enough, as outlined by multiple organization researches and guides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The &lt;a href="https://www.cisa.gov/sites/default/files/publications/defending_against_software_supply_chain_attacks_508_1.pdf"&gt;Defending Against Software Supply Chain Attacks guide from Cybersecurity and Infrastructure Security Agency&lt;/a&gt; considers that the Software Supply Chain Lifecycle has six phases where &lt;em&gt;“software is at risk of malicious or inadvertent introduction of vulnerabilities”&lt;/em&gt;:

&lt;ul&gt;
&lt;li&gt;  Design&lt;/li&gt;
&lt;li&gt;  Development and production&lt;/li&gt;
&lt;li&gt;  Distribution&lt;/li&gt;
&lt;li&gt;  Acquisition and deployment&lt;/li&gt;
&lt;li&gt;  Maintenance&lt;/li&gt;
&lt;li&gt;  Disposal&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;  The Cloud Native Computing Foundation (CNCF) keeps a living, community maintained document: the &lt;a href="https://github.com/cncf/tag-security/tree/main/supply-chain-security/supply-chain-security-paper"&gt;Software Supply Chain Security Paper&lt;/a&gt;. This paper aims to contribute to the community with &lt;em&gt;“a series of recommended practices, tooling options, and design considerations that can reduce the likelihood and overall impact of a successful supply chain attack”&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;  The CNCF, Linux Foundation, VMware, Intel, Google, and others are also working on &lt;a href="https://slsa.dev/"&gt;SLSA – Supply-chain Levels for Software Artifacts&lt;/a&gt;, &lt;strong&gt;a security framework, and a common language for increasing levels of software security and supply chain integrity&lt;/strong&gt; for anyone working with the software. Each level provides an increasing degree of confidence, a way to say that software hasn’t been tampered with and can be securely traced back to its source.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Kubernetes and containers&lt;/strong&gt; are so common nowadays that NSA/CISA also released a &lt;a href="https://kubernetes.io/blog/2021/10/05/nsa-cisa-kubernetes-hardening-guidance/"&gt;Kubernetes Hardening Guidance&lt;/a&gt;, highlighting “Supply chain risks” as one of three sources of compromises, and proposing the following hardening measures and mitigations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://sysdig.com/blog/vulnerability-assessment/"&gt;Scan containers and Pods for vulnerabilities&lt;/a&gt; or misconfigurations.&lt;/li&gt;
&lt;li&gt;  Run containers and Pods with &lt;a href="https://sysdig.com/blog/dockerfile-best-practices/"&gt;the least privileges possible&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;  Use &lt;a href="https://sysdig.com/blog/kubernetes-native-network-security/"&gt;network separation&lt;/a&gt; to control the amount of damage a compromise can cause.&lt;/li&gt;
&lt;li&gt;  Use firewalls to limit unneeded network connectivity and encryption to protect confidentiality.&lt;/li&gt;
&lt;li&gt;  Use strong authentication and authorization to limit user and administrator access, as well as to limit the attack surface.&lt;/li&gt;
&lt;li&gt;  Use &lt;a href="https://sysdig.com/blog/kubernetes-audit-log-falco/"&gt;log auditing&lt;/a&gt; so that administrators can monitor activity and be alerted to potential malicious activity. Our blog post, &lt;em&gt;&lt;a href="https://sysdig.com/blog/chainging-the-game/"&gt;“Chain”ging the Game – how runtime makes your supply chain even more secure&lt;/a&gt;&lt;/em&gt;, provides nice examples of runtime threat detection.&lt;/li&gt;
&lt;li&gt;  Periodically review all &lt;a href="https://sysdig.com/resources/ebooks/kubernetes-security-guide/?utm_source=google&amp;amp;utm_medium=cpc&amp;amp;utm_campaign=10874493558&amp;amp;adgroupid=106662564883&amp;amp;utm_content=473221742796&amp;amp;utm_term=kubernetes%20security%20guide&amp;amp;utm_position=&amp;amp;utm_device=c&amp;amp;utm_type=p&amp;amp;utm_geo=1005548&amp;amp;gclid=CjwKCAjwiY6MBhBqEiwARFSCPjkuPpEEomi18FV_-9zMsCB3TCsfwsijNc53AnVZ72P5nEfRLYvbJhoC1X4QAvD_BwE"&gt;Kubernetes settings&lt;/a&gt; and use vulnerability scans to help ensure risks are appropriately accounted for and security patches are applied.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Your software is the input to other companies or users
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://sysdig.com/wp-content/uploads/SupplyChain-12.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JyfabZJT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://sysdig.com/wp-content/uploads/SupplyChain-12.png" alt="" width="880" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Everything you apply when choosing your best providers with a high level of confidence will apply to your company when acting as a supplier for other companies or for end-users. Even if you correctly implement security into every step and process of your software supply chain life cycle, you still need to manifest it and add specific measures to the delivered artifacts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Provide evidence of regulatory compliance and security certifications within your organization that applies to the software supply chain.&lt;/li&gt;
&lt;li&gt;  Add a Software Bill of Materials (SBOM) as a way to track dependencies and third-party sources of compromise in your software.&lt;/li&gt;
&lt;li&gt;  Include digital signatures to prevent tampering and verify the source of your artifacts.&lt;/li&gt;
&lt;li&gt;  Use safe distribution channels, encrypted communications, and trusted hosting or storage infrastructure.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Software supply chain attacks are not really something recent. Ken Thompson, after receiving the Turing Award with Dennis Ritchie in 1984, &lt;a href="https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_ReflectionsonTrustingTrust.pdf"&gt;wrote this speech about the importance of trust in the [code] providers&lt;/a&gt;. He shows how a trojanized version of the compiler binary produces modified versions of the “login” Unix command with a backdoor.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“To what extent should one trust a statement that a program is free of Trojan horses? Perhaps it is more important to trust the people who wrote the software.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;But the ever-growing complexity of software, infrastructure, and dependencies, and the rate of growth of attacks targeting the supply chain, are making industries and organizations more and more concerned about its security.&lt;/p&gt;

&lt;p&gt;At this point, you already noticed that the software supply chain is a very complex network of interconnected and heterogeneous pieces, from code and libraries to hardware components. So the approach for securing every single piece and link is very different and cannot be covered as a whole. But, whether you are a supplier or a consumer (or both), you need to put the focus on &lt;strong&gt;securing your processes&lt;/strong&gt; and establishing &lt;strong&gt;strong connections with trusted and verified providers&lt;/strong&gt;. Because even if you apply the best security practices and put all efforts in your own code, infrastructure, etc., you still depend on third-party components completely outside of your control. And the &lt;strong&gt;security of the software supply chain&lt;/strong&gt; &lt;strong&gt;depends on every individual link&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>security</category>
      <category>supplychain</category>
      <category>devops</category>
      <category>software</category>
    </item>
  </channel>
</rss>
