Skip to content

Commit aba3b04

Browse files
committed
Windows Thrdscan: Fix thread filtering + tracebacks
Tracebacks were occurring across a number of samples when running the threads/threadscan plugins due to uncaught `InvalidAddressExceptions`. Further investigations led to the discovery of some incorrect thread filtering that was missing valid threads.
1 parent 64ecd65 commit aba3b04

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

volatility3/framework/constants/windows/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@
2828

2929
# CR3 register within structures describing initial processor state to be started
3030
PROCESSOR_START_BLOCK_CR3_OFFSET = 0xA0 # PROCESSOR_START_BLOCK->ProcessorState->SpecialRegisters->Cr3, ULONG64 8 bytes
31+
32+
MAX_PID = 0xFFFFFFFC

volatility3/framework/plugins/windows/thrdscan.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from volatility3.framework import exceptions, interfaces, objects, renderers
99
from volatility3.framework.configuration import requirements
10+
from volatility3.framework.constants import windows as windows_constants
1011
from volatility3.framework.renderers import format_hints
1112
from volatility3.framework.symbols.windows import extensions as win_extensions
1213
from volatility3.plugins import timeliner
@@ -112,10 +113,19 @@ def gather_thread_info(
112113
vollog.debug(f"Thread invalid address {ethread.vol.offset:#x}")
113114
return None
114115

115-
# don't look for VADs in kernel threads, just let them get reported with empty paths
116+
# Filter junk PIDs
116117
if (
117-
owner_proc_pid != 4
118-
and owner_proc.InheritedFromUniqueProcessId != 4
118+
ethread.Cid.UniqueProcess > windows_constants.MAX_PID
119+
or ethread.Cid.UniqueProcess == 0
120+
or ethread.Cid.UniqueProcess % 4 != 0
121+
):
122+
return None
123+
124+
# Get VAD mappings for valid non-system (PID 4) processes
125+
if (
126+
owner_proc
127+
and owner_proc.is_valid()
128+
and owner_proc.UniqueProcessId != 4
119129
and vads_cache is not None
120130
):
121131
vads = pe_symbols.PESymbols.get_vads_for_process_cache(

volatility3/framework/symbols/windows/extensions/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,11 @@ def is_valid(self) -> bool:
709709
return False
710710

711711
# NT pids are divisible by 4
712-
if self.UniqueProcessId % 4 != 0:
712+
if (
713+
self.UniqueProcessId % 4 != 0
714+
or self.UniqueProcessId == 0
715+
or self.UniqueProcessId > constants.windows.MAX_PID
716+
):
713717
return False
714718

715719
# check for all 0s besides the PCID entries

0 commit comments

Comments
 (0)