Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preventing/Mitigating Open Source Supply Chain Attacks #88

Open
4 tasks
lewisdaly opened this issue Apr 6, 2022 · 15 comments
Open
4 tasks

Preventing/Mitigating Open Source Supply Chain Attacks #88

lewisdaly opened this issue Apr 6, 2022 · 15 comments
Assignees

Comments

@lewisdaly
Copy link
Contributor

Request Summary:

Open Source Module Supply Chain attacks pose a real risk to the community:

For example: https://www.zdnet.com/article/corrupted-open-source-software-enters-the-russian-battlefield/

In this case, a malicious package was inserted as a dependency for a widely used package, which ended up attacking users who had ip addressed in Russia.

How can we as a community best prevent these sorts of attacks from affecting the Mojaloop Community?

Request Details:

  • Deadline:
  • Impact (Teams): <If your proposal is accepted, what team(s) will be affected by it?>
  • Impact (Components):

Artifacts:

Dependencies:

  • If Applicable

Accountability:

Decision(s):

  • Approved By:

Details

  • Actual decision made as a result of discussion

Follow-up:

  • Actions to implement the decisions
@godfreykutumela
Copy link
Contributor

godfreykutumela commented Apr 6, 2022

@godfreykutumela
Copy link
Contributor

godfreykutumela commented Apr 6, 2022

Top line is to:

  • Inspect dependency lists and ensure only necessary dependencies are to be downloaded/updated - Package-json.lock, a specification file that forces JavaScript applications to use a specific version of an NPM dependency, is highly recommended both for stability and security purposes.

  • Npm-secure-install, is a package installer that enforces secure practices, such as preventing the global installation of packages unless they contain npm-shrinkwrap.json, a specification that ensures everyone gets the same version of all dependencies

https://blog.logrocket.com/how-to-protect-your-node-js-applications-from-malicious-dependencies-5f2e60ea08f9/

@godfreykutumela

This comment was marked as off-topic.

@lewisdaly

This comment was marked as off-topic.

@lewisdaly
Copy link
Contributor Author

https://snyk.io/blog/publishing-malicious-packages/
This one has some good practices around preventing the installation of malicious packages, but it's fairly outdated.
Node has a lot of this stuff built in now (such as the package-lock.json)

I think we could look at developing a whitelist or something of that nature, but I think in general we should focus on best practices around code reviews, and have a culture around being skeptical when a new package is being added.

https://jfrog.com/blog/mind-your-dependencies-defending-against-malicious-npm-packages/
This one is more up to date, the npm-secure-installer looks like an interesting approach since it can stop sub-dependencies from being installed if they don't follow best practices around using a package-lock.json

package_checker also looks like an interesting utility that can look out for red flags, although I don't know where this would fit into our toolchain (maybe in a docker build)?

@godfreykutumela
Copy link
Contributor

Thanks @lewisdaly for this input and we will keep this open until we decide additional package check measures to compliment existing checks which may not sufficient to prevent this types of attacks.

@godfreykutumela godfreykutumela self-assigned this Apr 27, 2022
@godfreykutumela
Copy link
Contributor

Hi @MichaelJBRichards and @mdebarros Initially we thought we can prevent these types of attacks based on our current NPM package checking measures but upon reflecting on this again Lewis suggested to explore additional measures above which we can discuss in our DA meeting so lets keep this open for a while!

@MichaelJBRichards
Copy link

MichaelJBRichards commented Apr 27, 2022 via email

@godfreykutumela
Copy link
Contributor

Ownership is me and Lewis and participation is everyone in the DA @MichaelJBRichards

@lewisdaly
Copy link
Contributor Author

Decision today: @lewisdaly to investigate how we can better use our process around npm audit to make sure we can tighten the process around ignoring some vulnerabilities

@lewisdaly
Copy link
Contributor Author

I've done some more digging around our existing integrated tools, and here's a summary on my latest thinking:

Goal: Determine how we can use our existing tools: npm audit, npm-audit-resolver and dependabot to prevent open source supply chain attacks

Questions I think we all want to answer:

  • Did we just get lucky on the last n npm hacks/flaws? Or is our processing working?
  • How can we make our process more robust to protect the codebase without adding too much governance (e.g. whitelisting npm packages) or work?

