Leakage of sensitive data in dynamic file generation

Overview

  • Rule ID: javascript_lang_file_generation

  • Applicable Languages: Javascript

  • Weakness ID: CWE-313

Description

Sensitive data leakage in dynamic file generation occurs when confidential information is written to static files, such as logs, backups, or data exports. This vulnerability can expose sensitive data to unauthorized access, increasing the risk of data breaches or misuse.

Remediation Guidelines

  • Do not write sensitive data directly to logs, backups, or data exports. This practice can lead to unauthorized access and compromise the confidentiality of the information.

    fs.writeFile("data.csv", JSON.stringify(users), "utf-8", (err) => {
      if (err) console.log(err)
    })
    
  • Do obfuscate or filter sensitive data before writing it to static files. This reduces the risk of sensitive data exposure.

References

Configuration

To omit this rule during a scan, and to provide you with continuous 24/7 code-level scanning, you can employ our SAST TOOL

Last updated