A Single Partner for Everything You Need Optiv works with more than 450 world-class security technology partners. By putting you at the center of our unmatched ecosystem of people, products, partners and programs, we accelerate business progress like no other company can.
We Are Optiv Greatness is every team working toward a common goal. Winning in spite of cyber threats and overcoming challenges in spite of them. It’s building for a future that only you can create or simply coming home in time for dinner. However you define greatness, Optiv is in your corner. We manage cyber risk so you can secure your full potential.
Breadcrumb Home Insights Source Zero Securing the Software Supply Chain from Typosquatting Attacks April 08, 2024 Securing the Software Supply Chain from Typosquatting Attacks Lessons from the PyPI Breach for Open-Source and AI/ML Security This is the first of a two-part blog series addressing key lessons learned from the PyPI security incidents. This first blog post explains the nature of the “typosquatting” adversary technique used to target the Python Package Index (PyPI) and its significant impact on AI/ML development. The second blog post provides comprehensive defense strategies for strengthening your security posture against such attacks. In March 2024, security incidents targeting the Python Package Index (PyPI) were announced. These incidents serve as a critical wake-up call for the industry regarding the vulnerabilities of open-source software (OSS) within the software development life cycle (SDLC), particularly for applications leveraging AI and ML technologies. This incident not only underscores the growing concerns surrounding open-source security, but also highlights the need for more sophisticated, programmatic approaches to managing these risks. As we delve deeper into the technicalities and solutions, it is important for organizations like us at Optiv to lead the discourse and implementation of advanced security measures. Understanding the Attack Vector The PyPI breach illustrates a software supply-chain exploitation of the open-source ecosystem's reliance on name recognition and trust for package dependency management. In this specific incident, attackers utilized the technique of typosquatting, demonstrating an understanding of developer behaviors and the potential for human error within software development workflows. Typosquatting involves the creation of malicious packages with names closely resembling those of legitimate, widely used packages, capitalizing on the likelihood of typographical errors by developers when searching for or installing dependencies. While the primary method in this breach was typosquatting, the relevance of dependency confusion in the broader context of software supply-chain security cannot be overlooked. Dependency confusion is a separate attack vector that exploits ambiguities in package dependency resolution mechanisms. This method involves an attacker publishing a malicious package under the same name as a private package used within an organization, but on a public repository, and with a higher version number. Consequently, when the build system seeks to resolve the dependency, it might erroneously fetch and integrate the malicious public package due to its higher version number, thinking it is the legitimate private package. Both typosquatting and dependency confusion highlight critical vulnerabilities in the software development and deployment process, underlining the importance of vigilant dependency management and verification practices. Typosquatting preys directly on human error and the simple mistake of a misspelling, while dependency confusion exploits the technicalities of how package managers and build systems prioritize and fetch dependencies. Together, they underscore the risks facing software supply chains and the necessity for comprehensive security measures to safeguard against these threats. Typosquatting Technique Typosquatting, in this context, hinges on the creation of maliciously crafted packages that bear strikingly similar names to legitimate, widely used packages. The attackers bet on the likelihood of developers making typographical errors when typing package names into package managers or dependency files. For instance, a package named “Django” might be mimicked as “Dajngo,” preying on hurried or distracted developers who may not notice the subtle swap of letters. This technique exploits a few key vulnerabilities: Human Error plays a significant role in the vulnerability of software development processes to malicious package insertions. Developers, often working under the pressure of tight deadlines or juggling multiple tasks simultaneously, may not allocate sufficient time to meticulously review each package name before incorporation. This oversight is particularly likely when managing a vast array of dependencies, where the focus might be on functionality and integration over security vetting. Automated Scripting is vital for streamlining software updates. It poses a unique risk when it lacks manual oversight. These scripts, designed to fetch and install packages, might inadvertently select maliciously named packages—exploiting typosquatting—without verifying their authenticity. This oversight allows attackers to introduce compromised packages into development or production environments, undermining application integrity and end-user security. To mitigate these risks, it is crucial to integrate validation steps, such as checksum verification and digital signature checks, into automated processes. These measures ensure that only verified, secure packages are incorporated, maintaining the balance between efficiency and security in software development workflows. Visual Deception exploits the subtleties of character representation, especially in various fonts or interfaces, and can significantly blur the line between distinct characters. Techniques extending beyond simple character substitution, including the use of homoglyphs—characters from different scripts that appear almost identical (such as Latin and Cyrillic alphabets)—or the strategic use of Unicode characters, amplify the risk of deception. These methods exploit the visual similarities between characters. Examples include “l” and “1,” “0” and “O,” and Latin character “a” (U+0061) and Cyrillic character “а” (U+0430), which enhance the potential for mistaken identity and can inadvertently facilitate the success of malicious packages in masquerading as their benign counterparts. Dependency Confusion Dependency confusion attacks exploit the way many package managers and build systems resolve dependencies with the same name from different sources. In a typical development environment, software projects may depend on both publicly available packages from repositories like PyPI and privately maintained packages, possibly with namespace overlaps. The attack strategy involves the following tactics: Namespace Collision occurs when an attacker deliberately publishes a public package that shares its name with a private package used within an organization's projects. This deceptive strategy exploits the way package managers resolve dependencies, potentially leading to the accidental inclusion of the malicious package in place of the intended private one. For example, if an organization internally uses a private package named "dataProcessor," an attacker might publish a malicious package under the same name to a public repository. When the build system fetches dependencies, it could mistakenly pull in the public "dataProcessor," introducing security vulnerabilities or malicious code into the organization's project. This risk underscores the importance of vigilant dependency management and the adoption of secure naming conventions for private packages. Versioning Trickery is an adversary tactic often employed in software supply-chain attacks, exploiting the inherent trust developers place in versioning systems. By maliciously assigning a higher version number to a public package that impersonates a legitimate private package, attackers take advantage of the automated behavior of package managers, which typically default to fetching the latest version of a package available. For example, if a private package within an organization's repository is labeled as version 2.0, the attacker might publish a compromised package with the version labeled 2.1 to a public repository. This may result in the package manager, in its attempt to keep dependencies up to date, selecting the malicious version 2.1 over the intended secure version 2.0—leading to the inadvertent integration of harmful code into the project. Ambiguous Source Resolution highlights a vulnerability within the dependency management ecosystem, where package managers face confusion over selecting the correct source for a dependency shared across multiple repositories. This ambiguity arises when a package of the same name exists in both a public repository and a private, internal repository. For instance, if the package manager prioritizes or defaults to public sources without clear directives, a developer intending to download a proprietary "Utils" package from a private repository might inadvertently receive a malicious version from a public repository. Countermeasures and Technical Defenses Understanding these attack vectors paves the way for implementing robust countermeasures: Package Name Scrutiny and Verification: Utilizing automated tools to detect and flag close matches to popular package names for manual review is a critical first step. Tools like Sonatype Nexus and JFrog Artifactory offer such capabilities, integrating directly into the development workflow. While effective, the cost can vary depending on the scale of the project and the choice of tool, with enterprise versions requiring a subscription. Private Repository Prioritization: Configuring package managers to prefer private repositories over public ones and to mandate explicit approval for namespace overlaps helps mitigate risks. This requires adjustments in the configuration settings of package managers like npm or pip, which are relatively low in cost but demand initial setup time and ongoing management to ensure policies remain effective. Semantic Versioning and Digital Signatures: Adopting semantic versioning for private packages and enforcing the verification of digital signatures to authenticate package integrity are vital practices. Implementing digital signatures involves cryptographic operations, which may require the acquisition of digital certificates from trusted Certificate Authorities (CAs). While the operational cost is moderate, it provides a high level of security assurance. Dependency Review Processes: Establishing manual or automated processes for reviewing and approving dependencies adds an additional layer of security. Automated dependency review tools can scan for vulnerabilities, license compliance, and other security risks, but they come with subscription costs. Manual review processes, while cost-effective, require significant time investment from skilled developers or security analysts. Continuous Monitoring and Vulnerability Scanning: Continuous monitoring of dependencies for new vulnerabilities and integrating vulnerability scanning tools into the CI/CD pipeline are crucial. Tools like Snyk or WhiteSource bolt onto existing development pipelines to provide real-time alerts on vulnerabilities. The implementation of these tools can be costly, especially for large-scale projects, but they offer the benefit of continuous security oversight. By integrating these measures, organizations can build a comprehensive defense against supply-chain attacks. While some strategies come with higher upfront costs or require ongoing investments, the cost of mitigating a security breach post-factum—both in financial terms and in damage to reputation—can be significantly higher. Balancing these costs against the potential risks is essential in developing an effective security strategy. The Python Predicament Python's status as the preferred language for AI and machine learning development is undisputed. Its simplicity, versatility, and the rich ecosystem of libraries and frameworks it offers—such as Pytorch for deep learning and Matplotlib for data visualization—make it the go-to language for data scientists and AI engineers worldwide. However, this popularity also places Python and its libraries in the crosshairs of cyberthreats, as evidenced by the recent attack campaign reported by Mend.io, where over 100 malicious packages specifically targeted Python's ML libraries. Impact on AI/ML Development This targeted attack goes beyond the usual software development vulnerabilities, striking at the heart of AI/ML innovation. By focusing on libraries like Pytorch and Matplotlib, attackers are not just aiming at disrupting software applications. They are also potentially compromising the integrity of machine learning models and data analysis processes. Such attacks have far-reaching implications and potential outcomes: Model Tampering represents a critical threat in the realm of machine learning, where malicious code embedded within compromised libraries can significantly manipulate algorithms. This insidious form of attack might go unnoticed, but it has profound implications that include the subtle altering of the behavior of machine learning models. For instance, a tampered model designed for facial recognition could be skewed to misidentify or fail to detect specific individuals, leading to security breaches or false identifications. These alterations produce outcomes that are either skewed or completely fabricated, undermining the reliability and integrity of machine learning applications and potentially causing significant harm in scenarios where accuracy is paramount. Data Leakage in AI/ML poses a critical risk when compromised libraries are used. Data scientists, who heavily rely on these tools for processing and visualizing sensitive information, could inadvertently expose confidential datasets through a tampered library. For instance, if a library essential for data visualization, such as Matplotlib, is manipulated, it could become a channel for unauthorized data access. This could happen through hidden code within the compromised library that silently uploads datasets to a remote server during visualization operations. Such incidents compromise data privacy and threaten the integrity and competitiveness of AI/ML projects by risking exposure of proprietary algorithms or sensitive training data, eroding trust in the process. Trust Erosion critically undermines the foundational belief in the integrity of data and algorithms. This erosion begins when malicious modifications, such as injecting biases into datasets or altering algorithms, breach this trust. Consider a scenario where a healthcare AI model, designed to diagnose diseases from patient scans, is compromised to overlook certain symptoms. This could misguide medical professionals and even endanger lives, casting doubt on the system's dependability. Such breaches question not just the outcomes of a single project, but also the reliability of the AI/ML pipeline at large—threatening to diminish stakeholder confidence and hinder future advancements in the field. Conclusion In light of the recent PyPI breach, this blog post has highlighted critical vulnerabilities within the open-source ecosystem, particularly affecting AI and ML domains. This event underscores the urgent need for comprehensive cybersecurity strategies that address threats like typosquatting. For organizations utilizing open-source software, adopting a multi-layered security approach is no longer optional, but essential for safeguarding development processes and maintaining the integrity of the software supply chain. In the second blog of this two-part series, we will delve into defensive strategies for securing the software supply chain in greater detail, offering insights and solutions to enhancing your cybersecurity posture. By: Jim Canup Sr. Practice Manager | Optiv Jim Canup is a strategic, risk-oriented professional with over 30 years of cybersecurity experience, specializing in application security across a broad range of industries. Canup has a proven track record of implementing and managing various application security programs. His initial roots in software development allow him to understand the unique needs of the development, quality and security roles within an organization. Additionally, Canup has extensive experience working with top-level executives, which gives him a keen understanding of the delicate balance between technical needs and business needs. Share: Red Team Source Zero® open-source software typosquatting OSS Application Security SDLC software development life cycle dependency confusion Python Artificial Intelligence AI Machine Learning ML supply chain software supply chain Optiv Security: Secure greatness.® Optiv is the cyber advisory and solutions leader, delivering strategic and technical expertise to nearly 6,000 companies across every major industry. We partner with organizations to advise, deploy and operate complete cybersecurity programs from strategy and managed security services to risk, integration and technology solutions. With clients at the center of our unmatched ecosystem of people, products, partners and programs, we accelerate business progress like no other company can. At Optiv, we manage cyber risk so you can secure your full potential. For more information, visit www.optiv.com.
Optiv Security: Secure greatness.® Optiv is the cyber advisory and solutions leader, delivering strategic and technical expertise to nearly 6,000 companies across every major industry. We partner with organizations to advise, deploy and operate complete cybersecurity programs from strategy and managed security services to risk, integration and technology solutions. With clients at the center of our unmatched ecosystem of people, products, partners and programs, we accelerate business progress like no other company can. At Optiv, we manage cyber risk so you can secure your full potential. For more information, visit www.optiv.com.
Would you like to speak to an advisor? Let's Talk Cybersecurity Provide your contact information and we will follow-up shortly. Let's Browse Cybersecurity Just looking? Explore how Optiv serves its ~6,000 clients. Show me AI Security Solutions Show me the Optiv brochure Take me to Optiv's Events page Browse all Services