It occurs when logging captures passwords, tokens, personal data, session details, or other confidential fields because the application logs inputs too broadly or without filtering. Logs are often widely accessible, so attackers prize them. Defenders should redact sensitive fields, restrict log access, and review logging code for overcollection.
What usually causes sensitive data to land in logs?
It is usually a logging design problem, not a storage problem. Applications often log request payloads, headers, exception objects, debug traces, or whole data structures without first separating operational telemetry from confidential fields. The result is that passwords, tokens, account details, and personal data are captured because the logger sees them, even when the business process never needed them recorded.
The most common trigger is overbroad instrumentation. Developers add generic request or response logging to speed up troubleshooting, then later forget that the same code now runs in production. A second cause is poor field selection: the application logs too much context, or it serializes nested objects where sensitive values are buried inside otherwise harmless data.
Why does this become a security issue so quickly?
Logs are often more widely distributed than the application data they describe. Operations teams, support staff, analytics pipelines, SIEM tooling, and cloud log services may all retain copies, so one careless log line can multiply exposure across several systems. That is why insertion of sensitive information into a log file is treated as a data exposure problem, not merely a coding mistake.
It also creates a persistence problem. Even if the original secret is later rotated or the user changes a password, the historic log record may still contain the old value. If attackers gain read access to logs, they may recover secrets, impersonate users, or piece together enough context to move deeper into the environment. For logging hygiene, see the Cloud Logging and Audit Trail Guide for how retention, tamper detection, and audit coverage affect operational log risk.
Teams also underestimate how log data can cross system boundaries. A value that is harmless in a local debug console may become sensitive once it enters centralized logging, long-term archives, support tickets, or cross-environment dashboards. That is why logging policy and access control need to be aligned from the start.
How do teams prevent overcollection in application logs?
The practical fix is to treat logging as a data minimization problem. Applications should redact or hash sensitive fields before they are emitted, and logging wrappers should define safe defaults so developers do not need to remember every field manually. A code review should ask whether the log entry is necessary for diagnosis, not whether it is merely convenient to emit.
For broader secure-coding guidance, the CWE Top 25 Guide is useful because this issue often appears alongside other input-handling and sensitive-information weaknesses. The same design discipline that prevents unsafe parsing also helps prevent accidental disclosure into logs.
Access control matters as much as redaction. Even well-designed logs should be treated as sensitive operational records, with narrow access, short retention where possible, and monitoring for unusual reads or exports. If a team relies on logs for incident response, it should still avoid making them a secondary repository of secrets.
Risk and Threat Considerations
Log files are attractive targets because they often concentrate credentials, identifiers, session details, and other context that can be reused after collection. The main risk is not only disclosure, but also secondary abuse, since a single exposed log can reveal both the sensitive value and the operational context around it.
Failure mechanism: Broad logging, exception dumping, or raw object serialization captures confidential fields before they are filtered, then the logs are retained in places with wider access than the source application or data store.
Impact: Attackers or unauthorized insiders may recover secrets, replay sessions, map internal systems, or exfiltrate personal data long after the original transaction has completed.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP ASVS, CIS Controls v8 and NIST SP 800-53 Rev 5 set the technical controls, while ISO/IEC 27001:2022 defines the regulatory obligations.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V16 — Security Logging and Error Handling | Log disclosure is directly about what the application records and reveals. |
| Recommendation — Review logging paths to prevent sensitive fields from being emitted in application logs. | ||
| CIS Controls v8 | CIS-8 — Audit Log Management | This weakness affects log content, retention, and access to sensitive records. |
| Recommendation — Define log handling rules that limit sensitive data collection and protect stored logs. | ||
| NIST SP 800-53 Rev 5 | AU-3 — Content of Audit Records | Audit records must capture useful events without collecting unnecessary sensitive data. |
| AU-9 — Protection of Audit Information | Sensitive logs require protection because they can expose confidential operational data. | |
| Recommendation — Limit audit record content so logs do not capture secrets or personal data unnecessarily. Restrict access to logs and protect them against unauthorized disclosure or tampering. | ||
| ISO/IEC 27001:2022 | A.8.15 — Logging | Logging controls must define what is recorded and how sensitive information is handled. |
| Recommendation — Set logging rules that exclude confidential fields and protect log integrity and access. | ||
Practitioner Guidance
What to verify: Check whether your logging path can ever receive raw request bodies, authorization headers, session tokens, passwords, or database error payloads. If it can, verify that a redaction step is applied before any sink, not after the log has already been written.
Common mistake: Teams often sanitize the most obvious fields and miss nested objects, exception messages, correlation metadata, or debug-only branches that still run in production. The safer test is to inspect the final emitted record, not just the source code that constructs it.
Practitioner takeaway: The right question is not whether a log entry is useful, but whether it is useful without exposing something that should never leave the transaction boundary.
Related resources from NHI Mgmt Group
- Is CVE-2023-21492 (Samsung Mobile Devices Insertion of Sensitive Information Into Log File) being exploited in the wild?
- How do you patch or mitigate CVE-2023-21492 (Samsung Mobile Devices Insertion of Sensitive Information Into Log File)?
- CVE-2023-21492 (Samsung Mobile Devices Insertion of Sensitive Information Into Log File)
- Insertion of Sensitive Information into Log File