Skip to content

feat: enhanced EVTX collection and event logs web UI with Sigma support#2939

Merged
kevoreilly merged 6 commits intokevoreilly:masterfrom
wmetcalf:feat/sigma-evtx-web
Mar 12, 2026
Merged

feat: enhanced EVTX collection and event logs web UI with Sigma support#2939
kevoreilly merged 6 commits intokevoreilly:masterfrom
wmetcalf:feat/sigma-evtx-web

Conversation

@wmetcalf
Copy link
Copy Markdown
Contributor

Summary

  • Enhanced evtx.py auxiliary module with 20+ additional Windows event log channels (PowerShell, Defender, BITS, Firewall, NTLM, AppLocker, WMI, Task Scheduler, etc.), command line logging, configurable log sizes, audit policy GUIDs for non-English Windows support
  • New event logs web UI with three-tab layout: Sigma Detections, Sysmon Events, EVTX Events
  • Sigma tab shows rule title, severity badges, ID, description, MITRE ATT&CK techniques, and matched events with expandable sigma query
  • Systemd timer for daily Sigma rule updates via Zircolite

Dependencies

wmetcalf added 3 commits March 9, 2026 16:33
… logs

The Windows analyzer logs the package selection as:
  INFO: analysis package selected: "pkg"
but get_package() only searched for the Linux format:
  INFO: Automatically selected analysis package "pkg"

This caused the package field to remain empty in reports for
Windows analyses where no package was explicitly specified.

Now searches for both log formats using len(marker) instead of
a hardcoded offset.
Enhanced evtx.py auxiliary module:
- Collect 20+ additional Windows event log channels (PowerShell,
  Defender, BITS, Firewall, NTLM, AppLocker, WMI, Task Scheduler, etc.)
- Enable command line logging (ProcessCreationIncludeCmdLine_Enabled)
- Configure log sizes (100MB per channel)
- Use audit policy GUIDs instead of English names (non-English support)
- Quote channel names in wevtutil calls

New event logs web UI:
- Three-tab layout: Sigma Detections, Sysmon Events, EVTX Events
- Sigma tab shows rule title, severity, ID, description, matched events
- Sigma query shown on expand (not cluttering collapsed view)
- Severity badge coloring (critical/high/medium/low/informational)
- MITRE ATT&CK technique display per detection

Systemd units for daily Sigma rule updates via Zircolite.

Companion to CAPESandbox/community#544 which adds the sigma processing
module and behavioral signature.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the platform's capability to collect and analyze Windows event logs, providing deeper insights into system activities. It introduces a comprehensive set of new event log channels for collection and a user-friendly web interface to visualize and interact with these logs, including Sigma detections and Sysmon events. These changes aim to improve threat detection and analysis by offering more granular data and a streamlined review process.

Highlights

  • Enhanced EVTX Collection: Expanded Windows event log collection in evtx.py to include over 20 new channels (e.g., PowerShell, Defender, NTLM, AppLocker, WMI, Task Scheduler), implemented command line logging, and configurable log sizes.
  • Language-Agnostic Audit Policies: Updated advanced audit policy configuration to use language-agnostic GUIDs for broader Windows support, ensuring consistent logging across different OS languages.
  • New Event Logs Web UI: Introduced a new web UI for event logs, featuring dedicated tabs for Sigma Detections, Sysmon Events, and detailed EVTX Events, providing a centralized view for security analysis.
  • Sigma Tab Enhancements: Enhanced the Sigma tab to display rule details such as title, severity, ID, description, MITRE ATT&CK techniques, and matched events with expandable queries.
  • Automated Sigma Rule Updates: Enabled daily automatic updates for Sigma rules via a new systemd service and timer, leveraging Zircolite to keep detection capabilities current.
