World-Readable Log Files in log4js-node Package - CVE-2022-21704

node-log4js Updated 02 Oct 2025

Summary

19/01/2022
N/A
Yes i
Medium
5.5

CVE-2022-21704: log4js-node is a port of log4js to node.js. Affects node-log4js across 2 version ranges.

< 6.3.0+~cs8.3.10-1+deb11u1 < 9fdbed5ad45d1b09b35c1ef5355ba726b60cb702

Fixed in 6.3.0+~cs8.3.10-1+deb11u1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

log4js-node is a popular logging library for Node.js, designed to provide a flexible and powerful logging solution for applications. It offers various appenders for logging, including file, fileSync, and dateFile, which allow developers to log messages to files with customizable formats and levels. However, certain versions of log4js-node have a critical vulnerability that results in log files being created with world-readable permissions, potentially exposing sensitive information to unauthorized users.

Vulnerability Detail

The vulnerability identified as CVE-2022-21704 arises from the default file permissions set for log files generated by the file, fileSync, and dateFile appenders in log4js-node. In affected versions, these log files are created with world-readable permissions on Unix systems, meaning any user on the system can read the contents of these files. This poses a significant risk if the logs contain sensitive information, such as user data, authentication tokens, or application errors. The issue originates from the lack of a specified mode parameter in the configuration, which would otherwise allow users to set appropriate permissions for their log files. The ramifications of this vulnerability can lead to data breaches and unauthorized access to sensitive information.

How To Fix

Minimum fixed version

6.3.0+~cs8.3.10-1+deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-log4js

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, users can manually set the file permissions of the log files after they are created. This can be done using the chmod command in Unix systems. For example, to set the permissions to be readable only by the owner, you can run: chmod 600 path/to/logfile.log. Additionally, users can specify the mode parameter in their log4js-node configuration to set custom permissions when creating log files.

Conclusion

CVE-2022-21704 presents a significant risk for applications using the log4js-node package due to the default world-readable permissions of log files. Users are strongly advised to update to the latest versions to mitigate this vulnerability and protect sensitive information. Additionally, implementing proper file permission settings in the logging configuration can further enhance security.

See every vulnerability recorded for node-log4js →

Share this vulnerability

FAQ

CVE-2022-21704 is a vulnerability in the log4js-node package that allows log files to be created with world-readable permissions, potentially exposing sensitive information.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

Affected versions include those prior to 6.3.0 for Debian 11 and prior to 6.4.1 for Debian 12 and 13.

If an immediate update is not possible, consider using the chmod command to restrict file permissions on existing log files as a temporary workaround.

The CVSS score for CVE-2022-21704 is 5.5, indicating a moderate level of severity.

Related vulnerabilities

Recent vulnerabilities recorded for node-log4js.

How To Fix

Minimum fixed version

6.3.0+~cs8.3.10-1+deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-log4js

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback