01 / 20

Security
Logging

Learn how authentication logs, network logs, and application logs work together to protect systems and detect threats.

Cyber Security

What Are Security Logs?

A security log is a chronological record of events generated by systems, applications, and network devices. Every time a user logs in, a file is accessed, or a packet crosses a firewall, the event can be captured as a log entry.

Why Logging Matters

★ Detection
Spot unauthorized access, malware, and anomalies as they occur or shortly after.
★ Investigation
Trace an attacker's steps through the system to understand scope and impact of a breach.
★ Compliance
Meet regulatory requirements (HIPAA, PCI-DSS, GDPR) that mandate log collection and retention.

Anatomy of a Log Entry

2024-03-15 09:23:47 | AUTH | INFO | user=jdoe | action=LOGIN_SUCCESS | ip=192.168.1.42 Timestamp When it happened Source Which system / layer Severity INFO / WARN / ERROR Actor Who did it Context Action, IP, resource Every log entry answers: Who? What? When? Where?

The Three Core Log Types

Security Logs Auth Logs Network Logs Application Logs Logins, logouts, password changes Firewall, DNS, traffic flow

Authentication Logs

Authentication logs record every identity-related event: successful logins, failed login attempts, account lockouts, password resets, privilege escalations, and logoffs. They are the first place to look when investigating unauthorized access.

1
Login success/failure: Records username, source IP, timestamp, and whether credentials were accepted.
2
Account lockout: Triggered after repeated failures: a strong indicator of brute-force attacks.
3
Privilege escalation: When a user gains admin/root permissions: must be monitored closely.

Network Logs

Network logs capture data about traffic flowing through routers, switches, firewalls, and intrusion detection systems (IDS). They reveal who is talking to whom, what ports and protocols are in use, and whether traffic was allowed or blocked.

Firewall Logs
Record allowed/denied connections with source IP, dest IP, port, and protocol.
DNS Logs
Track domain name lookups: reveal C2 callbacks and data exfiltration via DNS tunneling.
Flow Logs
Summarize traffic metadata (NetFlow/sFlow): bytes, packets, and duration per connection.

Application Logs

Application logs come from the software layer: web servers, databases, email servers, and custom applications. They capture user actions, errors, and transactions inside the application boundary.

1
Web server logs: HTTP requests and responses (method, URL, status code, user-agent).
2
Database logs: Queries executed, schema changes, and failed access attempts to restricted tables.
3
Error/exception logs: Stack traces and crashes that may indicate exploitation of a vulnerability.

Key Distinction: Three Log Types

Authentication Network Application
Focus Identity Traffic Behavior
Answers Who accessed? Where did data go? What did they do?
Sources OS, AD, IAM Firewall, IDS, router Web/DB/email server
Example Event Failed login ✕ 5 Blocked port scan SQL injection attempt
Detection Brute force, insider Lateral movement Exploit, data theft

How Logs Work Together

1. Auth Log 5 failed logins from IP 2. Network Log IP scanning ports 3. App Log SQL injection detected SIEM: Correlate All Logs Security Information and Event Management ALERT: Active Attack

Setting Up Effective Logging

1
Identify critical assets: Determine which servers, applications, and network segments must generate logs.
2
Enable all three log types: Configure auth logs (OS/AD), network logs (firewall/IDS), and application logs (web/DB).
3
Centralize with a SIEM: Forward all logs to a single platform for correlation and search.
4
Set retention policies: Store logs for a defined period (90 days to 1 year) based on compliance needs.
5
Create alert rules: Define thresholds (e.g., 5+ failed logins in 60 seconds) that trigger real-time alerts.

Example: Detecting a Brute Force Attack

09:01 FAIL #1 09:01 FAIL #2 09:02 FAIL #3 09:02 LOCKOUT 09:03 ALERT Auth Log: Failed logins SIEM: Alert triggered Authentication Log Timeline

Example: Tracing Lateral Movement

Workstation Compromised SMB File Server Accessed RDP DB Server Data Exfil Auth Log: login Network: SMB/RDP App: DB queries SIEM correlates all 3 log types into one attack chain

Example: Web Application Attack

GET /login?user=admin&pass=' OR '1'='1 HTTP/1.1 403 Forbidden GET /login?user=admin&pass=test123 HTTP/1.1 401 Unauth POST /admin/export?table=users HTTP/1.1 200 OK SUSPICIOUS SQL Injection Credential Guess Data Exfiltration

Common Mistakes

✕ Logging Too Little
Only enabling one log type leaves blind spots. All three types (auth, network, app) are needed for full coverage.
✕ No Centralization
Logs scattered across individual machines are nearly impossible to correlate during an incident.
✕ Ignoring Retention
Deleting logs after a few days means you lose evidence for attacks discovered weeks later.

Summary Comparison

Aspect Auth Logs Network Logs App Logs
Layer Identity Transport Application
Key Data User, result, IP Src/dst IP, port, protocol URL, query, status
Detects Brute force, insider Scanning, C2, exfil Injection, abuse
Source OS, AD, SSO Firewall, IDS, router Web/DB/mail server
When to Check Unauthorized access Unusual traffic App errors/exploits

Question 1 of 5

A security analyst sees 50 failed login attempts for the same account within 2 minutes. Which log type primarily captured this activity?

Question 2 of 5

Which of the following would best be detected using network logs?

Question 3 of 5

What is the primary purpose of a SIEM in security logging?

Question 4 of 5

An attacker has compromised a workstation and is using RDP to access a database server. Which combination of logs would best reveal the full attack path?

Question 5 of 5

A web server log shows the request: GET /search?q=' OR '1'='1. What type of attack does this entry most likely indicate?