Changelog
  • analyzer/windows/modules/auxiliary/evtx.py
    • Expanded the list of windows_logs to include over 20 new event log channels.
    • Added LOG_MAX_SIZE constant and log_sizes list to configure maximum sizes for event logs.
    • Introduced logs_to_enable list for logs that require explicit activation.
    • Implemented enable_cmdline_logging function to capture command line details in process creation events.
    • Implemented configure_log_sizes function to set max log sizes and enable disabled logs.
    • Refactored enable_advanced_logging to use audit policy GUIDs for language-independent configuration.
    • Modified wipe_windows_logs to use quoted channel names for wevtutil.
    • Integrated enable_cmdline_logging and configure_log_sizes into the run method.
  • modules/processing/analysisinfo.py
    • Modified get_package to check for both Windows and Linux analyzer log formats when identifying the analysis package.
  • systemd/cape-sigma-update.service
    • Added a new systemd service definition for updating CAPE Sigma rules using Zircolite.
  • systemd/cape-sigma-update.timer
    • Added a new systemd timer definition to schedule daily updates of CAPE Sigma rules.
  • web/analysis/urls.py
    • Added URL patterns for load_evtx_channel and load_evtx_channel_count views.
  • web/analysis/views.py
    • Imported lru_cache and JsonResponse.
    • Added PyEvtxParser import and HAVE_EVTX flag for EVTX parsing.
    • Defined EVTX_LEVEL_MAP and EVTX_PAGE_SIZE constants.
    • Added helper functions _evtx_member_display_name, _flatten_evtx_detail, and _list_evtx_members for EVTX processing.
    • Implemented cached functions _load_evtx_channel_page_cached and _count_evtx_channel_events_cached for efficient EVTX data retrieval.
    • Created _load_evtx_channel_page to handle EVTX channel page loading.
    • Extended load_files to include "eventlogs" category, fetching Sigma, Sysmon, and EVTX channel data.
    • Added decrypted_pcap_exists check to load_files AJAX response.
    • Updated report to check for has_evtx and include it in the report context.
    • Implemented load_evtx_channel view to serve EVTX channel data for the web UI.
    • Implemented load_evtx_channel_count view to provide event counts for EVTX channels.
    • Added "decrypted_pcap" category to file view for downloading decrypted PCAP files.
  • web/templates/analysis/eventlogs/_evtx_channel.html
    • Created a new template to display paginated EVTX events for a specific channel, including event details and level badges.
  • web/templates/analysis/eventlogs/index.html
    • Created a new template for the event logs section, featuring tabbed navigation for Sigma Detections, Sysmon Events, and EVTX Events.
    • Includes JavaScript for dynamic loading and pagination of Sysmon and EVTX events.
  • web/templates/analysis/report.html
    • Modified AJAX tab loading logic to prevent redundant loading and handle loading states.
    • Added a new "Event Logs" navigation tab, conditionally displayed based on the presence of Sigma, Sysmon, or EVTX data.
    • Included the analysis/eventlogs/index.html template in the report's tab content.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly enhances the EVTX log collection capabilities and introduces a new web UI for viewing event logs, including Sysmon events and Sigma detections, with improvements like using GUIDs for audit policies and on-demand UI loading. However, a significant DOM-based Cross-Site Scripting (XSS) vulnerability was identified in the Sysmon Events tab of the new web UI, stemming from the direct concatenation of unescaped Event IDs into the HTML structure via JavaScript. Additionally, feedback includes reducing code duplication in the evtx.py module and making the systemd service for Sigma updates more robust by not ignoring restart failures.

Comment on lines +211 to +212
tabsHtml += '<li class="nav-item"><a class="nav-link' + active + '" data-bs-toggle="tab" href="#sysmon_eid_' + eid + '" role="tab">' +
getEventName(eid) + ' (' + grouped[eid].length + ')</a></li>';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The eid (Event ID) variable, which is extracted from attacker-controlled Sysmon logs, is concatenated directly into HTML strings without proper escaping. This allows for DOM-based Cross-Site Scripting (XSS). An attacker can craft a malicious EVTX file or trigger malware to generate a Sysmon event with a specially crafted EventID containing HTML/JavaScript, which will be executed in the context of the user's browser when they view the Sysmon Events tab.

To remediate this, use the escapeHtml() function to sanitize the eid variable and the return value of getEventName(eid) before concatenating them into HTML strings.

                tabsHtml += '<li class="nav-item"><a class="nav-link' + active + '" data-bs-toggle="tab" href="#sysmon_eid_' + escapeHtml(eid) + '" role="tab">' +
                    escapeHtml(getEventName(eid)) + ' (' + grouped[eid].length + ')</a></li>';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f9988b8 — applied escapeHtml() to all eid insertions and getEventName(eid) return value.

var events = grouped[eid];
var showActive = j === 0 ? " show active" : "";

contentHtml += '<div class="tab-pane fade' + showActive + '" id="sysmon_eid_' + eid + '">';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The eid variable is used here without escaping, contributing to the DOM XSS vulnerability.

                    contentHtml += '<div class="tab-pane fade' + showActive + '" id="sysmon_eid_' + escapeHtml(eid) + '">';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f9988b8 — applied escapeHtml() to all eid insertions and getEventName(eid) return value.

var evt = events[e];
var pageNum = Math.floor(e / PAGE_SIZE) + 1;
var hidden = pageNum > 1 ? ' style="display:none"' : '';
contentHtml += '<tr class="sysmon-row" data-page="' + pageNum + '" data-eid="' + eid + '"' + hidden + '>';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The eid variable is used here without escaping, contributing to the DOM XSS vulnerability.

                        contentHtml += '<tr class="sysmon-row" data-page="' + pageNum + '" data-eid="' + escapeHtml(eid) + '"' + hidden + '>';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f9988b8 — applied escapeHtml() to all eid insertions and getEventName(eid) return value.


