CVE-2022-21704: Log4js Incorrect Default Permissions Vulnerability

MODERATE
Advisory Identifier: GHSA-82v2-mx6x-wq7q
CVSS 5.5
CWE-276
Published
Advisory Summary

CVE-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.

CVE-2022-21704 at a Glance

CVE Identifier CVE-2022-21704
GHSA Identifier GHSA-82v2-mx6x-wq7q
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-276: Incorrect Default Permissions
Affected Product Log4js
Package Ecosystem npm
Published Date
Last Updated

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).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (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.

log4js fixed: 6.4.0
npm install log4js@6.4.0
Verify Direct and Transitive Dependencies

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

### Impact Default 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. ### Patches Fixed by: * https://github.com/log4js-node/log4js-node/pull/1141 * https://github.com/log4js-node/streamroller/pull/87 Released to NPM in log4js@6.4.0 ### Workarounds Every version of log4js published allows passing the mode parameter to the configuration of file appenders, see the documentation for details. ### References Thanks to [ranjit-git](https://www.huntr.dev/users/ranjit-git) for raising the issue, and to @lamweili for fixing the problem. ### For more information If you have any questions or comments about this advisory: * Open an issue in [logj4s-node](https://github.com/log4js-node/log4js-node) * Ask a question in the [slack channel](https://join.slack.com/t/log4js-node/shared_invite/enQtODkzMDQ3MzExMDczLWUzZmY0MmI0YWI1ZjFhODY0YjI0YmU1N2U5ZTRkOTYyYzg3MjY5NWI4M2FjZThjYjdiOGM0NjU2NzBmYTJjOGI) * Email us at [gareth.nomiddlename@gmail.com](mailto:gareth.nomiddlename@gmail.com)

CVE-2022-21704 Affected Log4js Versions

1 component(s)
Fixed Versions:
6.4.0
Product / Package Ecosystem Affected Versions Fixed Version
log4js
npm
< 6.4.0
6.4.0

References

Frequently Asked Questions

What is CVE-2022-21704?
CVE-2022-21704 is a security vulnerability in Log4js involving Incorrect Default Permissions in log4js under CWE-276: Incorrect Default Permissions.
Which Log4js versions are affected?
Affected versions include releases prior to 6.4.0 across affected packages: log4js.
What version fixes CVE-2022-21704?
Upgrading to 6.4.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is log4js affected?
Yes, log4js is affected in releases prior to 6.4.0. Upgrade your dependency to 6.4.0 or later.
What is the CVSS score of CVE-2022-21704?
CVE-2022-21704 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2022-21704?
CVE-2022-21704 is classified under CWE-276: Incorrect Default Permissions (During installation, installed file permissions are set to allow anyone to modify those files.).
How can I check npm dependencies for CVE-2022-21704?
Run the dependency tree command: 'npm ls log4js'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}