{{announcement.body}}
{{announcement.title}}

Dependencies: It’s Not Just Your Code You Need to Secure

DZone 's Guide to

Dependencies: It’s Not Just Your Code You Need to Secure

Developers must not only check our code for vulnerabilities but also our dependencies to make our applications more secure.

· Security Zone ·
Free Resource

Hackmetrix: Dependencies: It’s not just your code you need to secure

Original article published by Cristián Rojas at Hackmetrix Blog

The EQUIFAX USA event of 2017 put a spotlight an under-considered aspect of software security: it’s not just our code that we need to secure. The facts of the case are widely known, but its cause? Not so much. Little is said about the fact that this leak would not have taken place if the developers of the EQUIFAX application had upgraded their Apache Struts web framework to a more secure version.

We developers are not creating applications based only on our code. We rely on servers, programming languages, frameworks, libraries (wheels, gems, JARs…), and we need to secure all of that, even code that we copy-paste from Stack Overflow.

When we create applications, we are not just writing code; we are building a house with Lego blocks, and our code is just a part of that house. In fact, our code is on the top of that house. All that other stuff we depend on is underneath, it’s our software’s foundations, and if it is not secured, our house will fall apart, just like EQUIFAX’s did.

One notable thing to mention in this issue is the fact that this kind of vulnerability is listed in OWASP Top 10 2017.

OWASP Top 10 2017 entry.

Project Support

The good news is that some developers have begun to take notice of these issues. There are projects available that aim to help developers take care of dependency security even before their code reaches the CI/CD (Continuous Integration/Continuous Delivery) server.

These tools are continuously updated, based on security data obtained from CVE (Common Vulnerabilities and Exposures) data and developer reports, and can be used in CI/CD servers as well.

Here are some of them:

OWASP Dependency-Check (Java, Multi-Language)

The main reference when it comes to dependency security checking is OWASP’s dependency checking tool, which is mainly thought for Java projects but has been expanded to other platforms, like .NET, with experimental support for Ruby, Node.js, Python, and C/C++.

OWASP Dependency Check as a Jenkins plugin.

Bundler Audit (Ruby)

Bundler Audit is made with the popular language Ruby in mind. Its vulnerability database is GitHub repository-based, and it is regularly updated. This allows Ruby developers to keep their gems up-to-date in security terms.

Package Manager Support

The even better news is that package managers have begun to take notice, and they take security a step further by integrating dependency checks into their features. Here are notable cases:

Pipenv (Python)

Pipenv is a packaging tool for Python that is gaining momentum every day and brings together many aspects of Python development: management of virtual environments (virtualenv), package definition (pip), and others.

One of its included features is a package security audit, right out of the box. If you still use pip, no problem. Just install the safety package, and you will get the same protection.

Pipenv check output.

NPM (Node.js)

Since version 6, the Node Package Manager includes an audit feature that allows developers to check for vulnerabilities in their projects’ dependencies.

One notable thing about this functionality is that it also warns about potentially functionality-breaking upgrades based on the Semantic Versioning standard.

Continuous Integration? Yes, But…

Some of these tools already have CI/CD system plugins available for servers like Jenkins, and they work quite well. In the case of the tools that don’t, integration to these systems is not that hard.

Now, we shouldn’t wait until our code reaches our repositories (and our CI servers) to see if our dependencies are secure. Dependency security checks should be done by every developer before pushing their changes to the repository. Don’t get busted by the CI/CD server.

How to Fix

Fixing the issues reported by these tools may seem easy: just change the library version, and that’s it. But you need to test the changes locally before pushing your code.

Many packaging systems are automatic when syncing versions and dependencies of your dependencies are upgraded easily. But this may cause functionality breakage. This is the main reason the community created the Semantic Versioning standard.

Usually, security vulnerability mitigations are put in the patch versions, but sometimes, you will need to upgrade to a minor or major version, and if that happens, you must do feature testing, because these kinds of upgrades could cause problems with functionality.

Not Just Libraries

The tools we saw earlier allow us to check vulnerabilities in libraries/frameworks. But we don’t just depend on those. Servers and our (every day more) virtualized infrastructure should be checked for security vulnerabilities. Automatically.

Tools like Ansible, InSpec, or OpenSCAP can be leveraged to alert of any security problems that our servers may have integrated to CI/CD pipelines.

Conclusion

Developers must check not only our code for vulnerabilities but also our dependencies to make our applications more secure.

This process should be automated, but not dependent on automation: we need to be more proactive and run our available tools before committing changes. This way, we will be one step ahead from malicious actors who intend to harm our software and its users.

Topics:
security ,web security ,dependencies ,vulnerabilities ,vulnerability assessment ,penetration testing ,npm ,apache ,python

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}