Did we just get lucky on the last n npm hacks/flaws? Or is our processing working?

I need to come back to this - my plan is to look at the last Whitesource Audit and see if some of the more recent NPM flaws show up. It's hard to look back in time for security issues since we don't know if we (1) never depended on a given malicious module, (2) depended on a malicious module but our tooling works.

How can we make our process more robust to protect the codebase without adding too much governance (e.g. whitelisting npm packages) or work?

Case Study: EJS

  • marked as vulnerable 15 days ago
  • found both in Dependabot + npm audit

da_central_ledger

da_central_ledger2
- (not surprising since they use the same database)

  • npm audit fix --force resolves the issue (easy!)

My lowest-hanging-fruit proposal here is:

  • Move from npm-audit-resolver to just native npm audit
    • We can specify an --audit-level=moderate "The minimum level of vulnerability for npm audit to exit with a non-zero exit code."
    • e.g. npm audit --omit=dev --audit-level=moderate
    • This means we cannot ignore vulnerabilities moderate or worse - is that something we want to do?

e.g.:

npm audit fix
# after running 
# 15 vulnerabilities (3 moderate, 12 high)

# this command passes
npm audit --omit=dev --audit-level=critical 


# this command fails:
npm audit --omit=dev --audit-level=high 

@lewisdaly
Copy link
Contributor Author

Whitesource vs NPM Audit

  • Godfrey and I ran another scan ~2 weeks ago

  • Now we are comparing the results of 5 repos npm audit run against whitesource,
    to shed light on how accurate our tools are to each other.

  • Summary:

repo # whitesource # npm audit
central-ledger 8 9
account-lookup-service 9 13
central-services-shared 6 7
sdk-scheme-adapter 7 7
ml-testing-toolkit 7 7
thirdparty-api-svc 7 8

