Known vulnerabilities in dependencies
Making sure your dependencies are secure
Select your ecosystem
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.
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.
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).
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.
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.
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.
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.
Test your knowledge!
Keep learning
To deepen your understanding of managing and mitigating known vulnerabilities in dependencies, explore the following resources:
- OWASP OSS Top 10
- Snyk Open Source. A tool to scan, fix, and monitor open-source dependencies for vulnerabilities.
- Snyk Advisor