Corrobora Development Series Part 4: What Happened When I Tested the Timestamps (and What BAM Was Actually Recording)

 




In Part 3 I mentioned I’d write about the timing results next, so here they are. Out of everything so far, this work changed Corrobora the most.


At this point the project had parsers for Event Logs, the Registry, Prefetch and the MFT, plus some rules that compared them against each other. I originally wrote those rules with anti-forensics in mind. So whenever an artifact was missing, the tool would point toward the idea that something may have been deleted. The more I worked with it, the less I liked that. Process creation auditing is off by default on Windows. Event logs roll over. Prefetch only holds the last eight run times. Most of the time there’s a normal reason something isn’t there, and I didn’t want to build a tool that suggests tampering when the likely answer is a default setting.


I decided to focus on a narrower question instead: did a program run, and if so, do the artifacts agree on when it ran?


Making the artifacts comparable:


Each parser hands back data in its own format (run times from Prefetch, records from the event logs, keys and values from the Registry), so I couldn’t compare them directly. I added a common evidence record that every parser’s output gets converted into. It holds:


the program name

the event

the timestamp

the source file

a field describing what the timestamp represents

I nearly left that last field out, and it ended up being the reason this post exists.


On top of that I wrote a check that pulls every record for one program and looks at whether the timestamps from different sources fall within a time window. If they agree, the result is Corroborated. If only some agree, it’s Partially Corroborated. If none agree, it’s Needs Review. When a source has no evidence at all, the report says so and leaves the interpretation to the examiner. It doesn’t call it tampering.


For the first version I used PowerShell and three sources:


Prefetch

Security event 4688, which logs process creation

BAM, a registry key that keeps one timestamp per program for each user


The test:


I needed to know what window size made sense, and I didn’t want to pick a number out of the air, so I ran a test on my own Windows 11 machine (build 26200). I wrote a script that:


turned on process creation auditing

started powershell.exe three times, three minutes apart

left each one open for 60 seconds before closing it

logged the exact start and exit time of every run

When it finished, it copied the Prefetch files, the Security log and the SYSTEM hive, and set the audit policy back to what it was before.


I kept each window open for a full minute so that the start and exit times would be far enough apart. That way, if an artifact was recording one and not the other, I’d be able to see it.


The results:


Measured against the real start and exit times:


Security 4688 was 0 to 1 ms after the process started, on all three runs.

Prefetch was 30 to 32 ms after the process started, on all three runs.

BAM was 2 ms after the process exited, around 61 seconds after it started.

I’d seen a Prefetch delay of about ten seconds mentioned before, so 30 milliseconds was not what I expected. On this machine it was consistent across every run.


The BAM result mattered more, though. On my machine BAM was recording when PowerShell closed, not when it opened.


How I found out:


I didn’t actually spot this in the numbers first. I’d been running the comparison with a 5 minute window and everything was coming back Corroborated. When I brought the window down to 30 seconds, PowerShell dropped to Partially Corroborated, and the report said the Registry evidence was outside the window.


The artifacts were recording exactly what they’re supposed to. Prefetch and 4688 marked the start of the run, BAM marked the end, and my code was treating all three as if they described the same moment. If I’d kept PowerShell open for an hour, BAM would have looked an hour “off.” With a tight enough window, Corrobora would have reported a disagreement between artifacts that weren’t disagreeing at all. Avoiding that kind of misleading result was the reason I reworked the old rules in the first place, so it wasn’t great to find I’d built it into the new one.


What I changed:


Now every timestamp is tagged as marking either a process start or a process end. Start times (Prefetch and 4688) are compared with each other inside the window. BAM is handled separately. It isn’t checked against the window. It gets matched to the most recent run that started before it, as long as no other run started in between. Since BAM only stores one timestamp per program per user, it can only support one run anyway.


There was a second issue in the same code. When more than one run matched equally well, the tool chose the group with the smallest spread, which in my test meant it always picked the first of the three runs. There wasn’t a good reason for that, so now it picks the most recent run, which is also the only run BAM can tell you anything about.


With those changes, the same test came back Corroborated at both 30 seconds and 5 seconds. The report also labels the BAM time as “process exit.” If a BAM time comes before the start it’s matched to, the report notes that this is expected when the program was still running at the time of collection.


The caveats:


All of this comes from one machine on one Windows build, so I’m not treating these numbers as true for Windows in general. Corrobora still requires you to set the window yourself, and each report states that the window isn’t a validated forensic threshold. I’d rather leave that decision to the examiner than ship a default that implies more certainty than the testing supports.


I’ve also only tested PowerShell, and only a few runs. Other programs, other builds and Sysmon logs are still on the list.


What I’m taking from it:


The main thing I’m taking forward is to check what event an artifact’s timestamp represents before comparing it with anything else. Before this test I mostly treated a timestamp as a timestamp.


This test is also why Corrobora now has a fixed reference case that anyone can run and get identical output on Windows, macOS or Linux. That’s what Part 5 will cover.


If you’re on a different Windows build and want to run the same test, I’d like to compare results.


GitHub: https://github.com/Gear-I/Corrobora



Comments

Popular posts from this blog

VeriTrace Development Series Part 1: Building the Windows EVTX Parser

VeriTrace Development Series Part 2: Building the Windows Registry Parser

Building VeriTrace: The Beginning of an Open-Source Digital Forensics Framework