White these numbers may not line up at a top level, the discrepencies can be explained by:

  • time delay in running npm audit (ideally we should've run these tools on the same day)
  • Whitesource also looks at source code, and some .html files have references to libraries
    such as jQuery which showed up in the scan

central-ledger

Whitesource found 11, 8 deduplicated:

  • High ejs-2.7.4.tgz
  • High ejs-2.7.4.tgz
  • High jsonpointer-4.1.0.tgz
  • High protobufjs-5.0.3.tgz
  • High protobufjs-6.11.2.tgz
  • High validator-10.11.0.tgz
  • Medium ajv-5.5.2.tgz
  • Medium markdown-it-10.0.0.tgz
  • Medium sanitize-html-1.27.5.tgz
  • Medium sanitize-html-1.27.5.tgz
  • Medium yargs-parser-11.1.1.tgz

npm audit found 10, 9 deduplicated:

  • critical ejs
  • moderate jsonpointer
  • high protobufjs
  • moderate validator
  • moderate ajv
  • moderate markdown-it
  • moderate sanitize-html
  • moderate sanitize-html
  • moderate yargs-parser
  • high trim **not found by whitesource

account-lookup-service

Whitesource found 12, 9 deduplicated

  • High ansi-regex-3.0.0.tgz
  • High ejs-2.7.4.tgz
  • High ejs-2.7.4.tgz
  • High jsonpointer-4.1.0.tgz
  • High minimist-1.2.5.tgz
  • High protobufjs-5.0.3.tgz
  • High protobufjs-6.11.2.tgz
  • Medium ajv-5.5.2.tgz
  • Medium markdown-it-10.0.0.tgz
  • Medium sanitize-html-1.27.5.tgz
  • Medium sanitize-html-1.27.5.tgz
  • Medium yargs-parser-11.1.1.tgz

npm audit found 17, 13 deduplicated:

  • high ansi-regex
  • high ansi-regex
  • critical ejs
  • moderate jsonpointer
  • critical minimist
  • high protobufjs
  • moderate ajv
  • moderate markdown-it
  • moderate sanitize-html
  • moderate sanitize-html
  • moderate yargs-parser
  • moderate urijs ** not found by whitesource
  • moderate validator ** not found by whitesource
  • high urijs ** not found by whitesource
  • moderate urijs ** not found by whitesource
  • high async ** not found by whitesource
  • high moment ** not found by whitesource

It looks like some of these may not have been vulnerable ~2 weeks ago when
I last ran the whitesource scan.

central-services-shared

Whitesource found 8, 6 deduplicated:

  • High ejs-2.7.4.tgz
  • High ejs-2.7.4.tgz
  • High jsonpointer-4.1.0.tgz
  • Medium ajv-5.5.2.tgz
  • Medium markdown-it-10.0.0.tgz
  • Medium sanitize-html-1.27.5.tgz
  • Medium sanitize-html-1.27.5.tgz
  • Medium yargs-parser-11.1.1.tgz

npm audit found 8, 7 deduplicated:

  • critical ejs
  • moderate jsonpointer
  • moderate ajv
  • moderate markdown-it
  • moderate sanitize-html
  • moderate sanitize-html
  • moderate yargs-parser
  • high trim ** not found by whitesource

sdk-scheme-adapter

Whitesource found 10 total, 7 deduplicated:

  • High ejs-2.7.4.tgz
  • High ejs-2.7.4.tgz
  • High jsonpointer-4.1.0.tgz
  • Medium ajv-5.5.2.tgz
  • Medium jquery-3.4.1.min.js **matched a file, not package-lock.json
  • Medium jquery-3.4.1.min.js **matched a file, not package-lock.json
  • Medium markdown-it-10.0.0.tgz
  • Medium sanitize-html-1.27.5.tgz
  • Medium sanitize-html-1.27.5.tgz
  • Medium yargs-parser-11.1.1.tgz

npm audit found 7:

  • critical ejs
  • moderate jsonpointer
  • moderate ajv
  • moderate sanitize-html
  • moderate yargs-parser
  • moderate markdown-it
  • moderate sanitize-html

ml-testing-toolkit

Whitesource found 12 total, 7 deduplicated:

  • High dicer-0.2.5.tgz
  • High engine.io-3.5.0.tgz
  • High minimist-1.2.5.tgz
  • High socket.io-parser-3.0.0.tgz **not found by npm
  • High validator-10.11.0.tgz
  • Medium bootstrap-4.0.0.min.js **not found by npm (this isn't for a dep in package-lock.json)
  • Medium bootstrap-4.0.0.min.js
  • Medium bootstrap-4.0.0.min.js
  • Medium bootstrap-4.0.0.min.js
  • Medium jquery-3.2.1.slim.min.js
  • Medium jquery-3.4.1.min.js
  • Medium jquery-3.4.1.min.js **not found by npm (this isn't for a dep in package.json)

npm audit found 7

  • critical minimist
  • moderate validator
  • high engine.io
  • high ansi-regex ** not found by whitesource
  • high async ** not found by whitesource
  • high moment ** not found by whitesource
  • high dicer

thirdparty-api-svc

Whitesource found 9 total, 7 deduplicated

  • High ejs-2.7.4.tgz
  • High ejs-2.7.4.tgz
  • High jsonpointer-4.1.0.tgz
  • High validator-10.11.0.tgz
  • Medium ajv-5.5.2.tgz
  • Medium markdown-it-10.0.0.tgz
  • Medium sanitize-html-1.27.5.tgz
  • Medium sanitize-html-1.27.5.tgz
  • Medium yargs-parser-11.1.1.tgz

npm audit found 9 total, 8 deduplicated:

  • critical ejs
  • high protobufjs ** not found by whitesource
  • moderate jsonpointer
  • moderate validator
  • moderate ajv
  • moderate markdown-it
  • moderate sanitize-html
  • moderate sanitize-html
  • moderate yargs-parser

@bushjames
Copy link

SBoM work helps mitigate...Moving to review, new ticket(s) to be opened to cover specifics if necessary.

@godfreykutumela
Copy link
Contributor

Hi @bushjames, SBOM is just a listing of what is used to build the software, which is one of the many steps required in the open-source risk chain. Since this is pretty old, you can close it, and it could be re-opened in a new context.

@bushjames
Copy link

Update from @elnyry-sam-k: SBOM progressing well. To be presented at upcoming DA call. Work on provenance of all mojaloop dependencies and artifacts is in progress. Some recommendations have been made which are being assessed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants