OWAST Top 10 vulnerabilities and how to approach them
Tags: security, webdev, datascience
Published: 2022-09-08 18:30:58

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">Shipping reliable and secure applications is vital for today’s organizations. Adopting security recommendation frameworks helps structure and systematize how you build software. OWASP Top 10 is one of those frameworks, being a widely adopted standard for software security.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">Using the right tools also helps secure your code. For example, static analysis tools provide adaptive, real-time protection against web applications' most sophisticated threats.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">So keep reading to learn about OWASP Top 10 and how a tool like Codacy can help.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="h-what-is-owasp"><strong>What is OWASP?</strong></h1>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">The Open Web Application Security Project (OWASP) is a nonprofit foundation dedicated to improving software security. It operates under an open community ideal where anyone can contribute to projects, events, online discussions, and other activities.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">This community works to create freely-available resources, including articles, videos, forums, events, documentation, methodologies, tools, and technologies. OWASP is not affiliated with any technology organization so they can provide high-quality information without bias.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="h-what-is-owasp-top-10"><strong>What is OWASP Top 10?</strong></h1>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">The OWASP Top 10 list is a recommendation framework maintained by OWASP since 2003. Security experts worldwide achieve a consensus to create the list, which is periodically updated to adjust to changes in application security.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">The vulnerabilities are classified based on the frequency of security defects, their severity, and the extent of their potential impact. The list's purpose is to provide actionable recommendations and serve as a security checklist that helps your organization write more secure code.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="h-owasp-top-10-vulnerabilities"><strong>OWASP Top 10 vulnerabilities</strong></h1>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">Let’s dive deeper into the Top 10 vulnerabilities of the latest 2021 report (we covered the 2017 report in a <a href="https://blog.codacy.com/code-security-vulnerabilities/" target="_blank" rel="noreferrer noopener">previous article</a>).</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="h-a01-broken-access-control"><strong>A01 Broken Access Control</strong></h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Description:</strong> <a href="https://owasp.org/Top10/A01_2021-Broken_Access_Control/" target="_blank" rel="noreferrer noopener">Broken access control</a> happens when a user can gain privileged access due to a faulty access control system. For example, an attacker can gain access to user accounts or behave as a different user, or regular users can access privileged functions.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Solution:</strong> The best way to model an access control system is to deny everything by default, except for public resources, and only give access if needed. An Interactive Application Security Testing (IAST) tool can also help you detect cross-site request forgery or insecure storage of sensitive data. Finally, penetration testing can supplement IAST, helping catch unintended access controls.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="h-a02-cryptographic-failures"><strong>A02 Cryptographic Failures</strong></h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Description:</strong> <a href="https://owasp.org/Top10/A02_2021-Cryptographic_Failures/" target="_blank" rel="noreferrer noopener">Cryptographic failures</a> happen when a lack of cryptography causes sensitive data to be compromised. Sensitive data include passwords, credit card numbers, or medical records. Thus, you must ensure data is always encrypted, and you’re not using weak or outdated cryptographic algorithms.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Solution:</strong> Store passwords using adaptive and salted hashing functions to ensure that users' passwords are not compromised even if there’s a database breach. You can also implement a secrets management system to store and rotate credentials. In addition, SAST tools can provide snapshots at the code and component level, but supplementing with IAST is crucial for continuous monitoring.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="h-a03-injection"><strong>A03 Injection</strong></h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Description:</strong> <a href="https://owasp.org/Top10/A03_2021-Injection/" target="_blank" rel="noreferrer noopener">Injection</a> happens when an attacker sends invalid data into an application to make it do something it was not supposed to do. SQL injection is a dominant flaw caused by using unsanitized user data to build dynamic database queries. Cross-site scripting is another common risk.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Solution:</strong> To prevent injections, keep data separate from queries. Use Object Relational Mapping, but remember that performance degradation might be a trade-off. Don’t trust any user input and validate it every time. Finally, including SAST and IAST tools in your CI/CD pipeline helps identify injection flaws.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="h-a04-insecure-design"><strong>A04 Insecure Design</strong></h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Description:</strong> <a href="https://owasp.org/Top10/A04_2021-Insecure_Design/" target="_blank" rel="noreferrer noopener">Insecure design</a> happens when there are design and architectural flaws. Some applications don’t have security considerations in the first place, while others have implementation problems that can lead to exploitable security flaws. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Solution:</strong> You should consider security principles from the beginning of the design process of your application. Assuming malicious intent from the start can help prevent many issues that would be hard to fix when the application is shipped. Plus, IAST tools can further help detect vulnerabilities.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="h-a05-security-misconfiguration"><strong>A05 Security Misconfiguration</strong></h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Description:</strong> <a href="https://owasp.org/Top10/A05_2021-Security_Misconfiguration/" target="_blank" rel="noreferrer noopener">Security misconfiguration</a> happens when you do not configure your application correctly, leaving security weaknesses. Misconfigurations can include having a default account with the original password, enabling unnecessary features, or error handling showing stack traces to users.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Solution:</strong> You can mitigate misconfigurations by investing in a repeatable process across the application stack. Removing unnecessary components and dependencies reduces the area for an attack. In addition, SAST tools can identify the information exposure available through an error message. Finally, IAST tools can detect information disclosure and inappropriate HTTP header configurations.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="h-a06-vulnerable-and-outdated-components"><strong>A06 Vulnerable and Outdated Components</strong></h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Description:</strong> <a href="https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/" target="_blank" rel="noreferrer noopener">Vulnerable and outdated components</a> happen when you build applications using obsolete components or third-party software. You should first learn about any application's core components, versions, and last update. Components usually run with the same privileges as the application, so any component's flaws can profoundly impact your security.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Solution:</strong> To mitigate this risk, periodically remove unused third-party dependencies and create an upgrade plan for valuable dependencies. You can use software composition analysis (SCA) tools alongside SAST and IAST to identify and detect outdated and insecure components. Additionally, a culture where developers triage third-party dependencies regularly can also help.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="h-a07-identification-and-authentication-failures"><strong>A07 Identification and Authentication Failures</strong></h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Description:</strong> <a href="https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/" target="_blank" rel="noreferrer noopener">Identification and authentication failures</a> happen when you don’t correctly implement your application’s authentication or session management. Attackers can compromise passwords, keywords, and sessions, allowing them to access any account, steal user identity, and control the system completely. So, validating user identities and setting up secure session management is vital.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Solution:</strong> Automatically check passwords against a list of common passwords before allowing users to set them. Implementing multi-factor authentication can prevent attacks. Plus, SAST is instrumental in identifying broken authentication vulnerabilities. IAST tools can also detect hardcoded passwords and improper authentication.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="h-a08-software-and-data-integrity-failures"><strong>A08 Software and Data Integrity Failures</strong></h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Description:</strong> <a href="https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/" target="_blank" rel="noreferrer noopener">Software and data integrity failures</a> happen when you make assumptions about software updates and critical data without verifying integrity. For example, if your application relies on third-party packages you downloaded from untrusted sources, you become vulnerable to malicious code injection.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Solution:</strong> Always use signature verification when installing third-party dependencies and only use trusted sources. All new packages added to a project must go through a mandatory manual code review process. Plus, SAST and IAST tools check for unsafe deserialization and help detect insecure redirects or tampering with token access algorithms.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="h-a09-security-logging-and-monitoring-failures"><strong>A09 Security Logging and Monitoring Failures</strong></h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Description:</strong> <a href="https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/" target="_blank" rel="noreferrer noopener">Security logging and monitoring failures</a> happen when the application fails to detect and respond to security threats. The lack of logs or alerting mechanisms in case of an anomaly makes the system vulnerable to attackers, who quietly compromise the system without anyone noticing.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Solution:</strong> Logs are the primary source of information when something goes wrong. So you should frequently perform logging and monitoring activities to help you detect breaches and take corrective action on time. In addition, some SAST and IAST tools can help identify unlogged security exceptions.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="h-a10-server-side-request-forgery-ssrf"><strong>A10 Server-side Request Forgery (SSRF)</strong></h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Description:</strong> <a href="https://owasp.org/Top10/A10_2021-Server-Side_Request_Forgery_%28SSRF%29/" target="_blank" rel="noreferrer noopener">Server-side request forgery</a> happens when a web application fetches a remote resource without validating the user-supplied URL. An attacker can make the application send a request to an unexpected destination. Even if you protect your system with a firewall, VPN, or network access control, SSRF can happen.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><strong>Solution:</strong> A good rule for firewall policies and network access controls is to deny by default. In the application layer, all user input should be sanitized and validated. IAST tools can track, monitor, and detect SSRF without additional scanning and triaging.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1 id="h-static-code-analysis-for-security-how-can-codacy-help"><strong>Static code analysis for security: how can Codacy help</strong></h1>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify"><a href="https://www.codacy.com/product?utm_source=blog&amp;utm_medium=website&amp;utm_campaign=owasp" target="_blank" rel="noreferrer noopener">Codacy</a> is an automated code review tool that includes SAST to find security problems in your source code. It analyzes your entire codebase to check for any potential security vulnerabilities.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">Codacy uses an early feedback system that alerts you as soon as it finds potential security risks in the code. As such, it helps your team write high-quality code that isn’t susceptible to security risks. In addition, Codacy integrates directly with your workflow, helping you save time reviewing code yourself.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">To help you verify the current security levels of your code, Codacy also features a security monitor, which will outline the security status of each of your repositories and warns you if you have any security code patterns turned off.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">The security monitor will also alert you as soon as it identifies any potential problem, which should take a load off your mind when developing future projects.  Check out <a href="https://docs.codacy.com/repositories/security-monitor/" target="_blank" rel="noreferrer noopener">our documentation</a> if you have any questions.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":6376,"sizeSlug":"large","linkDestination":"none","tdCaptionAlign":"https://blog.codacy.com/wp-content/uploads/2022/08/Codacy-security-monitor.png"} -->
<figure class="wp-block-image aligncenter size-large td-caption-align-https://blog.codacy.com/wp-content/uploads/2022/08/Codacy-security-monitor.png"><img src="https://blog.codacy.com/wp-content/uploads/2022/08/Codacy-security-monitor-1024x581.png" alt="Codacy security monitor" class="wp-image-6376"/><figcaption class="wp-element-caption">Codacy security monitor</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">While Codacy is in no way a comprehensive security system on its own, its usage can bring you and your team valuable guidance. A tool like Codacy will save you time by automatically analyzing vulnerabilities within your codebase and providing insights and an overview of all current security alerts.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">At Codacy, we understand that it’s crucial to have high-security standards, and that’s why we follow security best practices such as the OWASP Top 10 and SANS Top 25.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":1} -->
<h1><strong>Conclusion</strong></h1>
<!-- /wp:heading -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">The OWASP Top 10 list provides an excellent actionable framework to ensure your applications are safe against common security threats.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">Implementing a static analysis tool like Codacy helps automate the detection of specific vulnerabilities for each threat while you are still writing and reviewing the code. Plus, enabling developers to ensure source code security early on helps you embrace <a href="https://blog.codacy.com/what-is-devsecops/" target="_blank" rel="noreferrer noopener">the core principles of DevSecOps and shift left</a>.</p>
<!-- /wp:paragraph -->