The Academy is free // the war room is optional
DAEMONCORE // ACADEMY
← FIELD NOTES

Detecting log tampering with clock skew and impossible events

2024.09.03//8 MIN READlog-analysisincident-responsedigital-forensicssecurity-architecture

// Understanding Clock Skew

In environments where multiple systems interact, clock skew can introduce significant discrepancies in log timestamps. For instance, if two machines have a time difference of several minutes, log entries may appear out of order, which can be a red flag for tampering. Use the following command to check the current time and compare it across machines:

# Check system time
date

When working with distributed systems, ensure NTP (Network Time Protocol) is configured correctly:

# Install NTP and check status
sudo apt-get install ntp
sudo service ntp status

Verify the NTP configuration:

# View NTP configuration
cat /etc/ntp.conf

// Impossible Event Sequences

Another critical aspect in detecting log tampering is identifying impossible event sequences. An attacker might delete or modify logs to create a narrative that masks their activities. For example, if a log entry for a successful login appears after a log entry for accessing sensitive files, it raises suspicion. Consider this log sequence:

2023-10-01 12:00:00 UserA logged in
2023-10-01 12:01:00 UserA accessed /etc/shadow
2023-10-01 12:02:00 UserA logged out
2023-10-01 12:03:00 UserA logged in again

In this example, the second login doesn't make sense if the user logged out immediately after accessing sensitive data. A basic strategy to detect this can involve scripting:

# Check for impossible sequences
awk '{if($3 ~ /logged in/ && prev ~ /logged out/) {print "Possible tampering detected: " $0;}}' log.txt

// Methodology for Log Integrity Verification

1. Automate Log Collection: Centralize log management with tools such as ELK Stack or Graylog. This prevents local tampering and provides a single point to analyze events. 2. Implement Time Synchronization: Ensure all systems use NTP or chrony to keep time synchronized. Monitor NTP logs for unauthorized changes. 3. Check for Anomalies: Use scripts to regularly analyze log sequences. This includes checking for clock skew and impossible event sequences, as detailed above. 4. Regular Audits: Schedule periodic log reviews to identify discrepancies or tampered entries. Automated tools can assist in this process. 5. Alerting Mechanisms: Set up alerts for anomalous log patterns, such as multiple logins from the same user in a short time frame.

// Defensive Implications

If logs are compromised, so too is the integrity of the security posture. By enforcing strict access controls and monitoring, you can mitigate risks:

  • Use chmod to Restrict Log Access: Ensure that only necessary users have access to logs.
  • Implement Logging Policies: Define what events should be logged and regularly review policies for relevance.
  • Conduct Regular Training: Keep your team informed about the latest threats and log management best practices.

// Checklist for Log Integrity

  • [ ] Verify that NTP is configured and functioning on all systems.
  • [ ] Regularly analyze logs for impossible event sequences.
  • [ ] Review user access to logs on a monthly basis.
  • [ ] Setup automated alerts for any unusual log patterns.

Detecting log tampering isn’t a one-time event but a continuous process that requires diligence and proactive strategies. By focusing on clock skew and impossible sequences, you can better safeguard your environment against deceptive practices that compromise your logs.

DaemonCore Academy offers free curriculum resources to enhance your skills in these areas. Always apply these techniques in a controlled environment you own, such as a disposable lab range.