BaΔΔ±Εla β problem mΙndΙn qaynaqlandΔ±. A09 mΙqalΙsini bΓΌtΓΆv bir `markdown bloku iΓ§indΙ vermiΕdim, amma mΙqalΙnin ΓΆzΓΌndΙ dΙ kod bloklarΔ± var idi. Ona gΓΆrΙ kopyalayanda Markdown strukturu pozulurdu.
AΕaΔΔ±da A09-u yenidΙn, birbaΕa .md mΙzmunu kimi verirΙm. KΙnarΔ±nda ΙlavΙ kod bloku yoxdur: cavabΔ±n mΙzmununu olduΔu kimi A09-Security-Logging-and-Monitoring-Failures.md faylΔ±na kΓΆΓ§ΓΌrΙ bilΙrsΙn.
π A09:2021 β Security Logging and Monitoring Failures
An attack you cannot detect can continue long after the vulnerability that enabled it has been fixed.
A successful security program needs more than preventive controls. Authentication can fail. A dependency can be compromised. An administrator can make a mistake. When that happens, logging and monitoring determine whether the incident is discovered in minutesβor reconstructed months later from incomplete evidence.
A09:2021 β Security Logging and Monitoring Failures addresses the systems, processes, and decisions required to detect attacks, investigate them, and respond effectively. The category is not simply about writing more log lines. It is about producing useful security evidence, protecting that evidence, turning it into actionable alerts, and ensuring someone acts on those alerts.
π Table of Contents
- Introduction
- What Is a Security Logging and Monitoring Failure?
- The Detection Lifecycle
- A09 Compared with Other OWASP Categories
- Real-World Lessons
- Relevant CWEs
- What Should Be Logged?
- What Must Never Be Logged?
- Log Injection and Evidence Tampering
- Detection Engineering and Alerting
- Cloud-Native Logging Challenges
- Vulnerable vs. Secure Code
- Tools and Standards
- Interactive Review Widget
- β Ultimate Checklist
- Conclusion
- Further Reading
Introduction
OWASP placed Security Logging and Monitoring Failures at #9 in its 2021 Top 10.
The central problem is straightforward:
If an application cannot record meaningful security events, or an organization cannot detect and respond to those events, an attacker may remain active without being noticed.
Logging and monitoring are related but distinct:
| Capability | Question it answers |
|---|---|
| Logging | What happened? |
| Collection | Did records from every relevant system arrive? |
| Protection | Can the evidence be altered or deleted? |
| Analysis | Do these events form a suspicious pattern? |
| Alerting | Was the right person notified in time? |
| Response | Did anyone investigate and contain the threat? |
A system that writes detailed logs but never analyzes them has logging, not effective monitoring. A SIEM that raises accurate alerts that nobody investigates has detection, not effective response.
Why A09 amplifies other failures
Imagine an application has an authorization flaw that lets a normal user export records belonging to another customer.
- With strong A09 controls, unusual export activity may trigger an alert within minutes.
- With weak A09 controls, the attacker may repeat the export until the customer notices missing or exposed data.
- With no usable audit trail, the organization may be unable to determine which records were accessed.
A09 often does not create the initial breach. It determines how long the breach lasts and whether its scope can be established.
What Is a Security Logging and Monitoring Failure?
A security logging and monitoring failure occurs when security-relevant activity is not recorded, is recorded without useful context, cannot be trusted, is not examined, does not generate actionable alerts, or does not lead to a timely response.
Common examples include:
- Failed logins are not recorded.
- Privilege changes appear only in generic application logs.
- Logs contain timestamps but no user ID or request ID.
- Application servers retain logs only on local disks.
- A compromised administrator can delete the audit trail.
- An alert fires, but there is no assigned owner or response procedure.
- Production logs contain passwords, access tokens, or payment details.
- A critical service stops sending logs, and nobody notices the silence.
A practical definition
An effective security event should allow an investigator to answer:
- When did it happen?
- What happened?
- Which account or service performed the action?
- Which resource was affected?
- From where did the activity originate?
- Was the action allowed or denied?
- Which other events belong to the same request or session?
- Can the record be trusted?
If several of these answers are missing, the log may exist but have little investigative value.
The Detection Lifecycle
| Stage | Minimum requirement | Typical failure |
|---|---|---|
| Generate | Emit meaningful security events | Only exceptions and HTTP 500s are logged |
| Collect | Forward events from all relevant systems | One cloud account or region is missing |
| Protect | Restrict access and preserve integrity | Attackers can delete local files |
| Analyze | Correlate behavior across sources | Each event is examined in isolation |
| Alert | Define thresholds, ownership, and urgency | Important alerts drown in noise |
| Respond | Investigate using a tested playbook | Nobody is on call |
The crucial insight
The lifecycle is only as strong as its weakest stage.
Perfect application logs do not help if they never reach central storage. Excellent SIEM rules do not help if the required events were never logged. Immediate alerts do not help if nobody owns the response.
A09 Compared with Other OWASP Categories
| Category | Primary concern | Relationship to A09 |
|---|---|---|
| A01 β Broken Access Control | Users can perform unauthorized actions | A09 should record denied access, unusual access patterns, and privilege changes |
| A03 β Injection | Untrusted input reaches an interpreter | A09 may reveal probing, validation failures, and unusual database behavior |
| A05 β Security Misconfiguration | Systems have unsafe settings | Missing or disabled audit logging can also be a misconfiguration |
| A08 β Software and Data Integrity Failures | Code, artifacts, or data cannot be trusted | A09 needs tamper-resistant logs and monitoring of builds and deployments |
| A09 β Logging and Monitoring Failures | Attacks cannot be detected or investigated effectively | A09 determines visibility across the other categories |
A09 is not a substitute for prevention. Logging an unauthorized data export does not make the export safe. It gives defenders a chance to discover, contain, and investigate it.
Real-World Lessons
5.1 Target: A detection is not a response
During the 2013 Target breach, attackers used compromised third-party access and ultimately stole payment-card data. Public reporting established that security tooling generated warnings about malicious activity, yet those warnings did not result in timely containment.
The lesson is not merely βinstall a detection product.β The lesson is:
An alert must have an owner, priority, investigation procedure, and escalation path.
5.2 Equifax: Monitoring blind spots matter
The 2017 Equifax breach began with exploitation of an unpatched Apache Struts vulnerability. Investigations also identified failures in security operations and visibility. An expired certificate affected a network monitoring toolβs ability to inspect relevant traffic.
The broader lesson is that the health of monitoring controls must itself be monitored.
Examples of alerts that deserve immediate attention include:
- An inspection certificate approaching expiration
- A log collector that stops receiving events
- A disabled audit policy
- A sharp drop in expected log volume
- A security agent that stops reporting
A dashboard showing βno suspicious activityβ is not reassuring if the sensor is offline.
5.3 SolarWinds: Monitor the software factory
The SolarWinds compromise demonstrated that a build and update pipeline can become an attackerβs distribution channel.
An A09 program should therefore cover not just production applications but also:
- Source-control administration
- CI/CD workflow changes
- Build-runner activity
- Secrets access
- Artifact publication
- Signing-key use
- Deployment approvals
If production is monitored but the build pipeline is invisible, attackers may compromise software before it reaches production.
5.4 The lesson behind long breach lifecycles
Incident reports often measure how long it takes organizations to identify and contain breaches. Those averages vary by study and year, but the operational implication remains the same: detection delay gives attackers time to move, persist, and expand impact.
Do not treat an industry-wide average as a target. For high-confidence eventsβsuch as a production audit log being disabledβthe desired response time should be measured in minutes, not months.
Relevant CWEs
A09 encompasses multiple weaknesses rather than one specific bug.
CWE-778 β Insufficient Logging
Security-relevant events are not recorded.
Example: An administrator changes another userβs MFA settings, but the application logs only "Settings updated".
Better event:
{
"event": "mfa_settings_changed",
"actor_id": "user_142",
"target_user_id": "user_827",
"action": "disable",
"outcome": "success",
"request_id": "req_68c2...",
"timestamp": "2025-02-20T12:40:18Z"
}CWE-223 β Omission of Security-Relevant Information
An event is logged, but essential context is missing.
Weak:
Login failed.Useful:
{
"event": "authentication_failed",
"account_reference": "acct_72f...",
"source_ip": "203.0.113.42",
"outcome": "denied",
"reason_category": "invalid_credentials",
"request_id": "req_68c2...",
"timestamp": "2025-02-20T12:40:18Z"
}The account_reference should be chosen to support investigation while minimizing unnecessary personal data in logs.
CWE-117 β Improper Output Neutralization for Logs
Attacker-controlled input changes the apparent structure of log output.
Example input:
alice
2025-02-20T12:40:19Z INFO administrator_login_successIf the application writes that value into a plain-text log without escaping line breaks, the attacker may forge what appears to be a second event.
CWE-532 β Insertion of Sensitive Information into a Log File
Logs contain secrets or private data that should never have been recorded.
Examples include:
- Passwords
- Session cookies
- Authorization headers
- API keys
- Password-reset links
- Payment-card numbers
- Medical information
Logging must preserve investigative value without creating a second database of sensitive information.
What Should Be Logged?
Start from security decisions and state changes, not from a generic rule to βlog every request.β
| Event family | Examples | Useful context |
|---|---|---|
| Authentication | Success, failure, MFA failure, session revocation | Account reference, outcome, source, request ID |
| Authorization | Denied access, privileged access | Actor, resource reference, policy decision |
| Account security | Password change, MFA enrollment, recovery | Actor, target, action, outcome |
| Privilege administration | Role grant/revoke, admin creation | Actor, target, old role, new role |
| Sensitive data access | Export, bulk download, unusual query | Actor, resource type, record count |
| Application defense | Rate limit, validation rejection | Rule ID, endpoint, source |
| Infrastructure | Audit logging disabled, firewall changed | Actor, system, old/new state |
| CI/CD | Workflow edit, artifact publication, deployment | Commit, actor, environment, artifact digest |
A useful security-event schema
{
"timestamp": "2025-02-20T12:40:18Z",
"event": "customer_data_export",
"severity": "high",
"outcome": "success",
"actor_id": "user_142",
"resource_type": "customer_records",
"resource_count": 12000,
"source_ip": "203.0.113.42",
"request_id": "req_68c2...",
"session_reference": "sess_hash_9db...",
"environment": "production"
}Design rules for event fields
- Use UTC timestamps and synchronized system clocks.
- Use a stable event name, not free-form prose.
- Include an outcome such as success, failure, or denied.
- Include request or trace IDs for cross-service investigation.
- Identify the actor and affected resource without dumping entire objects.
- Avoid placing attacker-controlled text in fields used as trusted labels.
- Define a schema and validate it in tests.
What Must Never Be Logged?
The correct objective is high-signal logging, not indiscriminate logging.
Secrets to exclude
- Passwords and password-reset tokens
- Session IDs and cookies
- OAuth access and refresh tokens
- API keys
- Private keys
- Authentication headers
- One-time passwords
- Full payment-card data and CVV
Data to minimize
- Email addresses
- Phone numbers
- IP addresses, where privacy rules apply
- Health information
- Government identifiers
- Full request bodies
- Search terms containing personal data
A safe practice is to log a non-reversible reference where possible:
Bad: session_token=eyJhbGciOi...
Better: session_reference=HMAC(session_token)If a token reference is needed for correlation, use a keyed digest with a protected key. Simply logging the first or last characters of a live token can expose information and should not be the default.
Privacy and retention are design questions
Before adding a field, ask:
- What detection or investigation requires it?
- Who can read it?
- How long will it be retained?
- Can the same purpose be served with less sensitive data?
- Is deletion or retention subject to applicable law or contractual requirements?
Log Injection and Evidence Tampering
9.1 Log injection
The vulnerable pattern:
logger.warning("Login failed for username: " + username)If username contains newline characters, a line-oriented log viewer may present attacker-controlled text as a separate event.
Defenses:
- Prefer structured logging.
- Escape or reject control characters in fields displayed as text.
- Limit field lengths.
- Encode logs safely in any web-based viewer.
- Do not interpret log content as shell commands or executable templates.
Parameterized logging improves performance and consistency, but it does not by itself make attacker-controlled text safe in every downstream log viewer. The output format and viewer also matter.
9.2 Log tampering
An attacker with access to an application server may try to delete or change local logs.
Recommended controls:
- Forward security logs off-host promptly.
- Put logging infrastructure in a separate security account or project.
- Restrict deletion and configuration permissions.
- Use immutable or retention-locked storage where appropriate.
- Alert when log forwarding stops.
- Test whether a compromised application identity can alter stored evidence.
Detection Engineering and Alerting
Collecting logs is the beginning of detection engineering, not the end.
A useful detection rule should specify:
- Threat hypothesis: What attacker behavior are we trying to identify?
- Required events: Which sources and fields must exist?
- Logic: What sequence or threshold indicates concern?
- Expected false positives: What legitimate activity might match?
- Owner: Who receives and investigates the alert?
- Response: What should that person do first?
- Test: How do we prove the rule still works?
Example: suspicious account takeover sequence
One failed login is usually low-confidence. A failed-login burst followed by successful access, MFA changes, and a bulk export is a much stronger signal.
Alerts worth designing early
| Detection | Typical signal | First response |
|---|---|---|
| Credential stuffing | Many failures across many accounts from related sources | Rate-limit, review affected accounts |
| Account takeover | Unusual login followed by sensitive account changes | Verify user, revoke sessions if warranted |
| Privilege escalation | Unexpected role grant or policy change | Confirm approval, inspect actor activity |
| Data exfiltration | Unusual export volume or destination | Preserve evidence, restrict access |
| Audit disablement | Logging configuration changed or source silent | Restore visibility and investigate immediately |
| CI/CD compromise | Unexpected workflow or release-signing change | Halt deployment and inspect artifacts |
Avoid alert fatigue
Do not make every validation failure a pager alert. Separate:
- Events: Recorded for investigation.
- Signals: Worth automated analysis.
- Alerts: Worth human review.
- Pages: Require immediate action.
Tune rules against actual traffic and regularly review missed incidents and false positives.
Cloud-Native Logging Challenges
Cloud and container environments create short-lived systems and fragmented evidence.
Kubernetes
Pods can disappear quickly. If their logs are only available on the node, the evidence may disappear with the workload.
Monitor:
- Kubernetes API audit events
- Changes to roles and role bindings
- Container creation with elevated privileges
- Secret access
- Admission-controller decisions
- Runtime alerts
- Missing logs from workloads expected to be active
Serverless
A single user request may cross several functions and managed services. Propagate trace IDs and ensure each function records relevant security decisions.
Multi-account and multi-region cloud
Verify that audit logging covers every applicable account, subscription, project, and region. A single omitted environment may become an investigative blind spot.
CI/CD
Production monitoring alone will not reveal every software supply-chain attack. Record and alert on:
- Repository permission changes
- Workflow modifications
- New deployment credentials
- Artifact digest changes
- Signing activity
- Unexpected releases
Vulnerable vs. Secure Code
12.1 π΄ Vulnerable: missing security events and leaked secrets
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# π΄ VULNERABLE β illustrative Flask endpoint
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
from flask import Flask, request
import logging
app = Flask(__name__)
logger = logging.getLogger(__name__)
@app.post("/login")
def login():
username = request.form.get("username", "")
password = request.form.get("password", "")
# Dangerous: writes a password to a log.
logger.info("Login request: username=%s password=%s", username, password)
user = find_user(username)
if user and verify_password(user, password):
return {"status": "ok"}, 200
# Dangerous: no useful authentication-failure event.
return {"error": "Invalid credentials"}, 401Problems:
- The password enters the log.
- Failure events lack context.
- There is no request identifier.
- User-controlled text may create confusing output in line-oriented logs.
- Investigators cannot reliably correlate the login with other activity.
12.2 π’ Secure: structured, minimal authentication events
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# π’ SECURE β illustrative Flask endpoint
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
from flask import Flask, request, g
from datetime import datetime, timezone
import json
import logging
import uuid
app = Flask(__name__)
logger = logging.getLogger("security")
@app.before_request
def assign_request_id():
g.request_id = str(uuid.uuid4())
def security_event(event_name, outcome, **fields):
event = {
"timestamp": datetime.now(timezone.utc).isoformat(),
"event": event_name,
"outcome": outcome,
"request_id": g.request_id,
**fields,
}
# Structured JSON keeps individual fields separate.
# Forward this output to protected, centralized storage.
logger.info(json.dumps(event, ensure_ascii=True))
@app.post("/login")
def login():
username = request.form.get("username", "")
password = request.form.get("password", "")
user = find_user(username)
if user and verify_password(user, password):
security_event(
"authentication",
"success",
actor_id=str(user.id),
authentication_method="password",
)
return {"status": "ok"}, 200
security_event(
"authentication",
"failure",
# Use a privacy-reviewed reference rather than recording
# the raw username when it is not necessary.
attempted_account_reference=account_reference(username),
reason_category="invalid_credentials",
)
# Keep the client response generic to avoid account enumeration.
return {"error": "Invalid credentials"}, 401Important: account_reference() should be a stable, privacy-reviewed implementation, such as an HMAC-based reference. Do not replace it with Pythonβs built-in hash(), which is unsuitable as a durable identifier.
The example focuses on logging; production authentication also needs rate limiting, secure sessions, and appropriate MFA.
12.3 π΄ Vulnerable: request-body logging
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// π΄ VULNERABLE
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
app.use((req, res, next) => {
console.log({
path: req.path,
headers: req.headers, // May include Authorization and Cookie.
body: req.body // May include passwords or payment data.
});
next();
});12.4 π’ Secure: explicitly selected fields
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// π’ SECURE
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const crypto = require("node:crypto");
app.use((req, res, next) => {
const requestId = crypto.randomUUID();
req.requestId = requestId;
const event = {
timestamp: new Date().toISOString(),
event: "http_request",
request_id: requestId,
method: req.method,
route: req.route?.path ?? req.path,
// Do not log Authorization, Cookie, or entire request bodies.
};
securityLogger.info(event);
next();
});An allowlist of fields is generally safer than attempting to redact an unrestricted copy of every request. Redaction rules can miss new fields or unexpected nesting.
12.5 π’ Detection pseudocode: source silence
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# π’ MONITOR THE MONITORING SYSTEM
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
EXPECTED_SOURCES = {
"production-api",
"identity-provider",
"deployment-pipeline",
"cloud-audit",
}
for source in EXPECTED_SOURCES:
last_seen = get_last_event_timestamp(source)
if last_seen is None or minutes_since(last_seen) > 10:
create_high_priority_alert(
rule="security_log_source_silent",
source=source,
description="Expected security events are not arriving.",
)Thresholds should reflect each sourceβs normal event frequency. A service that legitimately emits one event per day needs a different heartbeat strategy from a busy API.
Tools and Standards
| Resource | Purpose |
|---|---|
| OWASP Logging Cheat Sheet | Guidance on what to log, what to exclude, and how to protect logs |
| OpenTelemetry | Standardized telemetry and cross-service correlation |
| Elastic Security | Search, analysis, and security detection |
| Splunk Enterprise Security | SIEM and detection workflows |
| Microsoft Sentinel | Cloud-native SIEM |
| Wazuh | Open-source security monitoring |
| Grafana Loki | Log aggregation and investigation |
| Fluent Bit | Log collection and forwarding |
| Sigma | Portable detection-rule format |
| MITRE ATT&CK | Model attacker techniques and detection coverage |
| NIST SP 800-92 | Security log management guidance |
| Cloud-provider audit services | Record cloud control-plane activity |
No tool automatically solves A09. The important questions remain: Are the right events present? Are detections tested? Are alerts owned? Can responders act?
Interactive Review Widget
The following disclosure widget works in Markdown renderers that permit basic HTML. Renderers that strip HTML will still show the checklist below it.
<details> <summary><strong>π§ͺ Five-minute A09 self-assessment β click to expand</strong></summary>
Ask your team:
- If a production administrator disables audit logging, who receives an alert?
- Can an application administrator delete centrally stored security events?
- Can you trace a suspicious request across all relevant services?
- Can you identify every bulk export performed by one account last week?
- When did you last test a detection rule end to end?
If any answer is βwe do not know,β that uncertainty is itself an A09 finding.
</details>
Note: Animated HTML or JavaScript widgets require an HTML-capable publishing pipeline. Basic .md files do not provide portable JavaScript interactivity; Mermaid diagrams, tables, checkboxes, and <details> are the Markdown-compatible alternatives used here.
β Ultimate Checklist
Event design
- [ ] Authentication successes and failures are recorded.
- [ ] MFA enrollment, removal, and failures are recorded.
- [ ] Privilege and permission changes are recorded.
- [ ] Sensitive data exports are recorded.
- [ ] Administrative configuration changes are recorded.
- [ ] Events contain a timestamp, outcome, actor reference, and request ID.
- [ ] Event names and fields follow a documented schema.
- [ ] Relevant systems synchronize their clocks.
Sensitive-data protection
- [ ] Passwords are never logged.
- [ ] Session cookies and live tokens are never logged.
- [ ] Authorization headers are excluded.
- [ ] Payment and health data are excluded unless a narrowly defined requirement permits specific fields.
- [ ] Log-field choices are reviewed for privacy impact.
- [ ] Log viewers safely render attacker-controlled text.
Collection and integrity
- [ ] Security logs are forwarded to central storage.
- [ ] Access to log storage follows least privilege.
- [ ] Application identities cannot delete centrally stored logs.
- [ ] Appropriate retention and immutability controls are configured.
- [ ] Missing log sources trigger alerts.
- [ ] Logging-agent failures trigger alerts.
- [ ] Log ingestion and storage failures are tested.
Detection and response
- [ ] High-risk behaviors have documented detection rules.
- [ ] Alerts have owners and severity levels.
- [ ] Critical alerts have response playbooks.
- [ ] Detection rules are tested with realistic events.
- [ ] False positives are reviewed and tuned.
- [ ] Incident exercises verify that responders can retrieve needed evidence.
- [ ] Monitoring covers production and CI/CD infrastructure.
Cloud and containers
- [ ] Cloud audit logging covers required accounts and regions.
- [ ] Kubernetes audit logs are collected where applicable.
- [ ] Ephemeral workload logs are forwarded before workloads disappear.
- [ ] Deployment and artifact-publication events are monitored.
- [ ] Cross-service request or trace IDs are propagated.
Conclusion
Security logging and monitoring are not a pile of log files. They are an operational promise:
When something important happens, we will record it accurately, preserve the evidence, recognize the danger, and act.
Five takeaways
- Record security decisions, not just application errors.
- Protect logs as evidence; do not rely only on files stored on the affected server.
- Minimize sensitive data so logging does not create another breach surface.
- Monitor the monitoring system for missing sources and disabled controls.
- Test the entire chain, from event generation to human response.
Final rule: If your team cannot explain how it would discover and investigate a specific attack, that attack may already be happening without anyone knowing.
Further Reading
| Resource | Link |
|---|---|
| OWASP Top 10 β A09:2021 | https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/ |
| OWASP Logging Cheat Sheet | https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html |
| OWASP Application Logging Vocabulary | https://owasp.org/www-project-application-logging-vocabulary/ |
| MITRE ATT&CK | https://attack.mitre.org/ |
| Sigma detection rules | https://github.com/SigmaHQ/sigma |
| OpenTelemetry | https://opentelemetry.io/ |
| NIST SP 800-92 β Guide to Computer Security Log Management | https://csrc.nist.gov/pubs/sp/800/92/final |
Category: OWASP Top 10 Β· A09:2021 Β· Security Logging Β· Monitoring Β· Detection Engineering Β· Incident Response Β· DevSecOps
A log that nobody can find is not evidence.
An alert that nobody owns is not a response.
Visibility is a security control only when it leads to action.