// Pagination controls
if (totalPages > 1) {
contentHtml += '<nav aria-label="Sysmon pagination"><ul class="pagination justify-content-center eventlogs-pagination" data-eid="' + eid + '">';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The eid variable is used here without escaping, contributing to the DOM XSS vulnerability.

                        contentHtml += '<nav aria-label="Sysmon pagination"><ul class="pagination justify-content-center eventlogs-pagination" data-eid="' + escapeHtml(eid) + '">';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f9988b8 — applied escapeHtml() to all eid insertions and getEventName(eid) return value.

Comment on lines +57 to +83
log_sizes = [
"Security",
"Microsoft-Windows-PowerShell/Operational",
"Windows PowerShell",
"PowerShellCore/Operational",
"System",
"Application",
"Microsoft-Windows-Windows Defender/Operational",
"Microsoft-Windows-Bits-Client/Operational",
"Microsoft-Windows-Windows Firewall With Advanced Security/Firewall",
"Microsoft-Windows-NTLM/Operational",
"Microsoft-Windows-Security-Mitigations/KernelMode",
"Microsoft-Windows-Security-Mitigations/UserMode",
"Microsoft-Windows-PrintService/Admin",
"Microsoft-Windows-PrintService/Operational",
"Microsoft-Windows-SmbClient/Security",
"Microsoft-Windows-AppLocker/MSI and Script",
"Microsoft-Windows-AppLocker/EXE and DLL",
"Microsoft-Windows-AppLocker/Packaged app-Deployment",
"Microsoft-Windows-AppLocker/Packaged app-Execution",
"Microsoft-Windows-CodeIntegrity/Operational",
"Microsoft-Windows-Diagnosis-Scripted/Operational",
"Microsoft-Windows-DriverFrameworks-UserMode/Operational",
"Microsoft-Windows-WMI-Activity/Operational",
"Microsoft-Windows-TerminalServices-LocalSessionManager/Operational",
"Microsoft-Windows-TaskScheduler/Operational",
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is significant duplication between the log_sizes list and the windows_logs list defined earlier in this file. This makes the code harder to maintain, as adding a new log channel to be collected might require adding it in two places.

To improve maintainability, consider defining log_sizes by filtering windows_logs instead of duplicating the entries. For example:

# Logs that should not have their size configured
logs_to_exclude_from_sizing = {
    "HardwareEvents",
    "Internet Explorer",
    "Key Management Service",
    "OAlerts",
    "Setup",
    "Microsoft-Windows-Sysmon/Operational",
}

# All channels get the same max size for sandbox use
log_sizes = [log for log in windows_logs if log not in logs_to_exclude_from_sizing]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't fix — log_sizes is intentionally a subset of windows_logs. Not all channels need size configuration (e.g. some are low-volume and the default size is fine). Merging the two would either over-configure small channels or require a more complex data structure for no real benefit.

WorkingDirectory=/opt/zircolite
ExecStart=/etc/poetry/bin/poetry --directory /opt/CAPEv2/ run python zircolite.py --update-rules
ExecStartPost=/bin/bash -c 'for f in /opt/zircolite/rules/*.json; do dest="/opt/CAPEv2/data/sigma/$(basename "$f")"; [ -f "$dest" ] && cp "$f" "$dest"; done'
ExecStartPost=+/bin/systemctl restart cape-processor.service
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The + prefix on this ExecStartPost command causes systemd to ignore any failures when restarting the cape-processor.service. If the service fails to restart, the new Sigma rules won't be loaded, but this update job will still be marked as successful. This can lead to a silent failure. For better operational robustness, it's recommended to remove the + so that a restart failure causes this service unit to enter a failed state, which can then be detected by monitoring systems.

ExecStartPost=/bin/systemctl restart cape-processor.service

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The + prefix is not for ignoring errors — it causes systemd to run that specific ExecStartPost command with full root privileges regardless of the User=cape directive. This is necessary because an unprivileged user cannot restart system services. See systemd.exec(5): "If the executable path is prefixed with '+', the process is executed with full privileges."

wmetcalf and others added 3 commits March 10, 2026 21:05
Event IDs from untrusted guest Sysmon logs were concatenated into
HTML without escaping. Apply escapeHtml() to all eid insertions.
Remove warning log for suspicious EVTX archive members.
@kevoreilly kevoreilly merged commit 0cdbc7a into kevoreilly:master Mar 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants