question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Replace ua-parser-js or pin current version

See original GitHub issue

It seems ua-parser-js has been the source of several security issues:

  1. https://github.com/karma-runner/karma/issues/3562 (regex catastrophic backtracking)
  2. https://github.com/karma-runner/karma/issues/3583 (regex catastrophic backtracking)
  3. https://github.com/karma-runner/karma/issues/3680 (regex catastrophic backtracking)
  4. https://github.com/karma-runner/karma/issues/3713 (malware compromise)

The catastrophic backtracking issues of course aren’t much of a problem for Karma, but the recent malware compromise certainly is! Karma represents a large chunk of the library’s usage (according to NPM, Karma represents ~25% of ua-parser-js’s downloads), and since a version range import is being used, it means that Karma may have unwittingly been a big contributor to spreading the latest malware.

Yet the library is only used in a single location for a very minor purpose (constructing a “friendly” name for browsers to show in the logs; as far as I can tell, this is an undocumented internal function with no particular promises about its API): https://github.com/karma-runner/karma/blob/94cf15e8fa4420c8716998873b77f0c4f59b9e94/lib/helper.js#L9

Maybe it’s time to swap that function out for a home-grown simplified version? I think there are a few options:

  • handle just the UAs for browsers with supported launchers, and the rest can use the fallback full version string
  • don’t try to create friendly names for any browsers; just use the full version string for everything
  • continue using ua-parser-js, but pin a specific version (0.7.30) instead of a range (^0.7.30) to at least avoid any future compromises being auto-fetched (and perhaps worth doing a quick review of the current code for other issues, if going with this option)
  • any of the above, plus make the function configurable (so that users can provide their own full-user-agent -> nice-name function, which could of course use any version of ua-parser-js if the user wants it). If doing this, my preferred choice would be to have the default just pass through the raw UA, removing the need for the dependency and keeping the code simple.

Do the maintainers have any preferences here?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
davidje13commented, Oct 26, 2021

sure; will take a look at it this weekend

1reaction
davidje13commented, Oct 30, 2021

Created a PR

Read more comments on GitHub >

github_iconTop Results From Across the Web

ua-parser-js - npm
UAParser. js. JavaScript library to detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data with relatively small footprint ...
Read more >
ua-parser-js and Malicious npm Packages - Expo Blog
Yesterday an npm package named ua-parser-js was compromised. ... The lockfiles pin all dependency versions so that running npm install or ...
Read more >
NPM package 'ua-parser-JS' with more than 7M weekly ...
We pin all of our npm dependencies and upgrade them via dependabot. ... minified js which makes the diffs between version bumps unreadable....
Read more >
Important: ua-parser-js exploit and Kotlin/JS - The JetBrains Blog
If you're using directly or indirectly ua-parser-js versions 0.7.29, 0.8.0, and 1.0.0, you can consider your system compromised.
Read more >
BREAKING!! NPM package 'ua-parser-js' with more than 7M ...
The latest in C++ dependency management is vcpkg, Microsoft's C++ version of npm or cargo. I've used it in my projects, but only...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found