OWASP Top 10 Security Lab

A09

Security Logging and Monitoring Failures

Learn to identify missing security logging and poor incident response

What are Security Logging and Monitoring Failures?

Security Logging and Monitoring Failures occur when applications and systems fail to properly log security events, monitor for malicious activity, or respond to incidents in a timely manner. This makes it difficult or impossible to detect breaches until significant damage has occurred.

🎯 Common Failure Scenarios

  • Insufficient Logging: Not logging authentication failures, access control violations, or input validation failures
  • Inadequate Log Protection: Logs stored without integrity protection or in insecure locations
  • Poor Log Quality: Missing context, timestamps, or crucial security information
  • No Real-time Monitoring: Lack of active monitoring and alerting for suspicious activities
  • Delayed Incident Response: No established processes for investigating and responding to security events

⚠️ Real-World Impact

  • Extended Breach Window: Attackers can remain undetected for months or years
  • Compliance Violations: Failure to meet regulatory logging requirements (PCI-DSS, GDPR, HIPAA)
  • Forensic Blindness: Inability to understand attack scope or implement proper containment
  • Repeat Attacks: Same vulnerabilities exploited multiple times without detection

📊 Detection Statistics

  • Average time to detect a breach: 207 days (IBM Security Report 2023)
  • Cost difference between breaches detected in <200 days vs >200 days: $1.12M USD
  • Organizations with security AI/automation save an average of $1.76M in breach costs

🛡️ Prevention and Detection Strategies

  • Comprehensive Logging: Log all authentication, authorization, and input validation failures
  • Centralized Log Management: Use SIEM/SOAR solutions for correlation and analysis
  • Real-time Monitoring: Implement automated alerting for suspicious patterns
  • Regular Log Review: Periodic manual review and threat hunting activities
  • Incident Response Plan: Documented procedures for handling security incidents
# Poor Logging Example def login_attempt(username, password): if authenticate(username, password): return True else: print("Login failed") # Insufficient logging! return False # Proper Security Logging import logging import json from datetime import datetime def login_attempt(username, password, source_ip, user_agent): timestamp = datetime.utcnow().isoformat() if authenticate(username, password): security_logger.info(json.dumps({ "event": "authentication_success", "timestamp": timestamp, "username": username, "source_ip": source_ip, "user_agent": user_agent, "session_id": generate_session_id() })) return True else: security_logger.warning(json.dumps({ "event": "authentication_failure", "timestamp": timestamp, "username": username, "source_ip": source_ip, "user_agent": user_agent, "failure_reason": "invalid_credentials", "attempt_count": get_failed_attempts(username, source_ip) })) return False