Modern software development relies on open source libraries, even for those applications that are sold commercially and aren’t open source. However, developers may not always be aware how these components are introducing vulnerabilities into their code.
Seven in 10 applications use at least one open source library with a security flaw, which makes those applications vulnerable, Veracode said in its latest State of Software Security: Open Source Edition report. The report analyzed 351,000 unique open source libraries across Veracode’s platform database of 85,000 applications. A single flaw in one library can cascade to all applications using that component. The security debt becomes even higher when the vulnerable component is not called directly by the application, but by some other library.
“An application’s attack surface is not limited to its own code and the code of explicitly included libraries, because those libraries have their own dependencies,” said Chris Eng, Veracode’s chief research officer.
In most cases, the vulnerable libraries wind up in the applications indirectly, as 47 percent of the open source libraries with at least one vulnerability were “transitive” dependencies, Veracode said. Transitive dependencies refers to situations where a library relies on code from other libraries. A developer may explicitly include only one library, but if that library includes another, and that one also pulls in code from yet another library, the code the developer is writing winds up having three dependencies, not just one. As applications get more complex, the number of dependencies the developer has to manage grows pretty quickly.
"An application that picks up most of its dependencies via second, third, or even greater degrees of separation from a developer's explicit instruction increases the difficulty of managing those dependencies," the report said.
This is why it is harder for developers to stay on top of making sure they are using the most up-to-date versions of open source libraries. They can keep track of the ones they are using directly, but they often have to trust that the upstream library maintainers are managing the other dependencies.
"All of this imported code represents functionality that your developers did not author, but becomes code you have to manage," the report said.
Vulnerable And Outdated
Veracode’s findings echo the recent Open Source Security and Risk Analysis report from Synopsys which found that 99 percent of codebases contain at least some open source code and 75 percent used at least one vulnerable open source component. Synopsys found that 49 percent of codebases it analyzed had at least one component with a high-risk vulnerability. Synopsys audited 1,253 applications and assessed open source codebases from 20,000 sources for the OSSRA.
About 90 percent of applications used at least one open source component that was out-of-date by four or more years, or was abandoned, with at least two years of no development activity, Synopsys found. Out-of-date or abandoned components are even more likely to have unfixed security vulnerabilities.
The average application included 445 open source components, Synopsys found—which was far higher than the average number of components reported by Veracode. In an average application, 70 percent of the codebase was open source. Both reports agreed that applications are using a lot of open source components.
"The 2020 OSSRA report highlights how organizations continue to struggle to effectively track and manage their open source risk,” said Tim Mackey, principal security strategist of the Synopsys Cybersecurity Research Center. “Maintaining an accurate inventory of third-party software components, including open source dependencies, and keeping it up to date is a key starting point to address application risk on multiple levels.”
The OSSRA, like Veracode’s State of Software Security report, looked at both open source and commercial applications that incorporate open source components. Synopsys also found that some open source components were widely used. For example, 55 percent of applications analyzed by Synopsys used jQuery, 40 percent used Bootstrap, 31 percent used Font Awesome, and 30 percent used Lodash.
Packages "implementing trivial functionality [_ms_ converts time into milliseconds] can have flaws, and may exist deep in a dependency tree," Veracode said.
Even if the developer knows to use the most recent version of the libraries, if any of the other libraries included in the application pull code from older versions of these two components, the denial of service issues becomes part of the application.
Swift has the highest density of flaws, but has an overall low percentage of flawed libraries, Veracode found. Go, on the other hand, has a high percentage of libraries with flaws but has low density, meaning the individual library has an overall low number of flaws.
The typical PHP applications doesn’t import a lot of libraries, an average of 34 components, but a greater share of PHP libraries have at least one security vulnerability. PHP has more flawed libraries and a high density of flaws (but not as high as Swift), meaning the individual library also has a lot of flaws. Including any given PHP library has a greater than 50 percent of chance of introducing a security flaw into the code, Veracode found.
Types of Vulnerabilities
Veracode mapped the vulnerabilities in the open source libraries against the Top 10 list of software vulnerabilities maintained by the Open Web Application Security Project to determine if some types of vulnerabilities were more prevalent in open source components than others. Cross-Site Scripting (XSS), insecure deserialization, and broken access control vulnerabilities made up "a substantial portion" of the flaws in open source components. Veracode found that 29.1 percent of the libraries had at least one cross-site scripting flaw, 23.5 percent had insecure deserialization issues, and 20.3 percent had problems with broken access control.
The language differences were evident here, as well, as more than 40 percent of PHP libraries had cross-site scripting issues. PHP also had more broken access control and authentication problems than in any other language.
Insecure deserialization issues were common only in PHP and Java libraries, and broken access control flaws were bigger problems for .NET and Go libraries than XSS. While XSS issues were prevalent across all languages, they posed less of a problem than insecure deserialization and broken access control because most XSS issues were not exploitable.
Synopsys also had similar findings, noting that of the ten most common vulnerabilities it identified in open source components, four did not have a CVE assigned. The top three most common vulnerabilities were found in 37 percent of the applications analyzed. The fourth most common was the first one with a CVE (CVE-2019-11358), and is a vulnerability in jQuery.
Update Those Libraries
Most, or 74 percent, of the applications with vulnerable libraries can be fixed by just updating the libraries, Veracode said. In fact, 71 percent of the applications would even need a major update since a minor version update would fix the issues.
Most of the libraries with vulnerabilities from the Top 10 list also have updates available, as did 91 percent of flaws with public proof of concept exploits already have a fix available. Considering that attackers continue to target older vulnerabilities to attack systems, updating these components could significantly reduce the attack surface.
"Open source software gives companies tremendous advantages, but there's no free lunch here, and all code must be managed to avoid your own contributions — whether open or closed source in nature — from exposing your users to vulnerabilities," Veracode stated in the report.