TExcelTAD

Time Sync, Time Zones and Event Order

An investigation timeline says the attacker copied the payroll file at 10:04 and logged on at 10:09: the copy happened before the logon. That is impossible, and the explanation is always the same: one of the sources logs local time, or one of the clocks is wrong. Correlation rules ("failure, then success, within 10 minutes"), sequence detections and every incident timeline assume that timestamps from different machines can be compared. This lesson shows how they break and how to make them comparable.

Three separate problems

  1. Clock accuracy: the machine's clock is wrong (drift, a dead CMOS battery, a VM restored from a snapshot, a host that never synced).
  2. Time-zone representation: the clock is right, but the log writes local time without saying which zone, or in a format that drops the year or the offset.
  3. Event versus ingestion time: the event happened at one time and reached the SIEM later (Collecting, Shipping and Retaining Logs).

Keeping clocks right

  • Every system syncs with NTP (chrony or systemd-timesyncd on Linux, the Windows Time service, which in a domain follows the domain hierarchy up to the PDC emulator). Use a small set of internal NTP servers that themselves sync with several reliable upstream sources.
  • Kerberos needs it: by default a client whose clock differs from the DC's by more than 5 minutes cannot get tickets, which is a useful alarm in itself.
  • Monitor offset: chrony and the Windows Time service report the current offset; alert when it exceeds, say, one second on servers.
  • NTS (Network Time Security, RFC 8915) authenticates NTP, so an attacker on the network cannot shift clocks.

Writing time so it can be compared

The rule is: store and compare in UTC, with an explicit offset, in ISO 8601 (2026-01-15T10:01:07Z or 2026-01-15T17:01:07+07:00), and convert to local time only for display. The session shows why everything else is fragile (in your sandbox; no network):

bash · try it yourself
# One instant, written four ways.
t=1768471267                                   # epoch seconds (UTC by definition)
date -u -d @$t '+%Y-%m-%dT%H:%M:%SZ'           # ISO 8601 in UTC
TZ=Asia/Ho_Chi_Minh date -d @$t '+%Y-%m-%d %H:%M:%S %z (%Z)'
TZ=America/New_York date -d @$t '+%Y-%m-%d %H:%M:%S %z (%Z)'
TZ=Europe/Berlin date -d @$t '+%b %e %H:%M:%S'  # legacy syslog style: no year, no zone
echo "--"
# A local time without an offset can be ambiguous: 02:30 happens twice in Berlin on 2026-10-25.
TZ=Europe/Berlin date -d '2026-10-25 02:30 CEST' -u '+%H:%M UTC (first 02:30, summer time)'
TZ=Europe/Berlin date -d '2026-10-25 02:30 CET' -u '+%H:%M UTC (second 02:30, winter time)'
# ...and in spring 02:30 does not exist at all.
TZ=Europe/Berlin date -d '2026-03-29 02:30' 2>&1 || true
2026-01-15T10:01:07Z
2026-01-15 17:01:07 +0700 (+07)
2026-01-15 05:01:07 -0500 (EST)
Jan 15 11:01:07
--
00:30 UTC (first 02:30, summer time)
01:30 UTC (second 02:30, winter time)
date: invalid date ‘2026-03-29 02:30’
  • The same instant is 10:01 in UTC, 17:01 in Ho Chi Minh City and 05:01 in New York. Only the forms with Z or an offset can be compared without outside knowledge.
  • The legacy syslog form Jan 15 11:01:07 has no year and no zone; the collector has to guess both, and guesses wrong around New Year and for remote sites.
  • On the night daylight saving time ends, local 02:30 happens twice (00:30 and 01:30 UTC in Berlin); on the night it starts, local 02:30 does not exist. A log that writes local time without offset is ambiguous for an hour every year.

Merging sources: wrong and right

The program builds a short incident from three synthetic sources: the branch office firewall writes local time without offset (it sits in Ho Chi Minh City, UTC+7), the DC writes UTC, and the EDR writes epoch milliseconds. A naive merge treats all three as UTC.

python · try it yourself
import pandas as pd

fw = pd.DataFrame({"t": ["2026-01-15 17:03:50", "2026-01-15 17:04:30"],            # local time, no offset
                   "src": "firewall", "what": ["VPN session from 198.51.100.23 accepted", "SMB 10.10.0.17 -> fs01 allowed"]})
dc = pd.DataFrame({"t": ["2026-01-15T10:03:58Z", "2026-01-15T10:04:05Z"],
                   "src": "dc01", "what": ["4625 erin failure", "4624 erin success (type 3)"]})
edr = pd.DataFrame({"t": [1768471500000, 1768471560000],                            # epoch ms
                    "src": "edr fs01", "what": ["robocopy.exe payroll.xlsx -> \\\\ws17\\c
quot;, "7z.exe a out.7z"]}) def naive(df): # everything parsed as if it were UTC t = pd.to_datetime(df.t, unit="ms") if df.t.dtype != object else pd.to_datetime(df.t, utc=True).dt.tz_localize(None) return df.assign(t=t) def correct(df, zone=None): if df.t.dtype != object: t = pd.to_datetime(df.t, unit="ms", utc=True) elif zone: t = pd.to_datetime(df.t).dt.tz_localize(zone).dt.tz_convert("UTC") else: t = pd.to_datetime(df.t, utc=True) return df.assign(t=t) for title, frames in [("NAIVE (firewall local time read as UTC)", [naive(fw), naive(dc), naive(edr)]), ("CORRECT (firewall zone Asia/Ho_Chi_Minh)", [correct(fw, "Asia/Ho_Chi_Minh"), correct(dc), correct(edr)])]: print(title) for r in pd.concat(frames).sort_values("t").itertuples(): print(f" {r.t:%H:%M:%S} {r.src:9} {r.what}")
NAIVE (firewall local time read as UTC)
  10:03:58  dc01      4625 erin failure
  10:04:05  dc01      4624 erin success (type 3)
  10:05:00  edr fs01  robocopy.exe payroll.xlsx -> \\ws17\c$
  10:06:00  edr fs01  7z.exe a out.7z
  17:03:50  firewall  VPN session from 198.51.100.23 accepted
  17:04:30  firewall  SMB 10.10.0.17 -> fs01 allowed
