• Browse topics
Login

Known vulnerabilities in dependencies

Making sure your dependencies are secure

Select your ecosystem

Known vulnerabilities in dependencies: the basics

What are known vulnerabilities in dependencies?

Known vulnerabilities in dependencies arise when open-source libraries or components integrated into a software application contain publicly disclosed security flaws. These vulnerabilities, often documented in resources like CVE databases, can compromise confidentiality, integrity, or availability. An attacker may exploit them to execute malicious actions, such as unauthorized access, data exfiltration, or system disruption. Examples include the infamous Log4Shell vulnerability (CVE-2021-44228) in Apache Log4j and the Equifax breach (CVE-2017-5638) caused by a flaw in Apache Struts.

About this lesson

In this lesson, you will explore how known vulnerabilities in open-source dependencies arise, how attackers exploit them, and effective measures to secure your applications. From real-world examples to mitigation strategies, you’ll gain insight into protecting your codebase from these common risks.

FUN FACT

Vulnerabilities at the heart of history

The Equifax breach in 2017, one of the most significant data breaches in history, was caused by a known vulnerability in Apache Struts (CVE-2017-5638). The breach affected the personal information of over 147 million individuals, underscoring the importance of regularly updating dependencies.

Known vulnerabilities in dependencies in action

Sofia is a backend developer who was working on a financial application. Her team used several popular open-source libraries to streamline development. While debugging an issue, she noticed unusual traffic patterns originating from her application. A closer inspection revealed a malicious actor exploiting a flaw in an outdated library version used in their project.

First, Sofia checked the application logs and identified suspicious activities targeting a specific API endpoint.

Demo terminal

She decided to run a security scanner on the project, and a known CVE in an open source library was discovered within the code base with a high severity score.

Type in snyk test in the terminal below to see the vulnerability (note, the vulnerability is of a fictitious library).

Demo terminal

Sofia verified the vulnerability allowed remote code execution under specific conditions, which the current system met. Looking at Snyk Advisor, she noticed a recommended package that is secure.

advisor

Then she updated the library to the new version and applied additional mitigations, such as restricting network access to sensitive endpoints. Keep reading below to see what this might look like in a real application.

Known vulnerabilities in dependencies under the hood

Let’s explore the mechanics of how a known vulnerability, like the one Sofia faced, could be exploited and mitigated. In this example, the vulnerability resided in a dependency used for input validation, exposing the application to a remote code execution (RCE) attack. The following sections break down the vulnerable code.

The fictitious Python application integrates a library to parse and validate data but uses a version vulnerable to injection attacks.

The library fails to escape user-provided input, enabling attackers to inject harmful commands.

Scan your code & stay secure with Snyk - for FREE!

Did you know you can use Snyk for free to verify that your code
doesn't include this or other vulnerabilities?

Scan your code

Known vulnerabilities in dependencies mitigation

How to Mitigate Known Vulnerabilities in Dependencies

To mitigate known vulnerabilities in dependencies, start by keeping them up to date and regularly reviewing changelogs and CVE disclosures. Using a security scanning tool like Snyk in your CI/CD pipeline helps detect vulnerabilities early, including those in transitive dependencies. It's also important to apply the principle of least privilege by restricting what dependencies can access, using containerization or security tools to limit potential damage. Regularly auditing and removing unused dependencies reduces unnecessary risk, while monitoring exploitability through threat intelligence sources ensures you prioritize the most critical vulnerabilities.

In the Python code, the vulnerable library has been replaced with secure_input_lib, a patched version that addresses the known vulnerabilities. Furthermore, the application adds explicit input validation to check that the input is a string, rejecting invalid data early. This prevents unexpected input types from being passed to the library, which could potentially trigger an exploit. Together, the updated library and stricter input checks significantly reduce the risk of injection or RCE attacks.

Quiz

Test your knowledge!

Quiz

What is an effective way to mitigate risks associated with known vulnerabilities in dependencies?

Keep learning

To deepen your understanding of managing and mitigating known vulnerabilities in dependencies, explore the following resources:

Congratulations

You have taken an essential step in understanding the risks associated with known vulnerabilities in dependencies. By learning how these vulnerabilities work, their potential impact, and how to mitigate them, you are better equipped to build and maintain secure applications. We encourage you to apply this knowledge by scanning your projects for vulnerable dependencies, updating outdated libraries, and integrating security tools into your development pipeline.