Repository navigation
v0.15.0
·
210 commits
to master
since this release
Records now render as Windows renders them in many more ways, and all the
breaking changes of this round are in this one release. Breaking changes says
what to change when upgrading; the sections after it give the details.
Breaking changes
Output, in XML and JSON, from every API and from evtx_dump:
- Timestamps have seven fractional digits (
2016-07-08T18:12:51.6816408Z).
Code that parses them with exactly six needs to accept seven. - GUIDs are lowercase and in braces (
{54849625-5478-4994-a5ba-3e3b0328c30d}). - Elements that depend on a NULL value are left out, as Windows leaves them
out: the<Binary></Binary>and<Data></Data>of values that were never
set, and unset optionalSystemfields. Code that reads them needs to handle
their absence. - In JSON, consecutive
Dataelements of one name are one member whose value
is an array, and a name that comes back later is numbered_1,_2: in
event 4648 of some logs, the secondLogonGuidisLogonGuid_1. - XML writes empty elements as
<X/>, or as<X></X>when their content is
empty, with nothing inside them when indented. - Characters that XML doesn't allow are
_in XML, and lone surrogates are_
in XML and U+FFFD in JSON. utf16-simd 0.2.0 does the same. - A log that has wrapped around comes out oldest record first.
- The walk over a chunk's records resyncs past a corrupt record header, so more
records come out. Withrecover_records, the records that the resync skips
come out as recovered. - A record fails with an error once its output passes 16 MiB, or once its tree
takes more than 2^18 nodes. The samples' records stay far below both.
API:
EvtxFileHeaderhascomputed_checksum, andEvtxChunkDatahasnumber,
so struct literals of them need the new fields.HeaderFlagsandChunkFlagskeep the bits evtx doesn't define: test flags
withcontains, since==compares those bits too.- A record that can't be read fails with
EvtxError::FailedToReadRecordAt,
whose source is the error it used to fail with.EvtxError,
DeserializationError(OutOfBounds,InvalidRecordTimestamp) and
ChunkError(InvalidChunkHeaderChecksum,InvalidFreeSpaceOffset) have
new variants, andInvalidChunkChecksumis now only for the records' CRC32. BinXmlValue::FileTimeType,SysTimeTypeand their arrays holdFileTime
andSysTime, the values as stored.to_timestamp()gives a jiff
Timestampwhen jiff can represent the value.AnsiStringArrayTypeholds
its strings.ParserSettingswith different WEVT template caches no longer compare equal.
Added
EvtxParser::header()returns the file header, which was private. The
header also hascomputed_checksum, the CRC32 of its first 120 bytes as
read, andvalidate_checksum(), which compares it with the stored
checksumunlessNO_CRC32is set (the Application_no_crc32 sample's
header sets it and stores 0). evtx never checked the header's CRC32. A file
whose header fails the check is still read, since evtx finds chunks at fixed
offsets, but the parser logs a warning andevtx_dumpprints one.
Breaking: code that builds anEvtxFileHeaderwith a struct literal
needs the new field.evtx_dump info -i <file>shows what the file header and each chunk header
say: the version, flags, chunk numbers, next record ID and CRC32 of the
header, and each chunk's record numbers and IDs, flags, and header and
records CRC32s, with empty and unreadable chunks marked, without parsing
records. For triaging dirty, wrapped or damaged logs: security.evtx's dirty
header says the next record ID is 2226, where its last chunk ends at 2261.ChunkFlags, the type ofEvtxChunkHeader::flags, is exported, so that its
flags can be named.
Changed
- A log that has wrapped around comes out oldest record first, as Windows reads
it: from the chunk that holds its lowest record ID to the end of the file,
then from the start of the file. evtx read it in file order, so its newest
records came first. The file header names the oldest chunk too, but a log
that wasn't closed cleanly can be a chunk ahead of it, as the LiveId sample
is, and Windows still starts at the oldest records. 5 of the samples change. - Timestamps render with seven fractional digits, the 100 ns that a FILETIME
counts, as Windows renders them:2016-07-08T18:12:51.6816408Zinstead of
2016-07-08T18:12:51.681640Z, which dropped the last digit. SYSTEMTIME
values, which store milliseconds, render as.7890000Z, as in Windows. This
covers XML and JSON,TimeCreatedincluded, so code that parses evtx's
timestamps with exactly six digits needs to accept seven. - In JSON,
Dataelements that share a name no longer become duplicate keys,
of which JSON parsers keep only the last. Consecutive ones, which an array
substitution writes, one per value, become one member whose value is an
array:"UnicodeStrings":["a","","c,d"]instead of
"UnicodeStrings":"a","UnicodeStrings":"","UnicodeStrings":"c,d". A name
that comes back later is numbered_1,_2and so on, as repeated element
names already are. Event 4648 in the Security_with_size_t and
security_big_sample samples names both of its GUIDsLogonGuid, where the
other samples name the secondTargetLogonGuid, so the second is now
LogonGuid_1andLogonGuidis the first, which parsers used to lose. XML
is unchanged, and so are arrays of one value, which render as that value. - Errors say where they are. A record that can't be read, such as one whose
header is damaged, fails withEvtxError::FailedToReadRecordAt, which names
its chunk and its offsets and has the error it replaces as its source:
Failed to read the record at offset 0x2060 of chunk 7 (file offset 0x73060). The chunks that the parser reads keep their number in the file in
EvtxChunkData::number, so errors name it when such a chunk is parsed on its
own, withEvtxChunkData::parse; a chunk built withEvtxChunkData::new
doesn't know it, and saysof its chunk. A position past the end of the data
readsNullType Descriptor at offset 78404 is past the end of the data (65536 bytes)(DeserializationError::OutOfBounds) instead ofbuffer too small for NullType Descriptor at offset 78404 (need 0 bytes, have 0), and a record
header whose timestamp is out of range fails withInvalidRecordTimestamp,
which gives the FILETIME, instead ofInvalidDateTimeError. Breaking:
code that matches on such a record's error finds it under
FailedToReadRecordAt, exhaustive matches onEvtxErrorand
DeserializationErrorneed the new variants, and code that builds an
EvtxChunkDatawith a struct literal needs itsnumber. BinXmlValue's FILETIME and SYSTEMTIME variants hold the stored value, a
FileTimeor aSysTime, instead of a jiffTimestamp, so that values jiff
can't represent still render.to_timestamp()converts them.BinXmlValue::AnsiStringArrayTypeholds its strings, as a&[&str].evtx_dumpstarts each chunk's output buffer as big as the largest a chunk of
the log has needed so far (from 128 KiB up to 1 MiB), instead of at 128 KiB.
Most Security chunks render about 160 KiB of XML, and growing the buffer
copies it unless the allocator has free space right after it, so the cost of
a dump depended on heap layout: up to 6.5% more instructions on a 30 MB
Security log.
Fixed
- A chunk whose string table couldn't be read was reported as
Failed to parse chunk number Nwith N its place among the chunks read, not its number in the
file. The two differ after an empty chunk and in a log that has wrapped
around. - GUIDs render as Windows renders them, lowercase and in braces:
{54849625-5478-4994-a5ba-3e3b0328c30d}instead of
54849625-5478-4994-A5BA-3E3B0328C30D. This covers GUID values in XML and
JSON, the provider'sGuidand theActivityIDincluded. A GUID that a
template holds as text keeps its case. Code that matches evtx's GUIDs as text
needs to accept the new form. - XML writes empty elements as Windows does:
<Provider Name="P"/>for an
element the template closes empty, and<Data Name="x"></Data>for one whose
content is empty. Indented output used to put a newline and indentation inside
them, which XML parsers read as text. JSON is unchanged. - An element whose template makes it depend on a value (its DependencyId) is
left out when that value is NULL, as MS-EVEN6 requires and Windows does. This
removes the<Binary></Binary>and<Data></Data>that classic events wrote
for values that were never set, and optionalSystemfields left unset. An
element left with no children renders empty, as<EventData></EventData>in
XML and"EventData": nullin JSON. An empty string still renders as an
empty element, as in Windows. This covers XML and JSON. - A record holding a FILETIME or SYSTEMTIME value that jiff can't represent
failed withInvalidDateTimeError: a FILETIME from 9999-12-30T22:00 UTC on,
and a SYSTEMTIME with a field out of range. Such values now render as Windows
renders them. Years past 9999 keep their last four digits, a FILETIME past
i64::MAXrenders as0000-00-00T00:00:00.0000000Z, and an invalid
SYSTEMTIME as1601-01-01T00:00:00.0000000Z, as an unset one already did.
10 records of the Windows types sample failed this way. - A record holding an array of ANSI strings, which Windows stores for a
win:AnsiStringfield with acount, failed because evtx didn't implement
that value type. Each string now renders as an element of its own, as Windows
renders them. 3 records of the Windows types sample failed this way. - A record whose template holds a CDATA section or a character reference failed,
because evtx didn't implement those BinXML tokens. XML now writes them as
<![CDATA[...]]>andA, and JSON gets their text. A]]>inside a
CDATA section splits it in two, so the XML stays well-formed. With this, every
record of the Windows types sample renders. - XML output wasn't always well-formed: C0 controls other than tab, LF and CR,
and U+FFFE and U+FFFF, went into it as they were, and XML parsers reject them.
Each now renders as_, as Windows renders them. A lone UTF-16 surrogate was
dropped: it now renders as_in XML, as in Windows, and as U+FFFD in JSON,
which already escaped controls. 5 records across the samples weren't
well-formed XML, and now every record is. utf16-simd 0.2.0 makes the same
change in its XML, JSON and raw output. - A chunk whose string table links back to a string it has already listed, as
a damaged or crafted chunk can, made the parser loop forever: only a string
that links to itself ended the walk. Any string already read now ends it.
Found by fuzzing. - Reading a
.wevtcachefile trusted each entry's length and allocated that
many bytes before reading, so a 25-byte crafted file could request ~4 GiB.
An entry longer than the rest of the file is now rejected with
EntryLengthTooLargebefore anything is allocated (#334). - The WEVT manifests in
.wevtcachefiles and DLLs could abort the process the
same way: a TTBL table, or a CHAN, KEYW, LEVL, OPCO, TASK or EVNT table of
size 0, reserved room for as many entries as its count claimed, up to
4 billion, before reading any. Those tables now reserve no more entries than
the manifest has room for. - A BinXML value holding more than one element kept only the first. Windows
writes such values: in the Shell-Core sample, events 161 and 968 hold their
event data and then aRenderingInfoelement, which evtx dropped. Every
element now renders, in XML and JSON, as Windows renders them. - A BinXML value holding no element rendered as an empty
Eventelement
("Event": nullin JSON), as in record 17 of the LanguagePackSetup sample. It
now renders nothing. - A corrupt or zeroed record header ended its chunk: the live records after it
were lost unless--recover-recordswas set. In every mode, the walk now
reports the bad header and resyncs on the next record whose ID is in the chunk
header's range, which brings back 166 records in the samples. With
--recover-records, every record carved before the free space used to count
as live. The ones the resync skips, such as records of the log's other pass
over a chunk, now come out as recovered, and the 23 of them whose templates
were overwritten are skipped like other carved noise instead of reported as
errors. - A crafted record could make evtx do work exponential in its size: a template
that uses a value in several places, whose value holds another instance of
the template, and so on a few levels down. A 600-byte record rendered to
600 MB of XML, and the records API could take hours to start rendering such a
record. A template that uses one long value or one long name thousands of
times, or many instances of such a template, could also render a record to
gigabytes, and an array of thousands of items deep in a record to hundreds
of megabytes. A record now fails with an error once its output passes
16 MiB, whichever API and format renders it, and the records API no longer
stalls. Records that render the slower way, from their tree, also fail once
building and walking the tree take more than 2^18 nodes, counting a value's
nodes once for each place the value is used: elements with thousands of empty
attributes render nothing, and kept evtx busy for a minute per record. Records
take that way when their templates don't compile, in JSON with
--separate-json-attributes, and in the records API with an.MTAfile. The
faster way renders each value once, so its output bounds its work. - The slower way built a record's whole tree before it rendered any of it, so a
crafted record could take gigabytes before a cap stopped it. A 62 KB record
that places a value of 3,000 elements 8,000 times took 1.7 GB, and a 558-byte
record with 6 arrays of 16 items in one element, which repeats the element for
each combination of items, took 20 s and 7 GB. A BinXML value in a template
can hold instances of other templates, which become part of the template: a
2 KB record of 25 templates that each hold two instances of the one before
took 4.8 GB and aborted. Building a record now counts toward its nodes as it
goes, the templates it instantiates and the instances they hold included, so
these records fail within 0.03 s and 20 MB. A record's tree takes at most
about 30 MB, and the samples' records build at most 198 nodes. - Records share their chunk's templates, so hundreds of small records in a
crafted chunk could each render close to 16 MiB, and both the records API and
evtx_dump hold a chunk's output until its last record: a 68 KB file needed
9 GB and aborted. A pass over a chunk now renders up to 64 MiB, failed
records included, and builds and walks up to 2^20 nodes the slower way. Once
less than one record's worth is left, the chunk's later records fail with an
error. The samples' chunks render at most 234 KB. - A record whose values nest elements more than 512 levels deep overflowed the
stack and aborted the process. It now fails with an error, unless evtx
renders it from a compiled template, which doesn't recurse per element and
renders it in full. A template whose elements nest more than 512 levels deep,
counting the instances that a BinXML value in it holds, now fails with an
error whichever way it renders: compiling or instantiating it recurses once
per level, and an 8 KB record of such a template overflowed the stack in both
APIs. - Crafted templates could make evtx keep hundreds of megabytes of compiled
templates per chunk for the rest of the parse. Each chunk now compiles at
most 16 MiB of them and renders the records that would need more the slower
way, and at most 64 MiB are kept for reuse across chunks. - A BinXML value used in two places of its template, at different depths, was
indented in both as in the last one. - In JSON, an element with more than 65,536 children of one name numbered them
from the start again, repeating keys. Debug builds panicked. Numbering the
children of an element with thousands of names took time quadratic in their
number. - A chunk that failed a checksum check reported
ChunkError::InvalidChunkChecksum { expected: 0, found: 0 }, whichever check
failed. The error now says which:InvalidChunkHeaderChecksumfor the
header's CRC32 andInvalidChunkChecksumfor the records', both with the
stored and computed values, orInvalidFreeSpaceOffsetwhen the header's
free space offset is outside the chunk, so the records' CRC32 can't be
computed. Breaking:ChunkErrorhas these two new variants. - File and chunk headers dropped the flag bits evtx doesn't define, so the
post-Security sample's header, whose flags are 0x1b970000, read as having no
flags.EvtxFileHeader::flagsandEvtxChunkHeader::flagsnow keep every
bit. ParserSettingsequality ignored the WEVT template cache, so settings with
different caches compared equal. Caches now compare by identity, as.MTA
files do.evtx_dumpbuilt without themultithreadingfeature warned at every run
that threads were turned on. It now warns only when-tasks for more than
one thread.- Docs: the
--eventshelp said it counts records from the start of the file
("offseted reltaive to file"); it filters by event record ID. The README said
threads could reorder records, but the records come out in the same order
with any number of threads.EvtxParser::from_buffer's doc said it loads
from a path. evtx_dumppiped into a reader that stops early, such ashead, ended with
Error: Broken pipe (os error 32)and exit status 1, and
dump-template-instancespanicked. They now stop quietly, with status 0.evtx_dumpdidn't flush its output before exiting, so a failure to write the
last of it, such as a full disk, was lost and the exit status was 0. It is
now an error.
Security
- Refreshed lockfiles to clear Dependabot alerts:
crossbeam-epoch0.9.21
(RUSTSEC-2026-0204) andanyhow1.0.104 (RUSTSEC-2026-0190),rkyv0.8.18 in the
utf16-simdbenches, andzod4.6.7,vite8.3.5,vitest5.0.5 and
source-map-js1.2.2 in the web viewer.
What's Changed
- fix(viewer): make DuckDB tests fail fast instead of hanging offline by @omerbenamram in #327
- chore(deps): refresh lockfiles to clear Dependabot alerts by @omerbenamram in #326
- Windows ground truth: Windows' own XML for every sample and a typed-events log by @omerbenamram in #328
- fix: keep every element of a BinXML value, not just the first by @omerbenamram in #329
- Land #329 on master: keep every element of a BinXML value by @omerbenamram in #332
- fix: resync past a corrupt record header without --recover-records by @omerbenamram in #330
- fix(wevtcache): bound entry length by the bytes left in the file by @omerbenamram in #335
- fix(wevt): don't reserve WEVT manifest tables by an unchecked count by @omerbenamram in #336
- fix: count what building a record's tree creates toward its node cap by @omerbenamram in #333
- fix: render timestamps with seven fractional digits, like Windows by @omerbenamram in #337
- fix: cap the output, work and memory of crafted records by @omerbenamram in #331
- fix: render ANSI string arrays as Windows does by @omerbenamram in #339
- fix: render CDATA sections and character references by @omerbenamram in #340
- fix: a string table chain that loops no longer hangs the chunk parse by @omerbenamram in #356
- Add cargo-fuzz targets for logs, chunks, WEVT templates and .MTA files by @omerbenamram in #357
- perf: size each chunk's output buffer from the largest output so far by @omerbenamram in #345
- feat: expose the file header and check its CRC32 by @omerbenamram in #350
- feat(evtx_dump): add
info, which shows the file and chunk headers by @omerbenamram in #351 - fix(evtx_dump): stop quietly when the reader closes the pipe by @omerbenamram in #354
- fix: leave out elements whose value is NULL, as Windows does by @omerbenamram in #344
- fix: keep the JSON walker's frame small for deep templates by @omerbenamram in #346
- fix: say where a record that can't be read is by @omerbenamram in #352
- fix: render out-of-range FILETIME and SYSTEMTIME values as Windows does by @omerbenamram in #338
- docs: say what --events filters, and that threads keep record order by @omerbenamram in #353
- Land F5, A4, F2, F3 and F4 (#341 to #344), and compare evtx's XML with Windows' by @omerbenamram in #355
- fix: read a wrapped log from its oldest chunk, as Windows does by @omerbenamram in #347
- fix: say which chunk checksum failed, keep unknown header flag bits by @omerbenamram in #348
- fix(json): keep every Data value when Data names repeat by @omerbenamram in #349
- feat: chunks the parser reads keep their number in the file by @omerbenamram in #358
- chore(release): 0.15.0 by @omerbenamram in #359
Full Changelog: v0.14.0...v0.15.0