CVE-2022-25927
Description
ua-parser-js versions before 0.7.33 and 1.0.33 are vulnerable to Regular Expression Denial of Service (ReDoS) via the trim() function.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
ua-parser-js versions before 0.7.33 and 1.0.33 are vulnerable to Regular Expression Denial of Service (ReDoS) via the trim() function.
Vulnerability
Overview The vulnerability is a Regular Expression Denial of Service (ReDoS) in the trim() function of the ua-parser-js library [1]. This issue affects versions from 0.7.30 to before 0.7.33, and from 0.8.1 to before 1.0.33. The vulnerable regex pattern can cause catastrophic backtracking when processing specially crafted user-agent strings, leading to high CPU consumption.
Exploitation
An attacker can exploit this vulnerability by providing a maliciously crafted user-agent string to an application that uses ua-parser-js [4]. No authentication is required; the attack can be performed remotely. The ReDoS occurs when the trim() function is called on the input, triggering exponential backtracking in the regular expression engine [3].
Impact
Successful exploitation results in denial of service, as the CPU becomes excessively busy processing the malicious input, potentially causing the application to become unresponsive for an extended period [4]. This can affect both client-side and server-side usage of the library.
Mitigation
The vulnerability has been patched in versions 0.7.33 and 1.0.33 by removing the unsafe regex pattern from the trim() function [3]. Users are advised to upgrade to the latest patched versions immediately. No workarounds are documented.
AI Insight generated on May 20, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
ua-parser-jsnpm | >= 0.7.30, < 0.7.33 | 0.7.33 |
ua-parser-jsnpm | >= 0.8.0, < 1.0.33 | 1.0.33 |
Affected products
2- ua-parser-js/ua-parser-jsdescription
Patches
1a6140a17dd03Remove unsafe regex in trim() function
1 file changed · +1 −1
src/ua-parser.js+1 −1 modified@@ -93,7 +93,7 @@ }, trim = function (str, len) { if (typeof(str) === STR_TYPE) { - str = str.replace(/^\s\s*/, EMPTY).replace(/\s\s*$/, EMPTY); + str = str.replace(/^\s\s*/, EMPTY); return typeof(len) === UNDEF_TYPE ? str : str.substring(0, UA_MAX_LENGTH); } };
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
5- github.com/advisories/GHSA-fhg7-m89q-25r3ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2022-25927ghsaADVISORY
- github.com/faisalman/ua-parser-js/commit/a6140a17dd0300a35cfc9cff999545f267889411ghsaWEB
- github.com/faisalman/ua-parser-js/security/advisories/GHSA-fhg7-m89q-25r3ghsaWEB
- security.snyk.io/vuln/SNYK-JS-UAPARSERJS-3244450ghsaWEB
News mentions
0No linked articles in our index yet.