Vulnerabilities in pkg:npm/log4js
PACKAGECVE-2022-21704 is a MODERATE (CVSS 5.5) incorrect default permissions vulnerability (CWE-276: Incorrect Default Permissions) affecting Log4js libraries in the npm ecosystem. The issue involves incorrect default permissions in log4js. Remediation is available by upgrading affected packages to version 6.4.0.
pkg:npm/log4js
Vulnerability advisories affecting package pkg:npm/log4js. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-82v2-mx6x-wq7q | CVE-2022-21704 | MODERATE | Incorrect Default Permissions in log4js |
CVE-2022-21704 at a Glance
Security Impact
CVSS: 5.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N).
How to Fix CVE-2022-21704
To remediate this vulnerability, upgrade all affected Log4js dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install log4js@6.4.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls log4js
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2022-21704, inspect your project dependencies using npm:
npm ls log4js
Analyze the terminal output to locate any version of Log4js in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 6.4.0), your application is affected.
Note: The npm ls log4js command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-276: Incorrect Default Permissions, where during installation, installed file permissions are set to allow anyone to modify those files. In Log4js, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2022-21704 Affected Log4js Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
log4js
|
npm |
< 6.4.0
|
6.4.0
|
References
Frequently Asked Questions
What is CVE-2022-21704?
Which Log4js versions are affected?
What version fixes CVE-2022-21704?
Is log4js affected?
What is the CVSS score of CVE-2022-21704?
What CWE is associated with CVE-2022-21704?
How can I check npm dependencies for CVE-2022-21704?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-82v2-mx6x-wq7q",
"modified" : "2022-10-03T19:49:13Z",
"published" : "2022-01-21T18:53:27Z",
"aliases" : [ "CVE-2022-21704" ],
"summary" : "Incorrect Default Permissions in log4js",
"details" : "### Impact\nDefault file permissions for log files created by the file, fileSync and dateFile appenders are world-readable (in unix). This could cause problems if log files contain sensitive information. This would affect any users that have not supplied their own permissions for the files via the mode parameter in the config.\n\n### Patches\nFixed by:\n* https://github.com/log4js-node/log4js-node/pull/1141\n* https://github.com/log4js-node/streamroller/pull/87\n\nReleased to NPM in log4js@6.4.0\n\n### Workarounds\nEvery version of log4js published allows passing the mode parameter to the configuration of file appenders, see the documentation for details.\n\n### References\n\nThanks to [ranjit-git](https://www.huntr.dev/users/ranjit-git) for raising the issue, and to @lamweili for fixing the problem.\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [logj4s-node](https://github.com/log4js-node/log4js-node)\n* Ask a question in the [slack channel](https://join.slack.com/t/log4js-node/shared_invite/enQtODkzMDQ3MzExMDczLWUzZmY0MmI0YWI1ZjFhODY0YjI0YmU1N2U5ZTRkOTYyYzg3MjY5NWI4M2FjZThjYjdiOGM0NjU2NzBmYTJjOGI)\n* Email us at [gareth.nomiddlename@gmail.com](mailto:gareth.nomiddlename@gmail.com)\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "log4js"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "6.4.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/log4js-node/log4js-node/security/advisories/GHSA-82v2-mx6x-wq7q"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-21704"
}, {
"type" : "WEB",
"url" : "https://github.com/log4js-node/log4js-node/pull/1141/commits/8042252861a1b65adb66931fdf702ead34fa9b76"
}, {
"type" : "WEB",
"url" : "https://github.com/log4js-node/streamroller/pull/87"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/log4js-node/log4js-node"
}, {
"type" : "WEB",
"url" : "https://github.com/log4js-node/log4js-node/blob/v6.4.0/CHANGELOG.md#640"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2022/12/msg00014.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-276" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-01-19T22:47:14Z",
"nvd_published_at" : "2022-01-19T23:15:00Z"
}
}