CORRECT (firewall zone Asia/Ho_Chi_Minh)
  10:03:50  firewall  VPN session from 198.51.100.23 accepted
  10:03:58  dc01      4625 erin failure
  10:04:05  dc01      4624 erin success (type 3)
  10:04:30  firewall  SMB 10.10.0.17 -> fs01 allowed
  10:05:00  edr fs01  robocopy.exe payroll.xlsx -> \\ws17\c$
  10:06:00  edr fs01  7z.exe a out.7z

The naive timeline puts the VPN session seven hours after the file copy, so an analyst would conclude that the VPN user had nothing to do with it. The corrected one tells the real story in order: VPN in, a failed and a successful logon, SMB to the file server, then the copy and the archive.

Detecting a wrong clock

When two sources record the same event (a logon seen by the DC and by the target host, a connection seen by the firewall and by the EDR), the difference between their timestamps estimates the offset between their clocks. Collect such pairs per host and look at the median:

python · try it yourself
import pandas as pd

pairs = pd.DataFrame({  # the same logons as written by the DC (reference) and by the target host
    "host": ["fs01", "fs01", "fs01", "ws17", "ws17", "ws17", "ws22", "ws22"],
    "dc_time":   pd.to_datetime(["10:00:01", "10:20:05", "10:40:10", "10:05:00", "10:25:30", "10:45:02", "10:10:00", "10:30:00"], format="%H:%M:%S"),
    "host_time": pd.to_datetime(["10:00:01", "10:20:06", "10:40:10", "10:12:21", "10:32:52", "10:52:24", "10:09:59", "10:30:00"], format="%H:%M:%S"),
})
pairs["offset_s"] = (pairs.host_time - pairs.dc_time).dt.total_seconds()
est = pairs.groupby("host").offset_s.median()
print(est.to_string())
print("\nhosts with offset > 60 s:", list(est[est.abs() > 60].index))
host
fs01      0.0
ws17    442.0
ws22     -0.5

hosts with offset > 60 s: ['ws17']

ws17 runs 7 minutes 22 seconds (442 s) fast: every event from it must be shifted back (or flagged) before correlation, and its time configuration fixed. Within Kerberos's 5-minute tolerance a skew goes unnoticed by users; beyond it, users see sign-in errors, which is often how skew is first reported.

How it is fixed and prevented

  • NTP everywhere, from internal servers, with offset monitoring and NTS where supported.
  • Configure sources to log UTC with an offset, or record each source's zone in the collector and convert at ingestion. Never leave conversion to the analyst.
  • Keep three times per event when you can: event time from the source, ingestion time, and the original timestamp string.
  • Display the zone in every timeline and report.

Pitfalls

  • Converting twice. A source already in UTC, "corrected" again by the collector, ends up hours off. Test each source's mapping with a known event.
  • Trusting attacker-controlled clocks. On a compromised host, the attacker can change the clock or file timestamps ("timestomping"); prefer timestamps recorded elsewhere (the DC, the network, the SIEM's ingestion time) for key events.
  • Sub-second order. Two events in the same second from different hosts have no reliable order; don't build rules that depend on it.

Practice

1. A log line reads `Mar 29 02:30:12 fw01 ...` from a firewall in Berlin. What UTC time is it?

None: on 29 March 2026 clocks in Berlin jump from 02:00 to 03:00, so 02:30 local time does not exist. Either the firewall is not on Berlin time (perhaps UTC, or no DST), or its clock is wrong. Check its configuration; don't guess.

2. In the second program, change ws22's second host time to 10:29:20. What does the median report, and why the median?

ws22's offsets become −1 s and −40 s; with two values the median is their average, −20.5 s, still under the 60 s threshold. The median resists a single bad pair (an event matched to the wrong DC record) better than the mean; collect more pairs per host for a reliable estimate.

3. Why should an incident report state the time zone of every timestamp?

Readers in different places assume their own zone; a report without zones leads to wrong conclusions about order and about working hours (a logon at "03:00" is suspicious only if it is 03:00 for that user).

Test yourself

Which timestamp form can be compared across sources without outside knowledge?

  1. Jan 15 11:01:07
  2. 2026-01-15 17:01:07
  3. 2026-01-15T10:01:07Z
  4. 17:01

What happens to local time 02:30 in Berlin on the night daylight saving time ends?

  1. It doesn't exist
  2. It happens twice, so a local timestamp without offset is ambiguous
  3. It becomes UTC
  4. Nothing special

In the naive merge, why did the VPN session appear after the file copy?

  1. The VPN logs were late
  2. The firewall's local time (UTC+7) was read as UTC, putting it seven hours too late
  3. The EDR clock was wrong
  4. pandas sorts randomly

How can you estimate a host's clock offset from logs?

  1. Ask the user
  2. Compare its timestamps with another source's timestamps for the same events, such as the DC's record of the same logons
  3. Read the BIOS
  4. It cannot be done