Leakage of sensitive data in dynamic file generation

Description

It is not uncommon to generate logs, backups, or data exports to static file formats. This rule checks if code exists to write sensitive data to static files.

Remediations

❌ Avoid code like the following:

  foreach ($users as $user) {
fputcsv($csvFile, [$user['email'], $user['address']]);
}

In instances where writing sensitive data is intentional, make sure to document its location according to your internal policies.

Associated CWE

OWASP Top 10

Configuration

To skip this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --skip-rule=php_lang_file_generation

To run only this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --only-rule=php_lang_file_generation