<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Johannes Späth</title>
    <description>The latest articles on Forem by Johannes Späth (@johspaeth).</description>
    <link>https://forem.com/johspaeth</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%2F494838%2Fdcbe8482-b8d0-44d2-ab6a-74b37b6a3e02.jpeg</url>
      <title>Forem: Johannes Späth</title>
      <link>https://forem.com/johspaeth</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/johspaeth"/>
    <language>en</language>
    <item>
      <title>Is your AWS Account vulnerable to the newest attack presented at Black Hat 2021?</title>
      <dc:creator>Johannes Späth</dc:creator>
      <pubDate>Wed, 01 Sep 2021 16:54:33 +0000</pubDate>
      <link>https://forem.com/aws-builders/is-your-aws-account-vulnerable-to-the-newest-attack-presented-at-black-hat-2021-2dg9</link>
      <guid>https://forem.com/aws-builders/is-your-aws-account-vulnerable-to-the-newest-attack-presented-at-black-hat-2021-2dg9</guid>
      <description>&lt;h4&gt;
  
  
  Running confused deputy attacks exploiting the AWS Serverless Application Repository
&lt;/h4&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu05pubkkit1o8m25f15b.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu05pubkkit1o8m25f15b.png" alt="Confused deputy attack on AWS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Early this month at &lt;em&gt;Black Hat USA 2021&lt;/em&gt;, researchers from &lt;em&gt;Wiz.io&lt;/em&gt; &lt;a href="https://www.blackhat.com/us-21/briefings/schedule/index.html#breaking-the-isolation-cross-account-aws-vulnerabilities-22945" rel="noopener noreferrer"&gt;presented&lt;/a&gt; a new &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html" rel="noopener noreferrer"&gt;confused deputy attack&lt;/a&gt; that allows an attacker to access data within your AWS account. Using to coarsely set IAM permissions when publishing an application within the AWS Serverless Application Repository (SAR), an attacker can acquire arbitrary data from the S3 bucket that is used for hosting the application's artifacts. In this article, we explain the vulnerability, showcase an actual exploit and explain how to fix the vulnerability in your account. If you are publishing an application using SAR, we recommend double-checking your permissions.&lt;/p&gt;

&lt;p&gt;SAR is a platform that allows developers to publish and share &lt;a href="https://aws.amazon.com/serverless/sam/" rel="noopener noreferrer"&gt;SAM&lt;/a&gt; applications across AWS accounts. These applications can then be deployed standalone or &lt;a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-nested-applications.html" rel="noopener noreferrer"&gt;easily be integrated into existing SAM applications&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Publishing an application to SAR is &lt;a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-publishing-applications.html#serverless-sam-template-publishing-applications-prerequisites" rel="noopener noreferrer"&gt;straightforward&lt;/a&gt;. As an author, one has to pack the underlying application code, templates, license, and readme files in a S3 bucket, create an entry in the SAR and attach a policy to the bucket that grants SAR access to the bucket.&lt;/p&gt;

&lt;p&gt;The S3 policy allows SAR to read all objects stored in the specified S3 bucket. In their documentation, AWS initially proposed to attach the following IAM policy to the bucket:&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": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service":  "serverlessrepo.amazonaws.com"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::&amp;lt;your-bucket-name&amp;gt;/*",
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What's the problem with this policy? It does not restrict the account on which's behalf SAR is allowed to access the bucket! While no account other than the owner of the SAR application can actually change the application's setup in SAR, every account can exploit SAR to query objects and data from an S3 bucket with such a &lt;code&gt;BucketPolicy&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This allows attackers to extract sensitive data like source code, hardcoded credentials, or configuration files that were never meant to be accessible by others. Even worse, if the bucket is used for more than hosting the packed SAR application, which, by the way, is an antipattern itself, attackers can acquire this data too!&lt;/p&gt;




&lt;h3&gt;
  
  
  Exploiting the Vulnerability
&lt;/h3&gt;

&lt;p&gt;To showcase the exploit, we prepared a SAR application setup of our &lt;a href="https://github.com/CodeShield-Security/Serverless-Goat-Java/tree/master/sar" rel="noopener noreferrer"&gt;Serverless-Goat-Java&lt;/a&gt; implementation. Serverless-Goat was &lt;a href="https://github.com/OWASP/Serverless-Goat" rel="noopener noreferrer"&gt;originally developed&lt;/a&gt; in JavaScript by OWASP and is an intentionally vulnerable serverless application. We &lt;a href="https://serverlessrepo.aws.amazon.com/applications/eu-central-1/028938425188/Serverless-Goat-Java" rel="noopener noreferrer"&gt;published&lt;/a&gt; Serverless-Goat-Java into the AWS SAR for security training purposes.&lt;/p&gt;

&lt;p&gt;With the following template, we deploy an AWS CloudFormation stack with the required bucket and policy to host a SAR app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Resources:
  ServerlessGoatPackages:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: "serverless-goat-packages"

  ServerlessGoatPackagesPolicy:
    Type: 'AWS::S3::BucketPolicy'
    Properties:
      Bucket: !Ref ServerlessGoatPackages
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Sid: ServerlessRepoAccess
            Action:
              - 's3:GetObject'
            Effect: Allow
            Resource: !Sub "arn:aws:s3:::${ServerlessGoatPackages}/*"
            Principal: 
              Service: "serverlessrepo.amazonaws.com"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Afterward, we pack our Serverless-Goat-Java application, upload it into the newly created bucket, and create a new SAR application in the SAR. &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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F32wo5484orxwo9nffgjf.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F32wo5484orxwo9nffgjf.png" alt="AWS Serverless Goat"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the application is bound to the account &lt;code&gt;028938425188&lt;/code&gt; and can only be modified by it. Let's call the account hosting the vulnerable app &lt;code&gt;Alice&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To test our exploit, we need another SAR application in a different account on which's behalf we can query objects from our ill-configured bucket. Let's call it account &lt;code&gt;Eve&lt;/code&gt;. For the sake of ease, we just deployed Serverless-Goat-Java again, but to account &lt;code&gt;Eve&lt;/code&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3tdabwk016iys6gyo856.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3tdabwk016iys6gyo856.png" alt="Serverless Goat Java deployed on Eve's Account"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Let’s see how we can exploit it!
&lt;/h4&gt;

&lt;p&gt;Now that our setup is complete, we can try to use SAR to query data from account &lt;code&gt;Alice&lt;/code&gt;'s bucket and set it as a configuration for account &lt;code&gt;Eve&lt;/code&gt;'s SAR app. &lt;/p&gt;

&lt;p&gt;Therefore, we instruct SAR to set the Readme file of account &lt;code&gt;Eve&lt;/code&gt;'s app to an arbitrary file from account &lt;code&gt;Alice&lt;/code&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4nlnq26spkvkzjhbuxsu.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4nlnq26spkvkzjhbuxsu.png" alt="Accessing an unintended file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looking again at the app in the SAR, SAR displays the following Readme in account &lt;code&gt;Eve&lt;/code&gt;'s app:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk5rix23qz6fb8c8tspuz.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk5rix23qz6fb8c8tspuz.png" alt="The app shows the wrong file as Readme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Phew, we are evil! 😈 We just stole the authors license file! Let's try another one:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyxmm4qmohqguficry34h.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyxmm4qmohqguficry34h.png" alt="Console command to access sensitive data from S3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This time around, the acquired information is much more interesting:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Finzu5zfnuzsqrkppw6wh.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Finzu5zfnuzsqrkppw6wh.png" alt="Sensitive information leaded from S3 bucket"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, this is only dummy information for the sake of this demonstration. 😊&lt;/p&gt;

&lt;p&gt;As you saw, the exploit is very easy once you know about it. The application's ID is public, only the bucket and file names have to be guessed by an attacker. This might sound hard to do!? Well, as we all know, security by obscurity doesn't work too well, so let's strive for a proper fix!&lt;/p&gt;




&lt;h3&gt;
  
  
  Fixing the Vulnerability
&lt;/h3&gt;

&lt;p&gt;The fix is even more straightforward than the exploit! We need to make sure that our bucket used for hosting the SAR app is only accessible by the account that actually publishes the app. &lt;/p&gt;

&lt;p&gt;Therefore, we have to modify our &lt;code&gt;BucketPolicy&lt;/code&gt; to contain a &lt;code&gt;condition&lt;/code&gt; that checks the AWS account which tries to instruct SAR to access the bucket:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  SampleBucketPolicy:
    Type: 'AWS::S3::BucketPolicy'
    Properties:
      Bucket: !Ref ServerlessGoatPackages
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Sid: ServerlessRepoAccess
            Action:
              - 's3:GetObject'
            Effect: Allow
            Resource: !Sub "arn:aws:s3:::${ServerlessGoatPackages}/*"
            Principal:
              Service: "serverlessrepo.amazonaws.com"
            Condition:
              StringEquals:
                "aws:SourceAccount": "AWS::AccountId"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Indeed, AWS added the new condition expression right after the vulnerability was disclosed to them and &lt;a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-publishing-applications.html#serverless-sam-template-publishing-applications-prerequisites" rel="noopener noreferrer"&gt;updated their documentation accordingly&lt;/a&gt;. However,  owners of the SAR applications need to update their S3 bucket policies, otherwise the respective AWS accounts remaining vulnerable. &lt;/p&gt;

&lt;p&gt;After re-deploying our stack with the fixed policy, we observe the following when trying the exploit again:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi8cjjkj203s0b1gmgzrx.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi8cjjkj203s0b1gmgzrx.png" alt="Fixing the vulnerability"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Awesome! Now SAR can only modify account &lt;code&gt;Alice&lt;/code&gt;'s app on the behalf of account &lt;code&gt;Alice&lt;/code&gt;! 🛡&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note: We changed the policy back after showcasing the fix, so you can try the exploit yourself easily with our &lt;a href="https://serverlessrepo.aws.amazon.com/applications/eu-central-1/028938425188/Serverless-Goat-Java" rel="noopener noreferrer"&gt;SAR application&lt;/a&gt;!&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Fixing the vulnerability is one thing. But how to find it in the first place?
&lt;/h3&gt;

&lt;p&gt;We develop &lt;em&gt;&lt;a href="https://codeshield.io" rel="noopener noreferrer"&gt;CodeShield&lt;/a&gt;&lt;/em&gt; to help developers and security teams finding and&lt;br&gt;
fixing vulnerabilities in cloud-native applications. &lt;em&gt;CodeShield&lt;/em&gt; can also help you to find Buckets that are vulnerable to the depicted confused deputy attack in your CloudFormation stacks and template files. Check it out and &lt;a href="https://dashboard.codeshield.io?utm_source=devto&amp;amp;utm_medium=bp&amp;amp;utm_campaign=confuseddep" rel="noopener noreferrer"&gt;try CodeShield yourself&lt;/a&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2g55awqqa6c4dc26gi0.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2g55awqqa6c4dc26gi0.png" alt="CodeShield's dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stay tuned if you are using Terraform or haven't set up your SAR buckets via a CloudFormation stack.&lt;/strong&gt; We are currently extending CodeShield to be able to scan whole AWS accounts independently of stacks or templates. If you want to get notified when whole account scanning is ready, &lt;a href="mailto:info@codeshield.io?subject=Whole%20Account%20Scanning%20Request&amp;amp;body=Please%20let%20me%20know%20when%20the%20whole%20account%20scanning%20feature%20is%20ready!"&gt;drop us a mail&lt;/a&gt;!&lt;/p&gt;




&lt;h2&gt;
  
  
  About the Authors
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Manuel Benz&lt;/strong&gt; is co-founder of &lt;a href="https://codeshield.io?utm_source=devto&amp;amp;utm_medium=bp&amp;amp;utm_campaign=confuseddep" rel="noopener noreferrer"&gt;CodeShield&lt;/a&gt;, a novel context-aware cloud security tool focusing on in-depth program analysis of microservice architectures. Prior to the start-up, Manuel worked as a researcher on combinations of static and dynamic program analysis for vulnerability detection at the Secure Software Engineering group at Paderborn University. Manuel is still actively maintaining the &lt;a href="https://github.com/soot-oss/soot" rel="noopener noreferrer"&gt;Soot static program analysis framework for Java&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Johannes Späth&lt;/strong&gt; is an AWS Community Builder and a co-founder of &lt;a href="https://codeshield.io?utm_source=devto&amp;amp;utm_medium=bp&amp;amp;utm_campaign=confuseddep" rel="noopener noreferrer"&gt;CodeShield&lt;/a&gt;. Johannes completed his Ph.D. in static program analysis. In his dissertation, he invented a &lt;a href="https://github.com/CodeShield-Security/SPDS" rel="noopener noreferrer"&gt;new algorithm for data-flow analysis&lt;/a&gt; which allows automated detection of security vulnerabilities.&lt;/p&gt;

</description>
      <category>security</category>
      <category>aws</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Automated Vulnerability Prioritization in the Context of the Cloud</title>
      <dc:creator>Johannes Späth</dc:creator>
      <pubDate>Mon, 09 Aug 2021 15:09:27 +0000</pubDate>
      <link>https://forem.com/aws-builders/automated-vulnerability-prioritization-in-the-context-of-the-cloud-3eg0</link>
      <guid>https://forem.com/aws-builders/automated-vulnerability-prioritization-in-the-context-of-the-cloud-3eg0</guid>
      <description>&lt;p&gt;More and more companies are moving their workloads to the cloud - and for a good reason: it reduces the cost and the associated risk in comparison to running and maintaining the solutions themselves. Clearly, the shift to the cloud does not come for free. There are three points in particular that many companies are struggling with: &lt;em&gt;Technical complexity, maintaining security, and ensuring compliance&lt;/em&gt; (Palo Alto, The State of Cloud-Native Security 2020).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Technical complexity&lt;/em&gt; arises from the fact that “moving to the cloud” means adopting new technology and does &lt;em&gt;not&lt;/em&gt; mean deploying legacy software on resources provided by the Cloud Service Provider (CSP). To make use of the cost benefits, the software also needs to be adopted to cloud-native technologies (i.e. it should be provisioned using modern cloud-native technologies such as Kubernetes, CloudFormation, Terraform, or Serverless.) Only cloud-native technologies are able to make full use of the on-demand payment models that CSP promises. &lt;a href="https://codeshield.io/blog/2021/07/07/blogpost_iac/?utm_source=devto&amp;amp;utm_medium=bp&amp;amp;utm_campaign=prio"&gt;For more details see a post by one of my colleagues.&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this post our focus lies on the second of the abovementioned most critical challenge when moving to the cloud: &lt;em&gt;maintaining security&lt;/em&gt;. Security itself, also prior to the cloud era, has been a challenge for many companies, as expertise in the area is rare.&lt;/p&gt;

&lt;p&gt;Within the cloud security remains a challenge, as software is released even faster. With the "Shared Responsibility" security model that large cloud providers apply, part of the security responsibility is &lt;a href="https://medium.com/@ory_51733/serverless-and-the-evolution-in-cloud-security-how-faas-differs-from-iaas-4ea8bc7b1dff"&gt;taken care of by the cloud provider&lt;/a&gt;. (for instance, physical hardware security, OS, and network security). New challenges that companies need to handle are a) secure configuration of the cloud account (setting minimal IAM permissions) and b) secure application level (i.e. address CVEs in third-party libraries and vulnerabilities in the own code).&lt;/p&gt;

&lt;p&gt;Luckily, we have a large set of tools that help us detect security vulnerabilities as well as cloud misconfigurations. Unfortunately, with a large set of tools, the set of potential warnings easily reach between 100s and 1.000s that experts and developers need to navigate through and prioritize. This raises the question:&lt;/p&gt;

&lt;h2&gt;
  
  
  How do Companies Currently Prioritize Security Vulnerabilities?
&lt;/h2&gt;

&lt;p&gt;A common way to prioritize security vulnerabilities is to prioritize them based on the scores that are pre-assigned by the underlying security tools, e.g., tools that perform software composition analysis (SCA) or software application security testings (SAST). Each security issue is assigned a score, mostly following the classification of easy, medium, high, and critical. SCA tools typically report the &lt;a href="https://www.first.org/cvss/v3.1/specification-document"&gt;CVSS score&lt;/a&gt; associated with each CVE. The CVSS score is assigned by CVE Number Authorities (for instance GitHub) at the time when the vulnerability is reported. The score is assigned based on the information available to the authority at the time of the report. The score is rarely updated later on when more information is available. But this information clearly lacks &lt;em&gt;context&lt;/em&gt;: the context of your application, your business, and the impact it may have on your application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best practice for Prioritizing Security Vulnerabilities
&lt;/h2&gt;

&lt;p&gt;With 100s to 1.000s of findings that security teams have to navigate, &lt;em&gt;the severity score is only a first indication&lt;/em&gt; for prioritization. Companies have to bear in mind that severity alone does not map the &lt;em&gt;company risk&lt;/em&gt; associated with each vulnerability. The risk can clearly significantly differ from the default suggested CVSS score. Even a low severity vulnerability can have a severe impact on one’s own application. A low vulnerability may serve as an entry point for an attacker to navigate through the software.&lt;/p&gt;

&lt;p&gt;So what is the business risk associated with a vulnerability? Well, it depends…&lt;a href="https://www.advantio.com/blog/vulnerability-management-assess-prioritize"&gt;Vulnerability assessment suggests&lt;/a&gt; that the business risk of a vulnerability depends on four parameters (Figure 1):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wlsSpB7l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fx4bckrwxf4sofhf9dny.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wlsSpB7l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fx4bckrwxf4sofhf9dny.png" alt="Security Risk"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 1: Security Risk is a combination of Vulnerability Score, Threat Context, Asset Exposure, and Business Impact&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Vulnerability Severity Score:&lt;/em&gt; CVSS score given by code scanning tools (SCA, SAST,…) or other severity score provided by tools.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Threat Context:&lt;/em&gt; Additional meta-information about the vulnerability: How often has this vulnerability been exploited elsewhere? Is there an exploit publicly available? Have other companies been hacked because of this vulnerability?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Business Impact:&lt;/em&gt; Given that the vulnerability is exploited, which assets can be leaked? And what is the business value associated with these assets?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Asset Exposure:&lt;/em&gt; Is the affected component/resource containing the vulnerability publicly reachable? How complicated is it for an attacker to reach the affected resource that contains the vulnerability? &lt;/p&gt;

&lt;p&gt;The good news is that with cloud-native determining asset exposure as well as automatically estimating the business impact is possible. And here is how:&lt;/p&gt;

&lt;h2&gt;
  
  
  How can we Automatically Assess the Asset Exposure?
&lt;/h2&gt;

&lt;p&gt;By shifting to cloud-native software, infrastructure provisioning is becoming more automated and standardized in the form of Infrastructure-as-Code. Infrastructure-as-code is version-controlled alongside the application, which also means we can automatically analyze the code and derive additional application semantic from it.&lt;/p&gt;

&lt;p&gt;See the diagram below (Figure 2) which depicts a CloudFormation template of a cloud-native application visualized in the form of a data-flow diagram. Highlighted in red is one cloud resource (an AWS Lambda called OrderGetFunction) which contains a vulnerability. Additionally, you see a graph that contains potential attack paths from different APIGateway methods within the infrastructure leading to the vulnerability. All paths end in the affected resource and start in different API endpoints (AWS ApiGatewayApi resources). Given the paths, one can decide and estimate the impact the vulnerability has on your application. Is the resource externally reachable at all?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Y4XHeyuz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ey7p8boi46pz4k2u2x82.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y4XHeyuz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ey7p8boi46pz4k2u2x82.png" alt="CodeShield's Attack Path Visualization"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 2: Potential attack paths in a cloud-native application (the red node contains a vulnerability)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the given case, you can see that the affected resource containing the vulnerability is reachable via several API gateway methods. For all paths, however, there are two hops in the infrastructure necessary as there are AWS Lambda nodes inbetween. An attacker must therefore craft an exploit to reach across two resources.&lt;/p&gt;

&lt;p&gt;If you want to prioritize your security workload and automatically assess your cloud security infrastructure, at &lt;a href="https://codeshield.io?utm_source=devto&amp;amp;utm_medium=bp&amp;amp;utm_campaign=prio"&gt;CodeShield&lt;/a&gt; we are happy to help.&lt;/p&gt;

&lt;h2&gt;
  
  
  About the Author
&lt;/h2&gt;

&lt;p&gt;Johannes Späth is an AWS Community Builder and a co-founder of &lt;a href="https://codeshield.io?utm_source=devto&amp;amp;utm_medium=bp&amp;amp;utm_campaign=prio"&gt;CodeShield&lt;/a&gt;, a context-aware cloud-native security tool. CodeShield allows you to automatically visualize your cloud environment. &lt;a href="//dashboard.codeshield.io?utm_source=devto&amp;amp;utm_medium=bp&amp;amp;utm_campaign=prio"&gt;Sign up&lt;/a&gt; with GitHub to connect your AWS account. Johannes completed his Ph.D. in static program analysis. In his dissertation, he invented a &lt;a href="https://github.com/CodeShield-Security/SPDS"&gt;new algorithm for data-flow analysis&lt;/a&gt; which allows automated detection of security vulnerabilities.&lt;/p&gt;

</description>
      <category>security</category>
      <category>cloudnative</category>
      <category>cloudskills</category>
    </item>
    <item>
      <title>The Myth of False Positives in Static Application Security Testing</title>
      <dc:creator>Johannes Späth</dc:creator>
      <pubDate>Tue, 20 Oct 2020 08:55:30 +0000</pubDate>
      <link>https://forem.com/johspaeth/the-myth-of-false-positives-in-static-application-security-testing-146g</link>
      <guid>https://forem.com/johspaeth/the-myth-of-false-positives-in-static-application-security-testing-146g</guid>
      <description>&lt;p&gt;&lt;em&gt;Static application security testing tools are notorious for presenting false positives, i.e., incorrect warnings. In this article, we explain the myth behind false positives and discuss two types of false positives - and which of those future SAST tools must solve.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The idea behind Static Application Security Testing (SAST) is flawless - theoretically.&lt;/p&gt;

&lt;p&gt;SAST allows you to detect security vulnerabilities early on in the development phase. The focus lies on the word &lt;em&gt;early&lt;/em&gt;. SAST analyzes your software's source code during development - long &lt;em&gt;before&lt;/em&gt; testing, deployment and release of your software. Any vulnerability detected during development saves money during the proceeding development iterations and reduces the risk of an attack. - So far the theoretical side.&lt;/p&gt;

&lt;p&gt;Now the practical side- legacy SAST tools are notorious for presenting false positives, i.e., spurious warnings that are not actionable. Developers and security analysts using SAST tools are typically forced to wade through endless lists of warnings. They evaluate and rank the findings one-by-one - until eventually at some point, the warnings are ignored.&lt;/p&gt;

&lt;p&gt;The idea behind SAST tools is to trace data-flows along all execution paths of the program. Typically, SAST traces data-flow connections between so-called &lt;em&gt;"sources"&lt;/em&gt; (method invocations that load user input) and &lt;em&gt;"sinks"&lt;/em&gt; (method invocations that execute security critical functionality based on user input).&lt;/p&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;p&gt;SQL injection of a web application is &lt;em&gt;the&lt;/em&gt; classic textbook example. The source is typically a method that receives the GET or POST parameters of a HTTP request. In the case of the Spring Application, any controller method annotated by &lt;code&gt;@GetMapping&lt;/code&gt;, e.g.,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@GetMapping("/{userName}")
public User getUserByName(@PathVariable String username){...}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The sink is a method that executes a SQL query without properly sanitizing the parameters. For instance, the method &lt;code&gt;executeQuery&lt;/code&gt; in the code below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
String sql = "SELECT id FROM users WHERE username='" + username + "'"
Connection connection = dataSource.getConnection();
ResultSet result = c.createStatement().executeQuery(sql);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where the string variable &lt;em&gt;sql&lt;/em&gt; is a concatenated query string that contains the user input &lt;em&gt;userName&lt;/em&gt; from the request. Obviously, using the user input directly in the SQL statement renders a serious SQL injection vulnerability. This, for example, allows an attacker to circumvent the user authentication by providing a properly crafted SQL statement as &lt;em&gt;username&lt;/em&gt; input, e.g., &lt;code&gt;"'user' OR 1=1"&lt;/code&gt; which leads to the statement &lt;code&gt;"SELECT id FROM users WHERE username='user' OR 1=1'"&lt;/code&gt; being executed. No matter what the username is, due to the &lt;code&gt;"OR 1=1"&lt;/code&gt; part, the execution of the statement returns the first user of the &lt;code&gt;users&lt;/code&gt; table, which often is the administrator user.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Two Types of False Positives
&lt;/h2&gt;

&lt;p&gt;During the static analysis the analyzed program is never executed. Therefore, the analysis engine needs to model potential program behavior during execution. This includes modeling the call stack, branch conditions and execution environments (hereafter &lt;em&gt;context&lt;/em&gt;). The engine has to make (frequently conservative) assumptions about the path the data actually takes.&lt;/p&gt;

&lt;p&gt;For instance, a data-flow engine needs to decide which concrete method implementation an interface invocation resolves to at runtime, the analysis needs to argue which branch will be executed and the analysis needs to reason about code locations that are at all reachable given the execution environment.&lt;/p&gt;

&lt;p&gt;All those assumptions are encoded into the engine and lead to different types of false positives. However, we argue, there are two types of false positives: &lt;em&gt;technical&lt;/em&gt; and &lt;em&gt;contextual&lt;/em&gt; ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technical False Positives
&lt;/h2&gt;

&lt;p&gt;Technical false positives are inherited from properties of the underlying data-flow engine. Typical examples are context-sensitive, flow-sensitive, and field-sensitive analyses.&lt;br&gt;
&lt;a href="https://link.springer.com/chapter/10.1007/11688839_5"&gt;Context-sensitive analyses&lt;/a&gt; model the call stack, &lt;a href="https://www.cs.utexas.edu/~lin/papers/cgo11.pdf"&gt;flow-sensitive analyses&lt;/a&gt; model the order of control-flow and &lt;a href="https://johspaeth.github.io/publications/boomerangPDS.pdf"&gt;field-sensitive analyses&lt;/a&gt; statically model the object-oriented programming style: objects referencing other objects using (im)mutable fields or class members.&lt;br&gt;
Modern analysis engines, at least state-of-the-art research tools, address and handle all those details and are mostly false positive free - at least from a technical perspective.&lt;/p&gt;

&lt;h2&gt;
  
  
  Contextual False Positives
&lt;/h2&gt;

&lt;p&gt;However, if you speak to developers and security analysts about SAST tools, you will frequently hear them saying:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It is not possible to perform a SQL injection attack at this code location. The method will only be executed from within our own infrastructure. An attacker cannot execute this part of the program.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This command injection is a false positive. The injection is only possible if the DEBUG_MODE flag is set. In our production environment, we do not set the environment variable DEBUG_MODE and the code is never executed.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For most SAST users, none of the above mentioned technical false positives (originating from context-sensitive, flow-sensitive, field-sensitive) come directly to mind when speaking about false positives. The two false positives mentioned in the quotes above also have one thing in common, the developer and analyst know more than the data-flow engine can derive from the pure software's source code.&lt;/p&gt;

&lt;p&gt;A challenge that a next-generation SAST tool needs to cope with.&lt;/p&gt;

&lt;h2&gt;
  
  
  Contextual False Negatives
&lt;/h2&gt;

&lt;p&gt;While the world speaks about SAST solution's false positives, SAST is also prone to false negatives. However, false negatives are invisible to the user, no-one - but the attacker and, if (s)he notices the attack, your CISO- cares.&lt;/p&gt;

&lt;p&gt;A vulnerability which many SAST solutions fail to detect is a vulnerability that involves several components, for instance, a database. SAST solutions fall short on modeling data being stored in one cell of the database and being loaded at a different location within the program. If the database flow is part of a potential security vulnerability, the SAST tool will either miss the critical data-flow and not report the vulnerability, or alternatively, the tool will need to heavily over-approximate and mark every cell of the database as potentially manipulated.&lt;/p&gt;

&lt;p&gt;Analyzing data-flows across several components is an even bigger issue in today's micro-service cloud architectures, where functionality is split among multiple separate services. Due to the missing context, legacy SAST tools are no longer able to properly model data-flow between those services and, again, are prone to either miss some vulnerabilities or over-approximate heavily.&lt;/p&gt;

&lt;p&gt;Therefore, SAST tool vendors mostly decide to be "ok" with contextual false negatives. In that way, they avoid many contextual false positives wherever content of the database or data from another micro-service reaches a security-critical operation within the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  About
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Johannes Späth is a co-founder of &lt;a href="//www.codeshield.io"&gt;CodeShield&lt;/a&gt;, a novel static security testing tool focusing on in-depth program analysis of open-source dependencies. Prior to the start-up, Johannes completed his PhD in static program analysis where he designed and implemented new algorithms for data-flow and pointer analysis, analyses that are necessary for automated detection of security vulnerabilities.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
