Nouvelle réglementation de cybersécurité 2026 en vigueur au Maroc. Obtenir un audit de conformité gratuit →
← Retour au blog
Owasp 2025-04-14 ⏱️ 15 min

Insufficient Logging & Monitoring: why breaches go undetected

Insufficient Logging & Monitoring: Why Major Breaches Go Undetected

Security is not just about building impenetrable walls; it is equally about detecting when those walls have been breached. According to recent industry reports, the average time to identify and contain a data breach (the "dwell time") frequently exceeds 200 days. This alarming statistic is directly attributable to one of the most persistent flaws in the OWASP Top 10: Insufficient Logging and Monitoring.

In this detailed technical guide, Cayvora Security investigates why poorly implemented logging allows threat actors to silently pivot through corporate networks, and provides a comprehensive blueprint for building a resilient centralized logging architecture in 2025.

The Cost of Silence

When a cyberattack occurs, the organization is effectively flying blind without adequate logs. Insufficient logging prevents security analysts from answering critical incident response questions:

  1. Patient Zero: How did the attacker initially gain access?
  2. Blast Radius: Which systems and databases were accessed by the compromised account?
  3. Data Exfiltration: What specific sensitive data was stolen?

Without answers to these questions, forensic teams cannot confidently declare an incident "contained." They are forced to assume worst-case scenarios, wildly inflating the financial and reputational costs of regulatory disclosures.

Common Logging Failures

Insufficient logging is not merely the absence of log files; it encompasses several critical anti-patterns in application development.

1. Missing Security-Relevant Events

Standard web servers inherently log access requests (e.g., HTTP 200 OK or 404 Not Found), but standard logs lack application-level context. Applications fail when they do not explicitly log: - Authentication Events: Successful logins, failed logins, password resets, and account lockouts. - Authorization Failures: A user attempting to access a resource explicitly forbidden to their role (a massive indicator of an active IDOR attempt). - High-Value Business Logic: Modifications to payment logic, bulk data exports, or privilege escalation/role assignments.

2. Inadequate Log Context

A log entry simply stating ["ERROR"]: Database connection failed is useless. A high-fidelity log must provide the "Who, What, Where, When, and Why." - Improper: Auth Failed - Proper: timestamp="2025-04-14T08:12:45Z" event="AUTH_FAILED" user_id="10452" source_ip="192.168.1.55" endpoint="/api/v1/login" reason="Invalid Password"

3. Log Exfiltration and Manipulation

If application logs are only stored locally on the web server's hard drive (/var/log/app.log), an attacker who achieves Remote Code Execution (RCE) will simply delete or manipulate the log file to cover their tracks before they disconnect.

# Attacker covering tracks by nullifying the log file
echo "" > /var/log/nginx/access.log
rm -rf /var/log/auth.log

Designing a Resilient Logging Architecture

To detect attacks in real-time, organizations must transition from passive logging to active Security Information and Event Management (SIEM).

1. Centralized Log Aggregation

Log events must be immediately streamed off the originating server to a secure, immutable, centralized repository. Technologies like the ELK Stack (Elasticsearch, Logstash, Kibana), Splunk, or Datadog consolidate logs from all web servers, firewalls, and databases into a single pane of glass.

By forwarding logs instantly (e.g., using rsyslog or Filebeat), subsequent tampering of the local web server by an attacker does not alter the centralized forensic record.

2. Standardized Structured Logging

Logs should be output in a structured, machine-readable format—typically JSON. This prevents developers from writing arbitrary string logs that break SIEM parsing rules.

{
  "@timestamp": "2025-04-14T15:30:10.000Z",
  "level": "WARN",
  "app_name": "billing-service",
  "event_type": "ACCESS_DENIED",
  "actor": {
    "ip": "203.0.113.88",
    "user_id": "U-8819",
    "role": "customer"
  },
  "target_resource": "api/v1/admin/reports",
  "message": "User attempted to access restricted admin endpoint."
}

Structured JSON logs allow the SIEM to instantly index the actor.ip and event_type fields, enabling high-speed querying.

3. Proactive Alerting (Active Monitoring)

Logs are useless if nobody is looking at them. Alerting rules must be configured to trigger immediate notifications (via Slack, PagerDuty, or Email) to the Security Operations Center (SOC) when specific thresholds are breached.

Crucial Alert Thresholds: - Credential Stuffing: >50 failed login attempts from a single IP address in 60 seconds. - Data Exfiltration: A standard user role exporting database records exceeding 50MB. - RCE Detection: The execution of suspicious operating system commands (e.g., whoami, curl, wget) originating from the web application's user process.

Handling Sensitive Data in Logs

A critical aspect of logging is ensuring that you do not inadvertently violate compliance standards (GDPR, PCI-DSS) by writing sensitive data to the logs.

Developers must implement Log Masking or Scrubbing filters in the logging library to ensure that PII (Personally Identifiable Information), passwords, session tokens, and credit card numbers are never committed to disk.

# Improper: Logging the entire raw request object
logger.info(f"Incoming Registration Request: {request.body}")

# Proper: Masking sensitive fields before logging
masked_body = mask_sensitive_fields(request.body, fields=['password', 'ssn'])
logger.info(f"Incoming Registration Request: {masked_body}")

Conclusion

Insufficient Logging and Monitoring transforms minor security incidents into catastrophic uncontained breaches. By treating structured logging as a core architectural requirement and streaming those logs to a centralized monitoring system with strict alerting thresholds, organizations can detect threat actors within minutes, rather than months.

Are you blind to active attackers?

Ensure your centralized logging and SIEM alerts can actively detect a real cyberattack. Talk to Cayvora Security's Incident Response team.

📱 Contact Us on WhatsApp

Besoin d'un audit de sécurité ?

Contactez Cayvora pour une consultation gratuite et protégez votre entreprise contre les cybermenaces.

📱 Contacter via WhatsApp

Articles connexes