fbpx

How Amazon CodeGuru Security helps you effectively balance security and velocity

{ { Designers | Programmers | Builders} write { script | password}, review it, create artifacts, and install the { software | program} as part of the well-established software development process. | Developers write { script | password}, review it, create { relics | objects}, and { install | build} the { software | program} as part of a well-established software development process. | Developers write { script | password}, review it, create artifacts, and install the { software | program} as part of a well-established process for creating { application | program | applications}. } { { Therefore | Finally}, in order to enhance the password, they use data to { check | observe | track} the { software | program | app}. | To enhance the password, they { subsequently | therefore | finally} use { information | statistics} to { screen | check | observe | track} the { software | program | app | implementation}. | In order to enhance the password, they { subsequently | therefore | finally} use { information | statistics} to { screen | check | observe | track} the { software | program | app | implementation}. } { This procedure is frequently carried out repeatedly. | This procedure is frequently done repeatedly. | This procedure is frequently repeated numerous times. } { Customers of Amazon Web Services( AWS ) who adopt contemporary software development practices occasionally encounter difficulties when using third-party code security tools, such as an overwhelming number of findings, high rates of false positives among those findings and the logistics of tracking open issues across code versions. | Customers of Amazon Web Services( AWS ) who adopt contemporary software development practices occasionally encounter difficulties when using third-party code security tools, such as an overwhelming number of findings, high rates of false positives among those findings in the process, and the logistics of tracking open issues across code versions. | Customers of Amazon Web Services( AWS ) who adopt contemporary software development practices occasionally encounter difficulties when using third-party code security tools, such as an overwhelming number of findings, high rates of false positives among those findings and the logistics of tracking open issues among code versions. }

 <p>Customers tell us they need help to identify the top risks in their application code as it is being built and to receive actionable recommendations to mitigate these risks. In this blog post, we demonstrate how the new <a href="https://aws.amazon.com/codeguru/" target="_blank" rel="noopener">Amazon CodeGuru Security</a> service and its fully managed, machine learning (ML)-powered code security analysis capabilities provide intelligent recommendations to improve code security and quality. Amazon CodeGuru Security enhances the overall security posture of applications that are deployed in your environment while reducing the time to deploy in production.</p> <p>Amazon CodeGuru Security is a managed static application security tool (SAST) service that is also available through <a href="https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/welcome.html" target="_blank" rel="noopener">Amazon CodeGuru Reviewer</a>, <a href="https://aws.amazon.com/codewhisperer/" target="_blank" rel="noopener">Amazon CodeWhisperer</a> security scanning, the <a href="https://aws.amazon.com/sagemaker/studio/" target="_blank" rel="noopener">Amazon SageMaker Studio</a> CodeGuru extension, and <a href="https://aws.amazon.com/inspector/" target="_blank" rel="noopener">Amazon Inspecto</a>r code scanning.</p> <h2>Solution overview</h2> <p>In this blog post, we introduce you to the features and capabilities of Amazon CodeGuru Security. Amazon CodeGuru Security helps you focus on security risks that are relevant to your environment, along with contextually relevant remediation suggestions (provided as code diffs). Integration, centralization, and scalability of the service are facilitated by using an API-based design, plus bug tracking to automatically detect code fixes and close findings without user intervention. Amazon CodeGuru Security currently supports applications that are written in Python, Java, and JavaScript, along with associated artifacts like scripts, configuration, and documentation files.</p> <p>Created to improve the security posture of applications that were built for the cloud, Amazon CodeGuru Security rules are developed in partnership with Amazon application security teams, applying learnings and adhering to best practices that govern the development of Amazon internal systems and services.</p> <p>Amazon CodeGuru Security offers multiple integration points:</p> <p>In Figure 1, you can see one of the proposed architecture patterns that supports the integration of Amazon CodeGuru Security into your existing application deployment pipeline. In this scenario, developers write application code and get it committed into <a href="https://aws.amazon.com/codecommit/" target="_blank" rel="noopener">Amazon CodeCommit</a>. This event causes <a href="https://aws.amazon.com/codebuild/" target="_blank" rel="noopener">AWS CodeBuild</a> to start building the application and the static security code analysis of the application code, using a pre-build hook. The code and build artifacts are copied to a local Amazon S3 bucket within your account, and Amazon CodeGuru Security scans the application assets.</p> <div id="attachment_30238" class="wp-caption aligncenter"> <img aria-describedby="caption-attachment-30238" src="https://www.infracom.com.sg/wp-content/uploads/2023/07/img1-1.jpg" alt="Figure 1: Example of CodeGuru Security integration with deployment pipeline" width="780" class="size-full wp-image-30238"> <p id="caption-attachment-30238" class="wp-caption-text">Figure 1: Example of CodeGuru Security integration with deployment pipeline</p> </div> <h2>Amazon CodeGuru detection engine</h2> <p>At the core of the CodeGuru detector design is the idea of user action in response to findings. Detectors flag security risks or quality issues with a high degree of precision, such that action can be taken directly to remediate the finding. With this goal in mind, we have designed the <a href="https://www.amazon.science/publications/static-analysis-for-aws-best-practices-in-python-code" target="_blank" rel="noopener">Guru Query Language (GQL) toolkit</a>. GQL enables precise expression of scenario-centric micro-analyzers that check specific properties (for example, misuse of a particular Java cryptography library or API) through a wide range of analysis constructs (more than 200 at the time of publication).</p> <p>Among these constructs are capabilities such as <em>type inference</em> (determining the precise types of variables and fields), <em>inter-procedural analysis</em> (analyzing across function boundaries), and advanced <em>taint tracking</em> capabilities, where untrusted data (from <em>taint sources</em>) is tracked through the application to determine whether it reaches security-sensitive operations (known as <em>taint sinks</em>) without being sanitized. </p> <p>By using GQL, the rule author can combine constructs as building blocks to precisely match the vulnerable patterns that are being targeted. As an example, you can specify taint sources and sinks in a contextual way so that only data read from remote (as opposed to local) files is considered untrusted.</p> <p>We benchmark detectors against ever-growing datasets, and improve them based on feedback from our partner security teams and customers, as well as metrics that we collect. Detectors are subjected to a rigorous quality control process. Starting from the detector specification, we work closely with subject matter experts (SMEs) to make sure that the suggestions cover the most important application surfaces and are not overly defensive in the warnings they raise. Moving from specification to implementation, detections are reviewed and sampled from shadow runs on live codebases with the same SMEs as well as internal CodeGuru users. If detectors meet an internal performance bar, they are launched internally at AWS. After they are launched, the detectors are monitored by using weekly metrics. A detector graduates into the commercial CodeGuru service only if it meets a high quality bar for several weeks.</p> <p>Amazon CodeGuru Security uses a detection engine to find security issues in the application code that is scanned. The engine uses a <a href="https://docs.aws.amazon.com/codeguru/detector-library/" target="_blank" rel="noopener">Detector Library</a>, which is a resource that contains detailed information about the CodeGuru security and code quality detectors, to help you build secure and efficient applications. Each detection page within the Detector Library contains descriptions, compliant and non-compliant example code snippets, severities, and additional information that helps you mitigate risks (such as <a href="https://cwe.mitre.org/index.html" target="_blank" rel="noopener">Common Weakness Enumeration (CWE) numbers</a>). The materials presented in the Amazon CodeGuru Detector Library are intended to be a high-level summary of the service’s capabilities, but might not be inclusive of all detectors or their functionality.</p> <h2>Bug Fix Tracking and code fixes</h2> <p>With user action as the ultimate goal, an important metric to us is whether code fixes are made in response to our recommendations. As such, AWS has designed a novel Bug Fix Tracking (BFT) algorithm, whose key functionality is to relate CodeGuru findings across revisions of a given codebase or application. If, for example, CodeGuru reports misuse of a cryptographic API on version <em>V1</em> of codebase <em>C</em>, then BFT detects whether that misuse issue is still present when version <em>V2</em> of <em>C</em> is scanned.</p> <p>Tracking bugs and bug fixes are nontrivial. Code can be refactored into different locations within a file, and sometimes also into different files. In addition, syntax may be adjusted in ways that are orthogonal to fixing an issue (for example, if variables are renamed). The CodeGuru BFT algorithm constructs a bi-partite graph to relate a pair of findings across revisions, or otherwise declare a finding as either closed (no match in <em>V2</em>) or new (no match in <em>V1</em>).</p> <p>Figure 2 shows the process that is used by BFT in tracking application bugs. After the application version being scanned is identified and the bug detection verification starts, BFT updates the database with its findings, validating the existing issues with findings uncovered in version <em>N-1</em>.</p> <div id="attachment_30239" class="wp-caption aligncenter"> <img aria-describedby="caption-attachment-30239" src="https://www.infracom.com.sg/wp-content/uploads/2023/07/img2-1.jpg" alt="Figure 2: Overview of the Bug Fix Tracking algorithm" width="780" class="size-full wp-image-30239"> <p id="caption-attachment-30239" class="wp-caption-text">Figure 2: Overview of the Bug Fix Tracking algorithm</p> </div> <p>The algorithm is staged, starting from the simple case of 1:1 correspondence between findings, through cases where findings might have drifted to a new location but are otherwise the same. For the final, most complex scenario of fuzzy matching, we use advanced hashing techniques to establish the mapping.</p> <p>BFT provides a metric that guides our own rule development and tuning process on an ongoing basis. Data about BFT findings is available to our customers through the CodeGuru Security API. With gathered data about fixes, security engineers and leaders can measure exposure to security risks, quantify the lifetime of high and critical security issues, monitor burn rate for security issues, and form other insights from the raw data.</p> <h2>Actionable recommendations and concrete remediation</h2> <p>To align with our goal of encouraging user action in response to our recommendations, we’ve added a feature powered by automated reasoning for including concrete remediation advice as part of CodeGuru recommendations. This comes in the form of a code diff, which you can apply mechanically by using standard utilities like <code>patch</code>.</p> <p>The screenshot in Figure 3 shows how this functionality creates an important bridge between security engineers and software engineers—the former have the necessary security expertise, while the latter are often responsible for carrying out the code fix. Recommendations that are accompanied by concrete fix suggestions can cut through multiple correspondences, alignment issues, and validation cycles, which can help accelerate remediation.</p> <div id="attachment_30240" class="wp-caption aligncenter"> <img aria-describedby="caption-attachment-30240" src="https://www.infracom.com.sg/wp-content/uploads/2023/07/img3-1.jpg" alt="Figure 3: Example of recommendation showing difference between compliant and non-compliant code" width="780" class="size-full wp-image-30240"> <p id="caption-attachment-30240" class="wp-caption-text">Figure 3: Example of recommendation showing difference between compliant and non-compliant code</p> </div> <p>To enable the reasoning illustrated in Figure 3, where the data reaching the <span>addObject</span> call goes through sanitization in the form of an <span>HtmlUtils::htmlEscape</span> call, the underlying algorithm performs several steps. First, a formal representation of the code, known as its Abstract Syntax Tree (AST), is constructed. The AST is then visited by one or more transformation “recipes,” whose goal is to manipulate the program such that the vulnerability is mitigated.</p> <p>Code transformation is done in a contextual manner, so that syntax (for example, variable names) and formatting (for example, indentation levels) are preserved. To verify that the transformation is valid, the algorithm further runs post-processing checks on the resulting code structure and syntax.</p> <p>An important refinement of the remediation capability is that Amazon CodeGuru Security performs pre-analysis ahead of running the security scan to classify code artifacts into application- versus library-dependencies. It’s more feasible to take action on a recommendation for code owned by you, compared to code in a third-party library. The classification algorithm has been trained on hundreds of thousands of open-source libraries to disassemble code artifacts, including bundling application and library content in the same file, and focus downstream analysis on the most pertinent scanning surfaces.</p> <p>Critical security issues have been shown to sometimes take hundreds of days to address (<a href="https://securityintelligence.com/news/news-vulnerabilities-25-days-remediate" target="_blank" rel="noopener">as discussed in this study</a>). Internal studies that look at use of CodeGuru have seen a steep drop in time to fix issues thanks to concrete fix suggestions, which is value that the service excited to share with you.</p> <h2>Conclusion</h2> <p>Amazon CodeGuru Security is a static application security testing (SAST) tool that combines ML and automated reasoning to identify security issues in your code. Amazon CodeGuru detection capabilities that use GQL (Guru Query Language), Bug Fix Tracking (BFT), and efficacy mechanisms and AppSec expertise can help you precisely identify code security issues with a low rate of false positives. High signal-to-noise ratio is a key enabler in integrating SAST into the daily work of security engineers and software developers.</p> <p>In addition, Amazon CodeGuru Security provides thorough fix recommendations, which your development teams can use to improve the overall time to remediate application security issues. At the same time, the recommendations can help you to implement security best practices based on an ML model that was trained on millions of lines of code and vulnerability assessments performed within Amazon. <a href="https://aws.amazon.com/codeguru/" target="_blank" rel="noopener">Get started with Amazon CodeGuru Security</a>.</p> <p> <br>If you have feedback about this post, submit comments in the<strong> Comments</strong> section below. If you have questions about this post, <a href="https://console.aws.amazon.com/support/home" target="_blank" rel="noopener noreferrer">contact AWS Support</a>.</p> <p><strong>Want more AWS Security news? Follow us on <a title="Twitter" href="https://twitter.com/AWSsecurityinfo" target="_blank" rel="noopener noreferrer">Twitter</a>.</strong></p> <!-- '"` -->