1 of 26

Not All Dependencies are Equal�An empirical study on production dependencies in NPM

Jasmine Latendresse Suhaib Mujahid Diego Elias Costa Emad Shihab

1

2 of 26

90% of softwares rely on open source packages

2

Faster development time

Lower development costs

2M+ packages

Used by 11M+ developers

3 of 26

3

170 nodes

352 links

170 nodes

352 dependencies

https://npm.anvaka.com/

Software projects depend on a large number of packages.

Nearly 40% of npm packages rely on vulnerable code.

Dependencies need to be maintained.

Browserify

Which dependencies are actually critical to software projects?

4 of 26

What happens when critical dependencies fail?

4

Security breach in Apache Struts package.

  • data breach of millions of American citizens.
  • 1.8 billion USD in security upgrades and lawsuits.

2017

2022

Faulty update in a critical component.

  • 25% of Canada affected.
  • Users could not make 911 calls.
  • Banking services down for several days.

5 of 26

Which dependencies are more critical within a project?

5

Development dependencies

Runtime

dependencies

Dependencies

in production

Implementation

Validation

Deployment

Dependencies in production are the most critical in software systems

6 of 26

Identifying dependencies used in production

6

7 of 26

Identifying dependencies used in production

7

8 of 26

Identifying dependencies used in production

8

9 of 26

Identifying dependencies used in production

9

Production

10 of 26

Research questions

10

RQ1. How many installed dependencies are in production?

RQ2. What are the types of dependencies in production?

RQ3. How often are npm security alerts emitted for dependencies in production?

11 of 26

Approach overview

11

100 JavaScript projects

Clone projects and install dependencies

Build projects

Identify dependencies in production

12 of 26

Research questions

12

RQ1. How many installed dependencies are in production?

RQ2. What are the types of dependencies in production?

RQ3. How often are npm security alerts emitted for dependencies in production?

13 of 26

Quantifying packages in production

13

Manually build

projects, tree shaking

Manually inspect build configurations

Parse source maps of each project

Project build command

Project source maps

Dependencies in production

14 of 26

Less than 1% of installed dependencies were used in production

14

497 are used in production

53,421 installed dependencies

15 of 26

Research questions

15

RQ1. How many installed dependencies are in production?

RQ2. What are the types of dependencies in production?

RQ3. How often are npm security alerts emitted for dependencies in production?

16 of 26

Identifying the types of dependencies in production

16

npm ls

Dependency tree

Dependency tree parser

Cross dependencies in production with dataset of dependencies

Identify all versions of installed dependencies

Dataset of installed dependencies

Production dependencies types

17 of 26

28% of the dependencies in production are development dependencies

17

139 development dependencies

Development dependencies deployed to production can be potentially ignored in maintenance tasks.

497 dependencies in production

18 of 26

Dependency configuration

18

19 of 26

52.7% of dependencies in production are transitive

19

262 transitive dependencies

We have no control over transitive dependencies so it is important to be aware of them.

497 dependencies in production

20 of 26

Research questions

20

RQ1. How many installed dependencies are in production?

RQ2. What are the types of dependencies in production?

RQ3. How often are npm security alerts emitted for dependencies in production?

21 of 26

Collecting security alerts

21

npm audit

Alerts parser

Cross vulnerable dependencies with production dependencies

Project security alerts

Alert severity and vulnerable dependencies

Alerts emitted for production dependencies

22 of 26

None of the security alerts were emitted for dependencies in production

22

608 security alerts

268 high severity

45 critical severity

23 of 26

Too many security alerts, too little details

23

24 of 26

Takeaways

24

Difficult to prioritize maintenance efforts on dependencies that are critical to our software in production.

Not all security alerts are relevant to our applications.

We may miss an actual critical vulnerability, we need to be mindful about our dependencies configuration.

25 of 26

Not All Dependencies are Equal:�An empirical study on production dependencies in NPM

Suhaib Mujahid

smujahid@mozilla.com

Diego Elias Costa

costa.diego@uqam.ca

25

26 of 26

References

  1. Josh Fruhlinger. 2020. Equifax data breach FAQ: What happened, who was affected, what was the impact? https://www.csoonline.com/article/3444488/ equifax-data-breach-faq-what-happened-who-was-affected-what-was-theimpact.html
  2. J. P. Cheung, “The Rogers Outage of 2022: Takeaways for SREs,” DevOps.com, Aug. 15, 2022. https://devops.com/the-rogers-outage-of-2022-takeaways-for-sres/
  3. 2019. 2019 State of the Software Supply Chain. https://www.sonatype.com/ hubfs/SSC/2019%20SSC/SON_SSSC-Report-2019_jun16-DRAFT.pdf

26