<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Digvijay on Medium]]></title>
        <description><![CDATA[Stories by Digvijay on Medium]]></description>
        <link>https://medium.com/@ddigvijay?source=rss-bd4bfddba65------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Digvijay on Medium</title>
            <link>https://medium.com/@ddigvijay?source=rss-bd4bfddba65------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 09:09:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ddigvijay/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Double Extortion: Theft Before the Lock]]></title>
            <link>https://medium.com/@ddigvijay/double-extortion-theft-before-the-lock-ee5873d1a73b?source=rss-bd4bfddba65------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee5873d1a73b</guid>
            <category><![CDATA[data-exfiltration]]></category>
            <category><![CDATA[mitre-attack]]></category>
            <category><![CDATA[ransomware]]></category>
            <category><![CDATA[ransomware-attack]]></category>
            <category><![CDATA[double-extortion]]></category>
            <dc:creator><![CDATA[Digvijay]]></dc:creator>
            <pubDate>Tue, 24 Nov 2026 15:25:43 GMT</pubDate>
            <atom:updated>2026-11-24T15:26:21.135Z</atom:updated>
            <content:encoded><![CDATA[<p>Encryption is what victims notice first. But in modern ransomware attacks, the damage often begins much earlier — when attackers quietly identify, collect, stage, and exfiltrate sensitive data.</p><p>This is the foundation of <strong>double extortion</strong>.</p><p>Even if an organization restores its systems from backups, attackers can still threaten to publish stolen data. Recovery solves the availability problem, but it does not necessarily solve the confidentiality breach.</p><p>For defenders, this changes the detection strategy. Waiting for mass file encryption means missing an important part of the attack.</p><p>The real opportunity is to detect suspicious data collection and movement before encryption begins.</p><h3>Understanding the Attack Sequence</h3><p>Double extortion typically involves two interconnected ATT&amp;CK stages: Collection (TA0009) and Exfiltration (TA0010).</p><p>During collection, attackers identify valuable information across endpoints, file servers, shared drives, and backup infrastructure. They may then consolidate the data into archives before transferring it outside the organization.</p><p>Relevant MITRE ATT&amp;CK techniques include:</p><ul><li><strong>T1005:</strong> Data from Local System</li><li><strong>T1039:</strong> Data from Network Shared Drive</li><li><strong>T1074:</strong> Data Staged</li><li><strong>T1560:</strong> Archive Collected Data</li><li><strong>T1041:</strong> Exfiltration Over C2 Channel</li><li><strong>T1048:</strong> Exfiltration Over Alternative Protocol</li><li><strong>T1567:</strong> Exfiltration Over Web Service</li><li><strong>T1020:</strong> Automated Exfiltration</li></ul><p>The broader attack sequence often looks like this:</p><p>Credential Access → Discovery / Lateral Movement → Collection → Staging → Exfiltration → Impact (T1486)</p><p>The important distinction is that data theft and encryption are separate attack objectives. Detecting one does not automatically mean detecting the other.</p><h3>What Should Defenders Actually Detect?</h3><p>One of the biggest challenges in detecting data theft is distinguishing suspicious activity from confirmed exfiltration.</p><p>For example, an archive created in a temporary directory may indicate data staging, but it does not prove that sensitive information was included. Similarly, an unusual outbound HTTPS connection may indicate a possible transfer, but network metadata alone cannot establish what data was transmitted.</p><p>A practical detection model should distinguish between three stages:</p><p><strong>1. Collection:</strong> Unusual access to sensitive directories, shared drives, financial records, HR data, or backup repositories.</p><p><strong>2. Staging:</strong> Archive creation, temporary storage activity, or unusual file consolidation on servers and jump hosts.</p><p><strong>3. Exfiltration:</strong> Unusual outbound traffic, large transfers to rare destinations, or cloud uploads outside approved enterprise applications.</p><p>The strongest detection comes from correlating these activities rather than treating each event as an independent alert.</p><p>A useful alert description would be:</p><blockquote><em>Suspicious data staging followed by unusual outbound transfer.</em></blockquote><p>This is more defensible than declaring a confirmed double-extortion breach based on archive creation and network activity alone.</p><h3>Telemetry That Matters</h3><p>Detecting pre-encryption data theft requires visibility across endpoint, network, cloud, and identity layers.</p><p>On Windows endpoints, Sysmon provides useful telemetry:</p><ul><li><strong>Event ID 1:</strong> Process creation, including archive utilities and scripting activity.</li><li><strong>Event ID 3:</strong> Network connections.</li><li><strong>Event ID 11:</strong> File creation, including potential staging artifacts.</li><li><strong>Event ID 22:</strong> DNS queries.</li></ul><p>These events become more valuable when combined with EDR file-access telemetry, proxy logs, DNS records, NetFlow, Zeek, and CASB upload events.</p><p>Identity telemetry is equally important. Correlating suspicious file access with Windows Event ID 4624 (successful logon) can help establish whether a newly authenticated identity began accessing sensitive servers before staging activity appeared.</p><p>For example, a new server logon followed by unusual access to multiple shared directories and archive creation deserves more attention than an isolated archive event.</p><h3>Building Practical Detection Analytics</h3><p>A useful first-stage analytic is detecting archive creation in unusual locations on servers and jump hosts.</p><p>The following Sigma-style rule provides a starting point:</p><pre>title: Suspicious Archive Staging on Server or Jump Host<br>id: 6b1e4a20-exfil-staging<br>status: experimental<br>description: &gt;<br>  Detects archive creation in potentially suspicious<br>  staging locations. Does not prove data theft.<br>logsource:<br>  product: windows<br>  category: file_event<br>detection:<br>  selection_ext:<br>    TargetFilename|endswith:<br>      - &#39;.zip&#39;<br>      - &#39;.7z&#39;<br>      - &#39;.rar&#39;<br>      - &#39;.tar&#39;<br>      - &#39;.gz&#39;<br>  selection_path:<br>    TargetFilename|contains:<br>      - &#39;\\Temp\\&#39;<br>      - &#39;\\Users\\Public\\&#39;<br>      - &#39;\\AppData\\Local\\Temp\\&#39;<br>      - &#39;\\PerfLogs\\&#39;<br>  condition: selection_ext and selection_path<br>falsepositives:<br>  - Software deployment packages<br>  - Backup and patching jobs<br>  - Developer build artifacts<br>level: low<br>tags:<br>  - attack.collection<br>  - attack.t1560<br>  - attack.t1074</pre><p>This analytic should be treated as a low-confidence staging signal, not a standalone ransomware detection.</p><p>The next step is correlation.</p><p>For example:</p><ul><li><strong>Analytic A — Staging:</strong> Detect unusual archive creation.</li><li><strong>Analytic B — Collection:</strong> Identify bulk access to sensitive directories by non-backup identities.</li><li><strong>Analytic C — Exfiltration:</strong> Detect unusual outbound traffic following staging activity.</li><li><strong>Analytic D — DNS anomalies:</strong> Identify suspicious DNS patterns that may indicate alternative communication channels.</li></ul><p>The highest-value detection is generated when multiple signals occur within a defined time window and share the same endpoint, identity, or process lineage.</p><h3>Validating Detection Through Purple Teaming</h3><p>Detection logic should be validated before relying on it during an actual ransomware incident.</p><p>A controlled purple-team exercise can simulate the collection, staging, and outbound telemetry using synthetic data and a lab-controlled destination.</p><p>The exercise should validate three things:</p><ol><li>Synthetic sensitive files are accessed and staging activity is generated.</li><li>Archive creation is visible through endpoint telemetry.</li><li>Simulated outbound activity reaches a controlled lab sink, or is blocked and logged by the egress controls.</li></ol><p>A simple lab architecture looks like this:</p><pre>Windows Lab Host<br>       |<br>Synthetic Test Data<br>       |<br>Controlled Staging Simulation<br>       |<br>Lab-Controlled Egress Sink<br>       |<br>Sysmon + Proxy + DNS<br>       |<br>       SIEM<br>       |<br>Correlated Detection<br>       |<br>    Pass / Fail</pre><p>Map the simulation to relevant ATT&amp;CK techniques:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*-wriJ2UloOL1KG6uhqtrSA.png" /></figure><p>The success criteria should be straightforward: staging activity is detected, outbound activity is visible or blocked, and the SIEM correlates the events into a single investigation.</p><h3>Strengthening the Detection Strategy</h3><p>Detection alone is not enough. Organizations should reduce the opportunity for attackers to move sensitive data outside the environment.</p><p>Prioritize:</p><ul><li>Restricting outbound internet access from file and backup servers.</li><li>Applying least privilege to crown-jewel shares.</li><li>Monitoring bulk data access and archive creation.</li><li>Enforcing CASB and DLP policies for sensitive cloud uploads.</li><li>Segmenting backup infrastructure from general-purpose servers.</li><li>Maintaining immutable backups and independently tested recovery procedures.</li></ul><p>These controls reduce both the likelihood of successful exfiltration and the impact of subsequent encryption.</p><h3>Final Thoughts</h3><p>Ransomware is no longer just an encryption problem. It is increasingly a data confidentiality, availability, and business resilience problem.</p><p>An organization that detects encryption quickly but misses the preceding data theft may still face regulatory exposure, reputational damage, and extortion.</p><p>The objective for defenders should be to move detection earlier in the attack chain:</p><p><strong>Detect collection. Identify staging. Correlate outbound activity. Respond before encryption.</strong></p><p>Because by the time the lock screen appears, the data may already be gone.</p><p><em>Steal before the lock. Detect before the leak.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee5873d1a73b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mapping the House Before the Fire: Discovery and Lateral Movement in Ransomware Intrusions]]></title>
            <link>https://medium.com/@ddigvijay/mapping-the-house-before-the-fire-discovery-and-lateral-movement-in-ransomware-intrusions-dcb5fc1b39e8?source=rss-bd4bfddba65------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcb5fc1b39e8</guid>
            <category><![CDATA[threat-detection]]></category>
            <category><![CDATA[ransomware]]></category>
            <category><![CDATA[lateral-movement]]></category>
            <category><![CDATA[windows-security]]></category>
            <category><![CDATA[discovery]]></category>
            <dc:creator><![CDATA[Digvijay]]></dc:creator>
            <pubDate>Fri, 16 Oct 2026 04:19:38 GMT</pubDate>
            <atom:updated>2026-10-16T04:19:38.532Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Credential access answers one question: <em>who can the attacker become?</em></strong></h3><p><strong>Discovery and lateral movement answer the next: <em>how far can that identity go?</em></strong></p><p>Encryption is still the headline.</p><p>The enterprise-wide outage usually requires something quieter first mapping shares, trusts, backup tooling, and admin paths, then moving from one host to many with valid credentials and familiar remote-admin patterns.</p><p>This article focuses on a practical Windows detection model for that middle of the ransomware kill chain:</p><ul><li>What to observe</li><li>What an alert actually proves</li><li>How to correlate discovery with identity expansion</li><li>How to build a purple-team lab that validates telemetry with authorized simulation</li></ul><p>The goal is <strong>not</strong> to provide a public remote-exploitation cookbook. The goal is to build detection capability around the behaviors that can precede ransomware impact.</p><h3>Where This Sits in MITRE ATT&amp;CK</h3><h3>Discovery — TA0007</h3><p>Common ransomware-relevant techniques include:</p><ul><li><strong>T1135</strong> — Network Share Discovery</li><li><strong>T1482</strong> — Domain Trust Discovery</li><li><strong>T1518</strong> — Software Discovery (especially backup / security products)</li><li><strong>T1087</strong> — Account Discovery</li><li><strong>T1018</strong> — Remote System Discovery</li></ul><h3>Lateral Movement — TA0008</h3><p>Common ransomware-relevant techniques include:</p><ul><li><strong>T1021.002</strong> — SMB/Windows Admin Shares</li><li><strong>T1570</strong> — Lateral Tool Transfer</li><li><strong>T1550</strong> — Use Alternate Authentication Material (e.g. ticket abuse patterns)</li><li><strong>T1021.001</strong> — Remote Desktop Protocol (where enabled)</li></ul><p>A useful defensive sequence is:</p><pre>Credential Access → Discovery → Lateral Movement → Collection/Exfil → Impact</pre><p>This is a <strong>defensive sequence, not a mandatory attacker script</strong>.</p><p>If you only alert on mass file encryption, you are measuring the fire.</p><p><strong>Discovery and lateral movement are where you can still interrupt the spread.</strong></p><h3>First Rule: Know What Your Alert Actually Proves</h3><p>A share enumeration event is <strong>not</strong> proof the attacker will encrypt that share.</p><p>A remote service create is <strong>not</strong> proof ransomware deployed everywhere.</p><p>A successful admin logon to a new server is <strong>not</strong> proof Domain Admin was stolen.</p><p>This distinction matters because detection engineering becomes dangerous when individual telemetry events are promoted into conclusions they cannot actually support.</p><p>Separate the evidence layers:</p><ol><li>A host <strong>looked for</strong> network shares / trusts / backup software.</li><li>An identity <strong>authenticated</strong> to a new destination.</li><li>A remote <strong>execution / tool transfer</strong> pattern appeared.</li><li>That identity then touched <strong>backup</strong> or <strong>many file servers</strong>.</li><li>Impact (encryption / note drop) followed.</li></ol><p>A good first-stage detection statement is:</p><blockquote><strong><em>Suspicious network share discovery from a non-admin workstation.</em></strong></blockquote><p>Not:</p><blockquote><strong><em>Ransomware lateral movement confirmed.</em></strong></blockquote><p>The first statement accurately describes the observed behavior.</p><p>The second claims an outcome that the individual event does not establish.</p><h3>What “Mapping the House” Looks Like</h3><p>Before impact, operators typically want answers like:</p><ul><li>Which shares are reachable with this identity?</li><li>Where are the file servers and DFS namespaces?</li><li>What backup products are installed, and on which hosts?</li><li>Which domain trusts expand the blast radius?</li><li>Which admin tools already exist on the estate (PsExec-class, WMI, WinRM, RDP)?</li></ul><p>From a defender’s seat, that often shows up as:</p><ul><li>bursty net / PowerShell / WMI / LDAP enumeration from unusual hosts</li><li>sudden SMB session creation to many \\server\share targets</li><li>service / process discovery aimed at backup agents</li><li>remote logons (4624) from a workstation identity onto servers it never touches</li><li>remote service installation or scheduled-task style execution patterns</li></ul><p>None of these require malware with a scary name.</p><p><strong>Valid credentials plus living-off-the-land tooling are enough.</strong></p><h3>Telemetry That Matters</h3><p>A practical detection strategy starts by understanding which telemetry gives you process context, which gives you network behavior, and which gives you identity context.</p><h3>Endpoint / Sysmon</h3><ul><li><strong>Sysmon 1</strong> ProcessCreate — who launched discovery / remote-admin binaries, parent chain, command line</li><li><strong>Sysmon 3</strong> NetworkConnect — outbound SMB (445), WinRM (5985/5986), RDP (3389) from unusual sources</li><li><strong>Sysmon 11</strong> FileCreate — tool staging (enrichment, not proof alone)</li></ul><h3>Windows Security / Identity</h3><ul><li><strong>4624</strong> — logon success (Type 3 / Type 10 to new servers)</li><li><strong>4625</strong> — failures</li><li><strong>4648</strong> — explicit credential use</li><li><strong>4672</strong> — special privileges assigned</li><li><strong>5140 / 5145</strong> — network share access (when audited)</li></ul><h3>Directory / Environment</h3><p>Look for:</p><ul><li>LDAP / AD enumeration spikes from non-DC, non-IT sources</li><li>Trust / privileged group / SPN interrogation</li><li>Backup console / agent inventory from unexpected hosts</li></ul><p>The important point is that no single telemetry source provides the entire story.</p><p>You need to connect <strong>process behavior + network behavior + identity behavior + destination context</strong>.</p><h3>Building a Practical First-Stage Detection</h3><p>Start with <strong>discovery from the wrong place</strong>, then join it to <strong>identity expansion</strong>.</p><p>The first analytic should be intentionally conservative.</p><h3>Analytic A — Share Discovery Burst</h3><p><strong>Experimental Sigma:</strong></p><pre>title: Suspicious Network Share Discovery Burst<br>id: 5e2a9c10-disc-share-burst<br>status: experimental<br>description: &gt;<br>  Detects processes commonly used for share discovery on Windows.<br>  Enumeration alone does not prove lateral movement or ransomware intent.<br>logsource:<br>  product: windows<br>  category: process_creation<br>detection:<br>  selection_img:<br>    Image|endswith:<br>      - &#39;\net.exe&#39;<br>      - &#39;\net1.exe&#39;<br>      - &#39;\powershell.exe&#39;<br>      - &#39;\pwsh.exe&#39;<br>  selection_cli:<br>    CommandLine|contains:<br>      - &#39; view&#39;<br>      - &#39;share&#39;<br>      - &#39;Get-SmbShare&#39;<br>      - &#39;Get-SmbConnection&#39;<br>      - &#39;NetShareEnum&#39;<br>  condition: selection_img and selection_cli<br>falsepositives:<br>  - IT inventory / SCCM / vulnerability scanners<br>  - Backup discovery jobs<br>  - Helpdesk troubleshooting<br>level: low<br>tags:<br>  - attack.discovery<br>  - attack.t1135</pre><p>Keep this <strong>low</strong> until correlated.</p><p>The analytic deliberately detects a behavior that can be useful for discovery without claiming that the behavior itself represents ransomware.</p><h3>Analytic B — New Server Logons After Discovery</h3><p>Within <strong>N minutes</strong> of Analytic A on host <strong>H</strong> under user <strong>U</strong>:</p><p><strong>4624</strong> for <strong>U</strong> to <strong>≥ K distinct servers</strong> that identity rarely accessed — especially <strong>Type 3 from H</strong>.</p><p>This adds the identity and destination dimensions to the initial discovery signal.</p><p>The important transition is:</p><pre>Discovery<br>    ↓<br>Identity<br>    ↓<br>New destinations</pre><p>That is substantially more useful than treating the original share-enumeration event in isolation.</p><h3>Analytic C — Remote Execution Pattern</h3><p>Look for:</p><ul><li>Service creation / PsExec-class patterns</li><li>WinRM/WMI remote process create from a workstation</li><li>Admin-share writes followed by service start</li></ul><p>Alert this as:</p><blockquote><strong><em>Possible remote execution</em></strong></blockquote><p>not:</p><blockquote><strong><em>Ransomware confirmed</em></strong></blockquote><p>Again, the detection language should match the evidence.</p><h3>Purple-Team Lab PoC — Authorized Simulation</h3><p>The purpose of the lab is to validate that the telemetry pipeline can actually observe the behaviors the analytics depend on.</p><pre>[ Windows lab workstation + agent ]<br>        |<br>        v<br>[ Windows lab member server ]<br>        |<br>        v<br>[ Sysmon → SIEM ]<br>[ simulation test ]</pre><p>The lab should be treated as an authorized environment.</p><p>The validation objective is:</p><pre>Launch Pad<br>    ↓<br>Lab agent<br>    ↓<br>Observable Windows telemetry<br>    ↓<br>SIEM ingestion<br>    ↓<br>Detection analytic<br>    ↓<br>Correlated alert</pre><h3>Path 1 — Discovery</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XxNPiowYvvOyGCPv-s77xQ.png" /></figure><p><strong>Launch Pad → lab agent → confirm Sysmon + Analytic A.</strong></p><p>The important validation question is not simply whether the simulation executed.</p><p><strong>It is whether:</strong></p><ol><li>The endpoint generated the expected telemetry.</li><li>The telemetry reached the SIEM.</li><li>The expected fields survived normalization.</li><li>Analytic A matched.</li><li>The resulting alert retained the source context needed for investigation.</li></ol><h3>Path 2 — Lateral Movement — Lab Only</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yA4Z8Ptp6hBntXAoQRTLVA.png" /></figure><p>The validation condition is:</p><blockquote><strong><em>Pass when source, target, user, and run ID are in the alert.</em></strong></blockquote><p>That gives the analyst enough context to connect the observed activity back to the specific authorized simulation.</p><p>If prevention blocks it, that is still a useful control test.</p><p><strong>Do not disable defenses to force success.</strong></p><p>A blocked action can validate that the prevention layer is working, while the resulting telemetry can validate whether the detection pipeline sees and records the attempted behavior.</p><h3>Correlation Clusters</h3><p>The real detection value appears when individual events are connected into behavioral clusters.</p><h3>Cluster A — Mapping</h3><pre>unusual process<br>      ↓<br>share / trust / backup discovery<br>      ↓<br>many targets</pre><p>This represents an identity or process attempting to understand the environment.</p><h3>Cluster B — Expansion</h3><pre>discovery<br>      ↓<br>unusual identity<br>      ↓<br>new server logons<br>      ↓<br>remote execution</pre><p>This is stronger because it demonstrates movement from environmental discovery toward destination expansion.</p><h3>Cluster C — Pre-Impact</h3><pre>lateral reach<br>      ↓<br>backup admin<br>      ↓<br>mass file/share activity</pre><p>This is closer to the operational objective that makes ransomware campaigns so damaging.</p><p>The stronger the chain becomes, the more confidently the defender can escalate the investigation.</p><h3>The Strongest Statement</h3><p>Instead of describing one event as ransomware, correlate the sequence.</p><p>A strong investigation statement is:</p><blockquote><strong><em>A workstation identity enumerated shares, then authenticated to multiple file servers it had never accessed, then performed remote execution investigate as ransomware staging.</em></strong></blockquote><p>Notice the wording.</p><p>It does not say:</p><blockquote><em>Ransomware confirmed.</em></blockquote><p>It says:</p><blockquote><strong><em>Investigate as ransomware staging.</em></strong></blockquote><p>That distinction keeps the analytic evidence-based while still giving responders an actionable signal.</p><h3>Hardening</h3><p>Detection should not be the only control.</p><p>The same attack path can be made harder to traverse through environmental controls such as:</p><ul><li><strong>Tiered admin / PAWs</strong></li><li><strong>Remove standing local admin</strong></li><li><strong>Restrict remote admin tools by OU</strong></li><li><strong>Segment backup infrastructure</strong></li><li><strong>JIT server logons</strong></li><li><strong>Baseline who may RDP/WinRM/PsExec to servers</strong></li></ul><p>The objective is to reduce the number of paths available to an identity even if credentials are compromised.</p><p>In other words:</p><pre>Compromised identity<br>        ↓<br>Discovery<br>        ↓<br>Restricted reach<br>        ↓<br>Limited lateral movement<br>        ↓<br>Reduced blast radius</pre><h3>Takeaway</h3><p>Discovery is the attacker <strong>learning the floor plan</strong>.</p><p>Lateral movement is them <strong>walking the halls</strong>.</p><p>Encryption is them <strong>locking the doors</strong>.</p><p>The earlier stages give defenders an opportunity to interrupt the intrusion before the enterprise reaches the impact phase.</p><p>The detection strategy should therefore evolve from isolated events into a sequence:</p><pre>Discovery<br>    ↓<br>Identity expansion<br>    ↓<br>New destinations<br>    ↓<br>Remote execution<br>    ↓<br>Backup / file-server reach<br>    ↓<br>Impact</pre><p>The goal is not to make every discovery event a high-severity alert.</p><p>The goal is to recognize when individually explainable behaviors begin forming a ransomware-relevant chain.</p><h3>Lab Recipe</h3><pre>Authorized purple-team simulation<br>    ↓<br>Network share discovery (T1135) + Backup software discovery (T1518)<br>    ↓<br>Lab-only PsExec-style remote execution (T1570)<br>    ↓<br>Sysmon + Windows 4624<br>    ↓<br>Correlated alert<br>    ↓<br>Pass / fail</pre><p><strong>Pass when the detection pipeline preserves enough context to answer:</strong></p><ul><li><strong>Who</strong> initiated the activity?</li><li><strong>Where</strong> did it originate?</li><li><strong>What</strong> did it discover or access?</li><li><strong>Which</strong> destination did it reach?</li><li><strong>When</strong> did the sequence occur?</li><li><strong>Which run ID</strong> generated the activity?</li></ul><p>That is the difference between collecting logs and having a detection system capable of supporting an investigation.</p><h3>Final Principle</h3><p>The most useful ransomware detections are rarely the ones that simply say:</p><blockquote><strong><em>Something bad happened.</em></strong></blockquote><p>They are the ones that show:</p><blockquote><strong><em>This identity started learning the environment, expanded its reach, and began using that reach in a way that is inconsistent with its normal role.</em></strong></blockquote><p>That is the window where defenders can still interrupt the spread.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcb5fc1b39e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Detecting Credential Access Before Ransomware Spreads]]></title>
            <link>https://medium.com/@ddigvijay/detecting-credential-access-before-ransomware-spreads-4a1ea0e4142a?source=rss-bd4bfddba65------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a1ea0e4142a</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[identity]]></category>
            <category><![CDATA[ransomware]]></category>
            <category><![CDATA[windows-security]]></category>
            <category><![CDATA[threat-detection]]></category>
            <dc:creator><![CDATA[Digvijay]]></dc:creator>
            <pubDate>Mon, 12 Oct 2026 20:32:47 GMT</pubDate>
            <atom:updated>2026-10-12T20:32:47.037Z</atom:updated>
            <content:encoded><![CDATA[<p>Encryption is the visible part of a ransomware incident.</p><p>The more useful question often comes earlier:</p><p><strong>How did the attacker obtain permission to reach so many systems?</strong></p><p>A compromised workstation gives an intruder one foothold. Credentials with access to servers, identity infrastructure, or backup administration can expand that foothold considerably. The actual impact depends on the account’s permissions and the boundaries around it.</p><p>For a detection engineer, that creates an important opportunity:</p><blockquote><strong><em>Detect suspicious access to authentication material before the identity becomes a vehicle for lateral movement and recovery disruption.</em></strong></blockquote><p>This article builds one measurable Windows credential-access detection and connects it to the identity telemetry needed for a ransomware investigation.</p><p><strong>The lab contains:</strong></p><ul><li>Sysmon configuration</li><li>PowerShell simulation</li><li>Optional LSASS handle probe</li><li>Python detection logic</li><li>Synthetic event replay</li><li>Sigma detection</li><li>Regression tests</li><li>Live Windows event export</li><li>DCSync detection considerations</li><li>Kerberoasting detection considerations</li><li>Investigation and response guidance</li></ul><h3>Know Exactly What Your Alert Proves</h3><p><strong>LSASS the</strong> <strong>Local Security Authority Subsystem Service</strong> : participates in Windows authentication.</p><p>Its memory can contain authentication material, depending on the authentication mechanisms and protections in use.</p><p>MITRE ATT&amp;CK maps extraction from that memory to:</p><p><strong>T1003.001 OS Credential Dumping: LSASS Memory</strong></p><p>But defenders need to distinguish three different observations.</p><h3>1. Process access</h3><p>A process obtained access to another process.</p><p>That gives us:</p><ul><li>Source</li><li>Target</li><li>Access mask</li><li>Process identity</li><li>Timestamp</li></ul><h3>2. Dump-like artifact</h3><p>A process created a file ending in .dmp.</p><p>That provides additional evidence, but the extension says nothing reliable about the contents.</p><h3>3. Credential extraction or use</h3><p>Authentication material was actually extracted or subsequently used.</p><p>That requires additional evidence.</p><p><strong>Collapsing these observations into:</strong></p><blockquote><em>“Credentials stolen.”</em></blockquote><p>makes an alert sound more certain than the telemetry supports.</p><p>The simulation opens and closes a process handle and then writes plain text to a file ending in .dmp.</p><p><strong>No credential extraction occurs.</strong></p><p>Therefore, the analytic should initially report:</p><blockquote><strong><em>LSASS access with memory-read capability detected.</em></strong></blockquote><p>The analyst can increase the confidence level as additional evidence is correlated.</p><h3>Read the Access Mask Before Tuning the Rule</h3><p>Three Sysmon events support the lab.</p><p>EventPurpose<strong>Event 1 — ProcessCreate</strong>Process identity, command line, and lineage<strong>Event 10 — ProcessAccess</strong>One process opening another process<strong>Event 11 — FileCreate</strong>Creation or overwrite of a file</p><p>Collect these from:</p><pre>Microsoft-Windows-Sysmon/Operational</pre><p>An important limitation:</p><p><strong>Event 11 is not general file-read telemetry.</strong></p><p>Therefore, it cannot establish that a browser password database was read.</p><p>For Event 10, preserve:</p><pre>SourceImage<br>TargetImage<br>GrantedAccess<br>SourceProcessGUID<br>TargetProcessGUID<br>UtcTime<br>Computer</pre><p>Also preserve CallTrace and available user fields for investigation.</p><h3>Understanding GrantedAccess</h3><p>GrantedAccess is a bitmask, not a severity score.</p><p>Relevant Windows rights include:</p><pre>0x0010 = PROCESS_VM_READ<br>0x0400 = PROCESS_QUERY_INFORMATION<br>0x1000 = PROCESS_QUERY_LIMITED_INFORMATION</pre><p>Therefore:</p><pre>0x1010</pre><p>contains:</p><pre>0x1000 + 0x0010</pre><p>and includes limited-query and memory-read rights.</p><p><strong>Similarly:</strong></p><pre>0x1410</pre><p>includes both query bits and memory-read rights.</p><p><strong>A recorded mask containing:</strong></p><pre>0x0010</pre><p>establishes a <strong>capability</strong>.</p><p>It does not establish that a memory read actually occurred.</p><p>For a native analytic, test the bit explicitly:</p><pre>has_memory_read = (mask &amp; 0x0010) != 0</pre><p>A hexadecimal substring search is not equivalent.</p><p>An exact list of masks is easier to express in a portable Sigma rule, but necessarily covers fewer combinations.</p><p>And keep the scope honest:</p><blockquote><strong><em>This is one analytic, not a complete credential-theft detector.</em></strong></blockquote><h3>Simulation PoC That Generates Observable Behavior</h3><h3>Windows execution</h3><p>A process generates real process-access and file-creation activity.</p><p>An optional probe attempts the same handle request against LSASS.</p><h3>Portable replay</h3><p>Invented LSASS events exercise the detector on Windows, macOS, or Linux.</p><p>This validates the detection logic without touching a Windows process.</p><p>Use:</p><ul><li>Disposable Windows VM</li><li>VM snapshot</li><li>Windows PowerShell 5.1</li><li>Sysmon</li><li>Python 3.9+</li><li>No third-party Python packages</li></ul><p>The Python portion can run on another machine.</p><p><strong>Keep endpoint protection enabled.</strong></p><h3>Configure the Lab</h3><p>Open an elevated Windows PowerShell 5.1 terminal in the disposable VM:</p><pre>New-Item -ItemType Directory -Path C:\CredentialAccessLab -Force | Out-Null<br>Set-Location C:\CredentialAccessLab</pre><p>Obtain Sysmon from Microsoft and place:</p><pre>Sysmon64.exe</pre><p>in this directory.</p><p>The detector uses only the Python standard library.</p><p>Keep the following files together:</p><pre>CredentialAccessLab/<br>  sysmon-lab.xml<br>  Invoke-CredentialAccessSimulation.ps1<br>  Export-SysmonEvents.ps1<br>  detect.py<br>  make_fixtures.py<br>  lsass_access.yml<br>  test_detect.py</pre><p>Use a plain-text editor, preserve indentation, and save the exact extensions.</p><h3>Sysmon Configuration</h3><p>Save the following as:</p><pre>sysmon-lab.xml</pre><pre>&lt;Sysmon schemaversion=&quot;4.90&quot;&gt;<br>  &lt;EventFiltering&gt;<br>    &lt;RuleGroup name=&quot;Lab process creation&quot; groupRelation=&quot;or&quot;&gt;<br>      &lt;ProcessCreate onmatch=&quot;exclude&quot; /&gt;<br>    &lt;/RuleGroup&gt;<br>    &lt;RuleGroup name=&quot;Credential access lab targets&quot; groupRelation=&quot;or&quot;&gt;<br>      &lt;ProcessAccess onmatch=&quot;include&quot;&gt;<br>        &lt;TargetImage condition=&quot;end with&quot;&gt;\lsass.exe&lt;/TargetImage&gt;<br>        &lt;TargetImage condition=&quot;end with&quot;&gt;\CredentialLabTarget.exe&lt;/TargetImage&gt;<br>      &lt;/ProcessAccess&gt;<br>    &lt;/RuleGroup&gt;<br>    &lt;RuleGroup name=&quot;Lab dump extension artifacts&quot; groupRelation=&quot;or&quot;&gt;<br>      &lt;FileCreate onmatch=&quot;include&quot;&gt;<br>        &lt;TargetFilename condition=&quot;end with&quot;&gt;.dmp&lt;/TargetFilename&gt;<br>      &lt;/FileCreate&gt;<br>    &lt;/RuleGroup&gt;<br>  &lt;/EventFiltering&gt;<br>&lt;/Sysmon&gt;</pre><p>Check the installed schema:</p><pre>.\Sysmon64.exe -s</pre><p>Choose <strong>one</strong> installation method.</p><p>Fresh installation:</p><pre>.\Sysmon64.exe -i .\sysmon-lab.xml</pre><p>Existing installation:</p><pre>.\Sysmon64.exe -c .\sysmon-lab.xml</pre><p>Applying a configuration replaces the active configuration; it does not merge with it.</p><p>Retain the original configuration or restore the VM snapshot afterward.</p><p>Verify:</p><pre>Get-Service *Sysmon*</pre><p>and:</p><pre>Get-WinEvent -ListLog &#39;Microsoft-Windows-Sysmon/Operational&#39;</pre><h3>Write and Run the Windows Simulator</h3><p>The simulator has two modes.</p><h3>Surrogate</h3><p>Compiles:</p><pre>CredentialLabTarget.exe</pre><p>The program only sleeps and is started as a child process.</p><h3>LsassHandle</h3><p>Uses the existing LSASS process as the target.</p><p>Both modes request:</p><pre>0x1010</pre><p>and close the handle without reading memory.</p><p>On successful execution, the PowerShell process creates:</p><pre>simulation-marker.dmp</pre><p>containing plain text.</p><p>This allows the process-access event and file-creation event to be attributed to the same source process.</p><p>Save the following as:</p><pre>Invoke-CredentialAccessSimulation.ps1</pre><pre>#requires -Version 5.1<br>&lt;#<br>Run in a fresh Windows PowerShell 5.1 process in a disposable Windows VM.<br>Surrogate opens only a lab-owned process. LsassHandle attempts one handle open.<br>Neither mode reads process memory, dumps memory, or changes security controls.<br>#&gt;<br>[CmdletBinding()]<br>param(<br>    [ValidateSet(&#39;Surrogate&#39;, &#39;LsassHandle&#39;)]<br>    [string]$Mode = &#39;Surrogate&#39;<br>)<br>Set-StrictMode -Version Latest<br>$ErrorActionPreference = &#39;Stop&#39;<br>if ($PSVersionTable.PSEdition -ne &#39;Desktop&#39;) {<br>    throw &#39;Use Windows PowerShell 5.1 (powershell.exe), not PowerShell 7.&#39;<br>}<br>Add-Type -TypeDefinition @&#39;<br>using System;<br>using System.Runtime.InteropServices;<br>public static class CredentialLabHandleProbe<br>{<br>    [DllImport(&quot;kernel32.dll&quot;, SetLastError = true)]<br>    private static extern IntPtr OpenProcess(<br>        uint access,<br>        bool inherit,<br>        uint pid);<br>    [DllImport(&quot;kernel32.dll&quot;, SetLastError = true)]<br>    private static extern bool CloseHandle(IntPtr handle);<br>    public static int Run(uint pid)<br>    {<br>        // PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_VM_READ.<br>        IntPtr handle = OpenProcess(0x1010, false, pid);<br>        if (handle == IntPtr.Zero)<br>            return Marshal.GetLastWin32Error();<br>        // No memory read or dump operation is performed.<br>        if (!CloseHandle(handle))<br>            return Marshal.GetLastWin32Error();<br>        return 0;<br>    }<br>}<br>&#39;@<br>$runId = [Guid]::NewGuid().ToString(&#39;N&#39;)<br>$runDirectory = Join-Path `<br>    (Join-Path $env:TEMP &#39;CredentialDetectionLab&#39;) `<br>    $runId<br>New-Item -ItemType Directory -Path $runDirectory | Out-Null<br>$ownedChild = $null<br>$resultCode = 0<br>try {<br>    if ($Mode -eq &#39;Surrogate&#39;) {<br>        $targetExe = Join-Path `<br>            $runDirectory `<br>            &#39;CredentialLabTarget.exe&#39;<br>        Add-Type -TypeDefinition @&#39;<br>public static class CredentialLabTarget<br>{<br>    public static void Main()<br>    {<br>        System.Threading.Thread.Sleep(60000);<br>    }<br>}<br>&#39;@ -OutputAssembly $targetExe -OutputType ConsoleApplication<br>        $ownedChild = Start-Process `<br>            -FilePath $targetExe `<br>            -PassThru<br>        $targetProcessId = $ownedChild.Id<br>        $targetLabel = $targetExe<br>    }<br>    else {<br>        $targetProcess = Get-Process `<br>            -Name lsass `<br>            -ErrorAction Stop<br>        $targetProcessId = $targetProcess.Id<br>        $targetLabel = Join-Path `<br>            $env:WINDIR `<br>            &#39;System32\lsass.exe&#39;<br>    }<br>    $startUtc = [DateTime]::UtcNow.ToString(&#39;o&#39;)<br>    $resultCode = [CredentialLabHandleProbe]::Run(<br>        [uint32]$targetProcessId<br>    )<br>    $artifact = $null<br>    if ($resultCode -eq 0) {<br>        $artifact = Join-Path `<br>            $runDirectory `<br>            &#39;simulation-marker.dmp&#39;<br>        [IO.File]::WriteAllText(<br>            $artifact,<br>            &quot;SYNTHETIC TEXT ONLY. No process memory or credentials. RunId=$runId&quot;<br>        )<br>    }<br>    $result = [ordered]@{<br>        RunId = $runId<br>        Mode = $Mode<br>        StartUtc = $startUtc<br>        EndUtc = [DateTime]::UtcNow.ToString(&#39;o&#39;)<br>        Computer = $env:COMPUTERNAME<br>        SourceProcessId = $PID<br>        TargetProcessId = $targetProcessId<br>        TargetImage = $targetLabel<br>        RequestedAccess = &#39;0x1010&#39;<br>        Result = $(<br>            if ($resultCode -eq 0) {<br>                &#39;HandleOpenedAndClosed&#39;<br>            }<br>            else {<br>                &#39;BlockedOrDenied&#39;<br>            }<br>        )<br>        Win32Error = $resultCode<br>        Artifact = $artifact<br>        RunDirectory = $runDirectory<br>    }<br>    $json = $result | ConvertTo-Json<br>    [IO.File]::WriteAllText(<br>        (Join-Path $runDirectory &#39;run.json&#39;),<br>        $json<br>    )<br>    $json<br>}<br>finally {<br>    if ($null -ne $ownedChild) {<br>        if (-not $ownedChild.HasExited) {<br>            $ownedChild.Kill()<br>        }<br>        $ownedChild.Dispose()<br>    }<br>}<br>if ($resultCode -ne 0) {<br>    Write-Warning `<br>        &#39;Probe did not succeed. No marker was created. Keep protections enabled.&#39;<br>    exit 2<br>}</pre><p>Run the harmless surrogate mode:</p><pre>powershell.exe -NoProfile `<br>    -File .\Invoke-CredentialAccessSimulation.ps1 `<br>    -Mode Surrogate</pre><p>Successful execution produces:</p><pre>Result = HandleOpenedAndClosed<br>Win32Error = 0</pre><p>The output identifies:</p><ul><li>Artifact</li><li>RunDirectory</li><li>SourceProcessId</li><li>TargetProcessId</li><li>UTC timestamps</li></ul><p>The same information is stored in:</p><pre>run.json</pre><p>Retain the source PID, target PID, UTC timestamps, and run directory.</p><p>They allow you to identify the exact test execution in the telemetry.</p><h3>Optional LSASS Handle Probe</h3><p>In the same isolated VM:</p><pre>powershell.exe -NoProfile `<br>    -File .\Invoke-CredentialAccessSimulation.ps1 `<br>    -Mode LsassHandle</pre><p>This performs the same open-and-close operation against LSASS.</p><p>It does <strong>not</strong>:</p><ul><li>Enable debug privileges</li><li>Read memory</li><li>Extract credentials</li><li>Disable security controls</li></ul><p><strong>Access can be denied because of:</strong></p><ul><li>Process permissions</li><li>LSA protection</li><li>Endpoint security</li></ul><p>If denied, the script reports:</p><pre>BlockedOrDenied</pre><p>and returns exit code:</p><pre>2</pre><p>No .dmp marker is created.</p><p>Do <strong>not</strong> disable protections to force a successful test.</p><p>A prevention event is useful telemetry in its own right.</p><blockquote><em>A denied probe should not be counted as an </em><strong><em>Event 10</em></strong><em> detection pass.</em></blockquote><p>Use the surrogate and replay paths to validate the remaining detection components.</p><h3>Detection PoC With Reproducible Pass Criteria</h3><p>The Python detector reads exported Sysmon events as JSON Lines.</p><p>It generates an access alert when:</p><ol><li>Provider and channel identify Sysmon.</li><li>EventID = 10.</li><li>TargetImage ends with \lsass.exe.</li><li>GrantedAccess contains the 0x0010 memory-read bit.</li></ol><p>It then searches for <strong>Event 11</strong> records containing a .dmp filename.</p><p>A file becomes a companion only when:</p><pre>Computer<br>+<br>Process GUID<br>+<br>Event time</pre><p>match the access event and the file occurs between:</p><pre>0 and 120 seconds</pre><p>after the access.</p><p>The process join is:</p><pre>Event 10:<br>Computer + SourceProcessGUID</pre><pre>Event 11:<br>Computer + ProcessGuid</pre><p>Do <strong>not</strong> join using Event 10’s TargetProcessGUID.</p><p>That identifies LSASS rather than the process that may have written the file.</p><p>Do not use PID alone because PIDs can be reused.</p><p>Most importantly:</p><blockquote><strong><em>The access alert does not depend on the dump file.</em></strong></blockquote><h3>Python Detector</h3><p>Save the complete detector as:</p><pre>detect.py</pre><pre>#!/usr/bin/env python3<br>&quot;&quot;&quot;Offline Sysmon JSONL detector. Python 3.9+, standard library only.Native analytic: memory-read bit, broader than the bundled exact-mask Sigma rule.<br>This is a finite-file validation tool, not a streaming SIEM or Sigma interpreter.<br>&quot;&quot;&quot;<br>import argparse<br>from datetime import datetime, timezone<br>import json<br>from pathlib import Path<br>import re<br>import sys<br>from uuid import UUID<br><br>PROVIDER = &quot;Microsoft-Windows-Sysmon&quot;<br>CHANNEL = &quot;Microsoft-Windows-Sysmon/Operational&quot;<br>TARGETS = {<br>    &quot;lsass&quot;: &quot;\\lsass.exe&quot;,<br>    &quot;surrogate&quot;: &quot;\\credentiallabtarget.exe&quot;<br>}<br><br>def nonempty(row, name):<br>    value = row.get(name)<br>    if not isinstance(value, str) or not value.strip():<br>        raise ValueError(&quot;missing or invalid &quot; + name)<br>    return value.strip()<br><br>def process_guid(row, name):<br>    value = UUID(nonempty(row, name))<br>    if value.int == 0:<br>        raise ValueError(&quot;zero &quot; + name)<br>    return str(value)<br><br>def event_time(row):<br>    # UtcTime is a Sysmon UTC field even when<br>    # its text has no timezone suffix.<br>    raw = row.get(&quot;UtcTime&quot;) or nonempty(row, &quot;TimeCreated&quot;)<br>    if not isinstance(raw, str):<br>        raise ValueError(&quot;timestamp must be a string&quot;)<br>    # .NET round-trip timestamps can contain seven<br>    # fractional digits. Normalize to microseconds.<br>    raw = re.sub(<br>        r&quot;\.(\d+)&quot;,<br>        lambda m: &quot;.&quot; + (m.group(1) + &quot;000000&quot;)[:6],<br>        raw<br>    )<br>    stamp = datetime.fromisoformat(<br>        raw.replace(&quot;Z&quot;, &quot;+00:00&quot;)<br>    )<br>    if stamp.tzinfo is None:<br>        if not row.get(&quot;UtcTime&quot;):<br>            raise ValueError(<br>                &quot;TimeCreated must include a timezone&quot;<br>            )<br>        stamp = stamp.replace(<br>            tzinfo=timezone.utc<br>        )<br>    return stamp.astimezone(timezone.utc)<br><br>def access_mask(value):<br>    if isinstance(value, bool):<br>        raise ValueError(&quot;invalid GrantedAccess&quot;)<br>    if isinstance(value, int):<br>        number = value<br>    elif isinstance(value, str):<br>        value = value.strip().lower()<br>        number = int(<br>            value,<br>            16 if value.startswith(&quot;0x&quot;) else 10<br>        )<br>    else:<br>        raise ValueError(<br>            &quot;missing or invalid GrantedAccess&quot;<br>        )<br>    if not 0 &lt;= number &lt;= 0xFFFFFFFF:<br>        raise ValueError(<br>            &quot;GrantedAccess is outside uint32&quot;<br>        )<br>    return number<br><br>def detect(rows, mode=&quot;lsass&quot;, window=120):<br>    if mode not in TARGETS or window &lt; 0:<br>        raise ValueError(<br>            &quot;invalid mode or time window&quot;<br>        )<br>    accesses = []<br>    artifacts = {}<br>    errors = []<br>    seen = set()<br>    ignored = 0<br>    duplicates = 0<br>    for line_number, row in enumerate(rows, 1):<br>        try:<br>            if not isinstance(row, dict):<br>                raise ValueError(<br>                    &quot;event must be an object&quot;<br>                )<br>            if (<br>                row.get(&quot;Provider&quot;) != PROVIDER<br>                or row.get(&quot;Channel&quot;) != CHANNEL<br>            ):<br>                ignored += 1<br>                continue<br>            event_id = int(<br>                row.get(&quot;EventID&quot;, -1)<br>            )<br>            if event_id not in (10, 11):<br>                ignored += 1<br>                continue<br>            host = nonempty(<br>                row,<br>                &quot;Computer&quot;<br>            ).casefold()<br>            stamp = event_time(row)<br>            record_id = int(<br>                row[&quot;EventRecordID&quot;]<br>            )<br>            if record_id &lt; 1:<br>                raise ValueError(<br>                    &quot;invalid EventRecordID&quot;<br>                )<br>            identity = (<br>                host,<br>                record_id,<br>                stamp,<br>                event_id<br>            )<br>            if identity in seen:<br>                duplicates += 1<br>                continue<br>            seen.add(identity)<br>            if event_id == 10:<br>                guid = process_guid(<br>                    row,<br>                    &quot;SourceProcessGUID&quot;<br>                )<br>                nonempty(<br>                    row,<br>                    &quot;SourceImage&quot;<br>                )<br>                target = nonempty(<br>                    row,<br>                    &quot;TargetImage&quot;<br>                ).casefold()<br>                mask = access_mask(<br>                    row.get(&quot;GrantedAccess&quot;)<br>                )<br>            else:<br>                guid = process_guid(<br>                    row,<br>                    &quot;ProcessGuid&quot;<br>                )<br>                filename = nonempty(<br>                    row,<br>                    &quot;TargetFilename&quot;<br>                )<br>            if (<br>                event_id == 10<br>                and target.endswith(TARGETS[mode])<br>                and mask &amp; 0x10<br>            ):<br>                accesses.append(<br>                    (<br>                        stamp,<br>                        host,<br>                        guid,<br>                        record_id,<br>                        mask,<br>                        row<br>                    )<br>                )<br>            elif (<br>                event_id == 11<br>                and filename.casefold().endswith(&quot;.dmp&quot;)<br>            ):<br>                artifacts.setdefault(<br>                    (host, guid),<br>                    []<br>                ).append(<br>                    (stamp, row)<br>                )<br>        except (<br>            ValueError,<br>            KeyError,<br>            TypeError,<br>            AttributeError<br>        ) as error:<br>            errors.append({<br>                &quot;line&quot;: line_number,<br>                &quot;error&quot;: str(error)<br>            })<br>    alerts = []<br>    for (<br>        stamp,<br>        host,<br>        guid,<br>        record_id,<br>        mask,<br>        row<br>    ) in sorted(<br>        accesses,<br>        key=lambda a: (<br>            a[0],<br>            a[1],<br>            a[3]<br>        )<br>    ):<br>        companions = []<br>        for (<br>            file_time,<br>            file_row<br>        ) in sorted(<br>            artifacts.get(<br>                (host, guid),<br>                []<br>            ),<br>            key=lambda a: a[0]<br>        ):<br>            delta = (<br>                file_time - stamp<br>            ).total_seconds()<br>            if 0 &lt;= delta &lt;= window:<br>                companions.append({<br>                    &quot;path&quot;:<br>                        file_row[<br>                            &quot;TargetFilename&quot;<br>                        ],<br>                    &quot;event_record_id&quot;:<br>                        int(<br>                            file_row[<br>                                &quot;EventRecordID&quot;<br>                            ]<br>                        ),<br>                    &quot;seconds_after_access&quot;:<br>                        delta<br>                })<br>        alerts.append({<br>            &quot;analytic&quot;:<br>                &quot;LSASS_ACCESS_VM_READ&quot;<br>                if mode == &quot;lsass&quot;<br>                else<br>                &quot;LAB_PROCESS_ACCESS_VM_READ&quot;,<br>            &quot;evidence_scope&quot;:<br>                &quot;handle access; credential extraction not established&quot;,<br>            &quot;computer&quot;:<br>                row[&quot;Computer&quot;],<br>            &quot;time_utc&quot;:<br>                stamp.isoformat(),<br>            &quot;event_record_id&quot;:<br>                record_id,<br>            &quot;source_process_guid&quot;:<br>                guid,<br>            &quot;source_image&quot;:<br>                row[&quot;SourceImage&quot;],<br>            &quot;target_image&quot;:<br>                row[&quot;TargetImage&quot;],<br>            &quot;granted_access&quot;:<br>                hex(mask),<br>            &quot;dump_extension_companions&quot;:<br>                companions<br>        })<br>    return {<br>        &quot;mode&quot;: mode,<br>        &quot;input_events&quot;:<br>            len(rows),<br>        &quot;ignored_events&quot;:<br>            ignored,<br>        &quot;duplicate_events&quot;:<br>            duplicates,<br>        &quot;rejected_events&quot;:<br>            errors,<br>        &quot;alert_count&quot;:<br>            len(alerts),<br>        &quot;alerts_with_companion&quot;:<br>            sum(<br>                bool(<br>                    a[<br>                        &quot;dump_extension_companions&quot;<br>                    ]<br>                )<br>                for a in alerts<br>            ),<br>        &quot;alerts&quot;:<br>            alerts<br>    }<br><br>def main():<br>    parser = argparse.ArgumentParser(<br>        description=__doc__<br>    )<br>    parser.add_argument(<br>        &quot;events&quot;,<br>        type=Path<br>    )<br>    parser.add_argument(<br>        &quot;--mode&quot;,<br>        choices=TARGETS,<br>        default=&quot;lsass&quot;<br>    )<br>    parser.add_argument(<br>        &quot;--window&quot;,<br>        type=int,<br>        default=120,<br>        help=&quot;inclusive seconds; default 120&quot;<br>    )<br>    parser.add_argument(<br>        &quot;--out&quot;,<br>        type=Path<br>    )<br>    args = parser.parse_args()<br>    if args.window &lt; 0:<br>        parser.error(<br>            &quot;--window must be nonnegative&quot;<br>        )<br>    try:<br>        lines = args.events.read_text(<br>            encoding=&quot;utf-8-sig&quot;<br>        ).splitlines()<br>        rows = [<br>            json.loads(line)<br>            for line in lines<br>            if line.strip()<br>        ]<br>        if not rows:<br>            raise ValueError(<br>                &quot;input has no events&quot;<br>            )<br>        report = detect(<br>            rows,<br>            args.mode,<br>            args.window<br>        )<br>        rendered = (<br>            json.dumps(<br>                report,<br>                indent=2<br>            )<br>            + &quot;\n&quot;<br>        )<br>        if args.out:<br>            args.out.write_text(<br>                rendered,<br>                encoding=&quot;utf-8&quot;<br>            )<br>        print(<br>            rendered,<br>            end=&quot;&quot;<br>        )<br>        return (<br>            2<br>            if report[&quot;rejected_events&quot;]<br>            else 0<br>        )<br>    except (<br>        OSError,<br>        ValueError<br>    ) as error:<br>        print(<br>            &quot;error: &quot; + str(error),<br>            file=sys.stderr<br>        )<br>        return 2<br><br>if __name__ == &quot;__main__&quot;:<br>    sys.exit(main())</pre><p>The detector normalizes access masks and timestamps, validates process GUIDs, and evaluates the complete input before correlation.</p><p>Invalid supported events are reported instead of silently disappearing.</p><p>Exit code 0 means evaluation completed without rejected events.</p><p>It does <strong>not</strong> mean an alert fired.</p><p>Exit code 2 indicates invalid JSON, empty input, or rejected supported events.</p><p>Check:</p><pre>alert_count<br>rejected_events</pre><h3>Generate Synthetic Events</h3><p>Save as:</p><pre>make_fixtures.py</pre><pre>#!/usr/bin/env python3<br>&quot;&quot;&quot;Generate invented Sysmon-shaped events. No host access or credentials.&quot;&quot;&quot;<br>from datetime import datetime, timedelta, timezone<br>import json<br>from pathlib import Path<br>from uuid import UUID<br>from detect import PROVIDER, CHANNEL<br><br>BASE = datetime(<br>    2026,<br>    10,<br>    12,<br>    12,<br>    0,<br>    tzinfo=timezone.utc<br>)<br>SOURCE = (<br>    r&quot;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&quot;<br>)<br>LSASS = r&quot;C:\Windows\System32\lsass.exe&quot;<br><br>def event(<br>    event_id,<br>    record,<br>    guid=1,<br>    second=0,<br>    host=&quot;LAB-WIN01&quot;,<br>    **fields<br>):<br>    row = {<br>        &quot;Provider&quot;: PROVIDER,<br>        &quot;Channel&quot;: CHANNEL,<br>        &quot;EventID&quot;: event_id,<br>        &quot;EventRecordID&quot;: record,<br>        &quot;Computer&quot;: host,<br>        &quot;UtcTime&quot;:<br>            (<br>                BASE +<br>                timedelta(seconds=second)<br>            ).strftime(<br>                &quot;%Y-%m-%d %H:%M:%S.%f&quot;<br>            ),<br>        &quot;Synthetic&quot;: True<br>    }<br>    if event_id == 10:<br>        row.update(<br>            SourceProcessGUID=<br>                &quot;{&quot; +<br>                str(UUID(int=guid)) +<br>                &quot;}&quot;,<br>            SourceImage=SOURCE,<br>            TargetImage=LSASS,<br>            GrantedAccess=&quot;0x1010&quot;<br>        )<br>    elif event_id == 11:<br>        row.update(<br>            ProcessGuid=<br>                &quot;{&quot; +<br>                str(UUID(int=guid)) +<br>                &quot;}&quot;,<br>            Image=SOURCE,<br>            TargetFilename=<br>                r&quot;C:\Lab\simulation-marker.dmp&quot;<br>        )<br>    row.update(fields)<br>    return row<br><br>def fixtures():<br>    return [<br>        event(<br>            10,<br>            1<br>        ),<br>        event(<br>            11,<br>            2,<br>            second=2<br>        ),<br>        event(<br>            10,<br>            3,<br>            guid=2,<br>            GrantedAccess=&quot;0x1000&quot;<br>        ),<br>        event(<br>            10,<br>            4,<br>            guid=3,<br>            TargetImage=<br>                r&quot;C:\Windows\notepad.exe&quot;<br>        ),<br>        event(<br>            11,<br>            5,<br>            guid=4<br>        ),<br>        event(<br>            10,<br>            6,<br>            guid=5,<br>            second=10<br>        ),<br>        event(<br>            10,<br>            7,<br>            guid=6,<br>            second=20<br>        ),<br>        event(<br>            11,<br>            8,<br>            guid=6,<br>            second=21,<br>            host=&quot;LAB-WIN02&quot;<br>        ),<br>        event(<br>            10,<br>            9,<br>            guid=7,<br>            second=30,<br>            GrantedAccess=&quot;0x10&quot;<br>        )<br>    ]<br><br>if __name__ == &quot;__main__&quot;:<br>    path = Path(__file__).with_name(<br>        &quot;synthetic-events.jsonl&quot;<br>    )<br>    path.write_text(<br>        &quot;&quot;.join(<br>            json.dumps(row) + &quot;\n&quot;<br>            for row in fixtures()<br>        ),<br>        encoding=&quot;utf-8&quot;<br>    )<br>    print(<br>        &quot;Wrote 9 synthetic events to &quot;<br>        + str(path)<br>    )</pre><p>Run:</p><pre>python3 make_fixtures.py<br>python3 detect.py synthetic-events.jsonl --out replay-report.json</pre><p><strong>On Windows:</strong></p><pre>py -3 .\make_fixtures.py<br>py -3 .\detect.py .\synthetic-events.jsonl --out .\replay-report.json</pre><p><strong>Expected summary:</strong></p><pre>{<br>  &quot;mode&quot;: &quot;lsass&quot;,<br>  &quot;input_events&quot;: 9,<br>  &quot;ignored_events&quot;: 0,<br>  &quot;duplicate_events&quot;: 0,<br>  &quot;rejected_events&quot;: [],<br>  &quot;alert_count&quot;: 4,<br>  &quot;alerts_with_companion&quot;: 1<br>}</pre><p>The fixture deliberately contains:</p><ul><li>Query-only access</li><li>An unrelated target</li><li>File creation without process access</li><li>Access without a file</li><li>A file on the wrong host</li><li>A mask outside the Sigma list</li></ul><p><strong>The expected access findings have:</strong></p><pre>event_record_id:<br>1<br>6<br>7<br>9</pre><p>Only finding 1 has a matching file companion.</p><p>Replay validates the implemented logic.</p><p>It does <strong>not</strong> prove that Sysmon, a forwarding agent, or your SIEM collected an event.</p><h3>Analyze Live Windows Events</h3><p>Save the following as:</p><pre>Export-SysmonEvents.ps1</pre><pre>#requires -Version 5.1<br>[CmdletBinding()]<br>param(<br>    [ValidateRange(1, 1440)]<br>    [int]$Minutes = 10,<br>    [string]$OutFile = (<br>        Join-Path $PWD &#39;live-events.jsonl&#39;<br>    )<br>)<br>Set-StrictMode -Version Latest<br>$ErrorActionPreference = &#39;Stop&#39;<br>$logName =<br>    &#39;Microsoft-Windows-Sysmon/Operational&#39;<br>Get-WinEvent `<br>    -ListLog $logName `<br>    -ErrorAction Stop |<br>    Out-Null<br>try {<br>    $events = @(<br>        Get-WinEvent `<br>            -FilterHashtable @{<br>                LogName = $logName<br>                Id = 1, 10, 11<br>                StartTime =<br>                    (Get-Date).AddMinutes(-$Minutes)<br>            } `<br>            -ErrorAction Stop |<br>        Sort-Object TimeCreated, RecordId<br>    )<br>}<br>catch {<br>    if (<br>        $_.FullyQualifiedErrorId `<br>        -like &#39;NoMatchingEventsFound*&#39;<br>    ) {<br>        throw `<br>            &#39;No matching events. Check the time window, Sysmon filters, and simulation result.&#39;<br>    }<br>    throw<br>}<br>$destination =<br>    $ExecutionContext.SessionState.Path<br>    .GetUnresolvedProviderPathFromPSPath(<br>        $OutFile<br>    )<br>$writer =<br>    [IO.StreamWriter]::new(<br>        $destination,<br>        $false,<br>        [Text.UTF8Encoding]::new($false)<br>    )<br>try {<br>    foreach ($event in $events) {<br>        [xml]$xml =<br>            $event.ToXml()<br>        $row = [ordered]@{<br>            Provider =<br>                [string]<br>                $xml.Event.System.Provider.Name<br>            Channel =<br>                [string]<br>                $xml.Event.System.Channel<br>            EventID =<br>                [int]<br>                $event.Id<br>            EventRecordID =<br>                [long]<br>                $event.RecordId<br>            Computer =<br>                [string]<br>                $xml.Event.System.Computer<br>            TimeCreated =<br>                $event.TimeCreated<br>                .ToUniversalTime()<br>                .ToString(&#39;o&#39;)<br>        }<br>        foreach (<br>            $item<br>            in $xml.Event.EventData.Data<br>        ) {<br>            $row[<br>                [string]$item.Name<br>            ] =<br>                [string]$item.&#39;#text&#39;<br>        }<br>        $writer.WriteLine(<br>            (<br>                $row |<br>                ConvertTo-Json `<br>                    -Compress `<br>                    -Depth 4<br>            )<br>        )<br>    }<br>}<br>finally {<br>    $writer.Dispose()<br>}<br>Write-Host `<br>    &quot;Exported $($events.Count) events to $destination&quot;</pre><p><strong>After the surrogate run:</strong></p><pre>.\Export-SysmonEvents.ps1 `<br>    -Minutes 10 `<br>    -OutFile .\live-events.jsonl</pre><p><strong>Then:</strong></p><pre>py -3 .\detect.py `<br>    .\live-events.jsonl `<br>    --mode surrogate `<br>    --out .\live-report.json</pre><p>The detector’s surrogate mode labels findings:</p><pre>LAB_PROCESS_ACCESS_VM_READ</pre><p>This keeps simulation findings separate from actual LSASS findings.</p><p>For a successful LsassHandle run:</p><pre>.\Export-SysmonEvents.ps1 `<br>    -Minutes 10 `<br>    -OutFile .\lsass-events.jsonl</pre><p><strong>Then:</strong></p><pre>py -3 .\detect.py `<br>    .\lsass-events.jsonl `<br>    --mode lsass `<br>    --out .\lsass-report.json</pre><p>Other activity in the time window can generate additional findings.</p><p>Always match the run metadata before attributing an alert to your simulation.</p><h3>Sigma Detection</h3><p>Save as:</p><pre>lsass_access.yml</pre><pre>title: LSASS Access With Selected Memory Read Capable Masks<br>id: 8d7c4f91-2a62-4d79-a4bc-1a8b9e6f1032<br>status: experimental<br>description: &gt;-<br>  Detects a selected, non-exhaustive set of Sysmon ProcessAccess masks<br>  containing PROCESS_VM_READ when the target image ends in lsass.exe.<br>  Handle access alone does not establish a memory read or credential theft.<br>references:<br>  - https://attack.mitre.org/techniques/T1003/001/<br>  - https://learn.microsoft.com/en-us/windows/win32/procthread/process-security-and-access-rights<br>author: Detection Engineering<br>date: 2026-10-12<br>tags:<br>  - attack.credential-access<br>  - attack.t1003.001<br>logsource:<br>  product: windows<br>  category: process_access<br>detection:<br>  selection:<br>    TargetImage|endswith: &#39;\lsass.exe&#39;<br>    GrantedAccess:<br>      - &#39;0x1010&#39;<br>      - &#39;0x1410&#39;<br>      - &#39;0x1438&#39;<br>      - &#39;0x143a&#39;<br>      - &#39;0x1f0fff&#39;<br>      - &#39;0x1fffff&#39;<br>  condition: selection<br>fields:<br>  - Computer<br>  - SourceImage<br>  - SourceProcessGUID<br>  - TargetImage<br>  - GrantedAccess<br>falsepositives:<br>  - Approved endpoint security and diagnostic tools<br>  - Authorized incident response activity<br>level: medium</pre><p>These values all contain the memory-read bit, but the list is deliberately finite.</p><p>The native Python analytic is broader.</p><p>For example:</p><pre>0x10</pre><p>matches the Python analytic but is outside the Sigma list.</p><p>On the supplied fixture:</p><ul><li>Native Python analytic: <strong>4 access alerts</strong></li><li>Sigma selection: <strong>3 alerts</strong></li></ul><p>after correct field mapping and normalization.</p><p>Sigma describes the detection.</p><p><strong>Ensure that:</strong></p><pre>process_access</pre><p>maps to Sysmon Event 10 and that values such as decimal:</p><pre>4112</pre><p>are normalized appropriately before comparison with:</p><pre>0x1010</pre><p>The Sigma rule does not contain the Python file correlation.</p><p><strong>Start at:</strong></p><pre>Medium</pre><p>and prioritize using:</p><ul><li>Source lineage</li><li>Host role</li><li>Identity</li><li>Corroborating evidence</li></ul><h3>Regression Testing</h3><p>A positive detection is only part of the test.</p><p>The regression suite validates:</p><ul><li>Unrelated hosts do not join</li><li>Unrelated process GUIDs do not join</li><li>Query-only access does not satisfy the analytic</li><li>Boundary timestamps behave correctly</li><li>Malformed records are rejected</li><li>Numeric access-mask representations normalize correctly</li><li>Duplicate events are handled</li><li>CLI behavior works correctly</li></ul><p><strong>Save the test suite as:</strong></p><pre>test_detect.py</pre><p>Run:</p><pre>python3 -m unittest -v test_detect.py</pre><p>Expected result:</p><pre>Ran 22 tests in &lt;elapsed time&gt;</pre><pre>OK</pre><p>The elapsed time varies.</p><p>The synthetic replay and all 22 tests passed using Python 3.9.6 in the supplied test evidence.</p><p>The Windows scripts, real Sysmon event generation, and SIEM alert delivery still require live validation on the lab VM.</p><h3>Simulator blocked</h3><p>Inspect:</p><ul><li>Application control</li><li>Process permissions</li><li>Prevention telemetry</li></ul><p>Keep the protection enabled.</p><h3>Probe succeeds but Event 10 is missing</h3><p>Inspect:</p><ul><li>Active Sysmon filters</li><li>Source</li><li>Target</li><li>Observed access mask</li><li>Event latency</li></ul><h3>Local event exists but SIEM event is missing</h3><p>Inspect:</p><ul><li>Channel subscription</li><li>Forwarding agent</li><li>Ingestion route</li></ul><h3>SIEM event exists but no alert</h3><p>Inspect:</p><ul><li>Field names</li><li>Data types</li><li>Normalization</li><li>Sigma conversion</li><li>Access-mask coverage</li></ul><h3>Access alert has no file companion</h3><p><strong>Check:</strong></p><ul><li>Source GUID</li><li>Computer</li><li>Event ordering</li><li>120-second window</li><li>Filename filter</li><li>Whether the marker was actually created</li></ul><p><strong>Preserve:</strong></p><pre>run.json<br>event export<br>detection report</pre><h3>Extend Detection Beyond LSASS</h3><p>Credential access has several distinct surfaces.</p><p>Local account hashes in the SAM map to:</p><pre>T1003.002</pre><p>The Active Directory database maps to:</p><pre>T1003.003</pre><p>Monitor suspicious access and backup-related operations around those stores using telemetry capable of observing the relevant operation.</p><p>Browser credential stores require separate visibility.</p><p>Unexpected access by an unrelated process is worth investigating, but file access alone does not prove successful decryption.</p><p>Browser credential access maps to:</p><pre>T1555.003</pre><h3>DCSync Requires Directory Replication Visibility</h3><p><strong>T1003.006: DCSync</strong> abuses directory replication to obtain credential information.</p><p>It does not require a local LSASS dump on the Domain Controller.</p><p>For a Windows Security event approach, configure:</p><p><strong>Audit Directory Service Access</strong></p><p>and an appropriate SACL on the relevant directory object, such as the domain naming-context root for replication rights.</p><p>Without the matching audit configuration, absence of Event 4662 says little about whether replication occurred.</p><p>Within Event 4662:</p><pre>AccessMask = 0x100</pre><p>identifies a control-access operation.</p><p>Evaluate the Properties field for the relevant rights.</p><p>The replication rights are:</p><h3>DS-Replication-Get-Changes</h3><pre>1131f6aa-9c07-11d1-f79f-00c04fc2dcd2</pre><h3>DS-Replication-Get-Changes-All</h3><pre>1131f6ad-9c07-11d1-f79f-00c04fc2dcd2</pre><h3>DS-Replication-Get-Changes-In-Filtered-Set</h3><pre>89e95b76-444d-4c62-991a-0facbeda640c</pre><p>Microsoft defines these separately.</p><p>Do not require all three to appear in one event.</p><p>Investigate replication-related access by principals outside the validated set of:</p><ul><li>Domain Controllers</li><li>Authorized replication services</li></ul><p>And remember:</p><blockquote><em>An account ending in </em><em>$ is not automatically legitimate.</em></blockquote><p><strong>Event 4662</strong> does not directly provide the requesting workstation’s IP address.</p><p><strong>Correlate:</strong></p><pre>4662 SubjectLogonId<br>        ↓<br>4624 TargetLogonId</pre><p>on the same Domain Controller within the applicable logon session.</p><p>Then enrich with network or identity telemetry.</p><p>Treat unavailable source information as an investigation gap.</p><h3>Kerberoasting Requires Service-Ticket Context</h3><p><strong>T1558.003 — Kerberoasting</strong> involves obtaining service-ticket material and attempting offline password recovery.</p><p>A ticket request alone does not demonstrate that a password was recovered.</p><p>On Domain Controllers, collect successful:</p><pre>Event 4769</pre><p><strong>through:</strong></p><p><strong>Audit Kerberos Service Ticket Operations</strong></p><p>Useful fields include:</p><pre>TargetUserName<br>ServiceName<br>IpAddress<br>Status<br>TicketEncryptionType</pre><p>A successful request has:</p><pre>Status = 0x0</pre><p>Ticket encryption types:</p><pre>0x17 = RC4-HMAC<br>0x11 = AES128<br>0x12 = AES256</pre><p>RC4 can be useful in context.</p><p>But:</p><blockquote><strong><em>RC4 does not equal Kerberoasting.</em></strong></blockquote><p>Restricting detection to RC4 also creates gaps.</p><p>Investigate:</p><ul><li>Changes in the requesting identity’s normal service set</li><li>Request rate</li><li>Source host</li><li>Sensitive service accounts</li></ul><p>Avoid relying on a universal ticket-count threshold.</p><h3>Turn an Access Alert Into a Response Decision</h3><p>Start with the process.</p><p>Resolve Event 10’s source GUID to its creation event.</p><p>Inspect:</p><ul><li>Command line</li><li>Parent process</li><li>User</li><li>Executable path</li><li>Hash</li><li>EDR signer information</li></ul><p>Then determine whether the activity belongs to a documented:</p><ul><li>Diagnostic operation</li><li>Security product</li><li>Incident-response activity</li><li>Administrative workflow</li></ul><p>Then follow the identity.</p><p><strong>Windows:</strong></p><pre>4624 = Successful logon<br>4648 = Explicit credential use</pre><p><strong>For Event 4624:</strong></p><pre>Type 3 = Network logon<br>Type 10 = Remote interactive logon</pre><p>Neither event is inherently malicious.</p><p><strong>Look for:</strong></p><ul><li>New destinations</li><li>Unusual administrative sessions</li><li>Privileged authentication</li><li>Access to backup management</li><li>Unexpected server access</li></ul><p>Use stable account identifiers where available and the correct host scope for logon IDs.</p><p>A matching username and close timestamps are useful leads.</p><p>They are not proof that two events share a cause.</p><p>If the evidence supports compromise:</p><ol><li>Contain affected endpoints.</li><li>Preserve evidence.</li><li>Address exposed credentials and sessions.</li><li>Protect recovery infrastructure.</li><li>Scope credential changes to identities and systems actually at risk.</li></ol><h3>Reduce Future Credential Exposure</h3><p>Detection is only one side of the problem.</p><p>Reduce the attack surface with:</p><ul><li>Credential Guard</li><li>LSA protection</li><li>Privileged Access Workstations</li><li>Restricted administrative logons</li><li>Unique managed local administrator credentials</li><li>Reviewed directory replication rights</li><li>Separate backup administration</li><li>Strong authentication for privileged access</li></ul><p>Credential Guard uses virtualization-based isolation to protect selected secrets.</p><p>LSA protection restricts access to the authentication process.</p><p>They address different parts of the problem.</p><p>Use them together with strong identity architecture and privileged-access controls.</p><h3>The Real Outcome</h3><p>The most valuable result from this exercise is not simply:</p><blockquote><em>“The Sigma rule fired.”</em></blockquote><p>The useful outcome is a defensible chain of evidence:</p><pre>Behavior occurred<br>       ↓<br>Sensor recorded it<br>       ↓<br>Pipeline preserved it<br>       ↓<br>Analytic matched it<br>       ↓<br>Alert contained context<br>       ↓<br>Analyst investigated it<br>       ↓<br>Response decision was possible</pre><p>That is when a credential-access rule starts contributing to ransomware resilience.</p><p>Ransomware may end with encryption, but the path to that encryption often runs through identity.</p><p>A single compromised workstation is one problem.</p><p>A compromised identity with access to servers, Active Directory, and backup infrastructure is a very different problem.</p><p>Detect the credential-access stage early, correlate it with identity activity, and investigate before the attacker reaches the recovery and impact stages.</p><p><strong>The goal isn’t simply to detect ransomware.</strong></p><p><strong>The goal is to detect the conditions that allow ransomware to spread.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a1ea0e4142a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Killing Recovery Before Encryption: How Ransomware Removes Your Safety Net]]></title>
            <link>https://medium.com/@ddigvijay/killing-recovery-before-encryption-how-ransomware-removes-your-safety-net-9855a180bcb3?source=rss-bd4bfddba65------2</link>
            <guid isPermaLink="false">https://medium.com/p/9855a180bcb3</guid>
            <category><![CDATA[rasnsom]]></category>
            <category><![CDATA[data-backup]]></category>
            <category><![CDATA[threat-detection]]></category>
            <category><![CDATA[windows-security]]></category>
            <dc:creator><![CDATA[Digvijay]]></dc:creator>
            <pubDate>Thu, 08 Oct 2026 15:52:40 GMT</pubDate>
            <atom:updated>2026-10-08T15:52:40.806Z</atom:updated>
            <content:encoded><![CDATA[<p>Ransomware is not only about locking files.</p><p>It is about making sure you cannot unlock them yourself.</p><p>Before many modern ransomware crews encrypt anything, they try to destroy or impair recovery Volume Shadow Copies, local restore points, backup agents, and sometimes the backup infrastructure itself. If that step succeeds, the encryption that follows is far more painful because restore is already broken.</p><p>This is one of the highest-signal moments in the ransomware kill chain. It is also one of the easiest stages for defenders to miss if they are only watching for mass file changes.</p><h3>Where this sits in ATT&amp;CK</h3><p>In MITRE ATT&amp;CK terms, this is primarily:</p><ul><li><strong>TA0040 Impact</strong></li><li><strong>T1490 Inhibit System Recovery</strong></li></ul><p>Related behaviors you often see nearby:</p><ul><li><strong>T1489 Service Stop</strong>: killing backup or security services before impact</li><li><strong>T1562 Impair Defenses: </strong>weakening EDR / AV so the rest of the chain is quieter</li><li><strong>T1070 Indicator Removal: </strong>clearing evidence after the sabotage</li></ul><p>If your detections only cover T1486 (Data Encrypted for Impact), you are late to the fight.</p><h3>What “killing recovery” looks like on Windows</h3><p>On Windows endpoints and servers, the classic target is Volume Shadow Copy Service (VSS).</p><p>Shadow copies are point-in-time snapshots. Many restore workflows, backup products, and even casual “Previous Versions” recovery depend on them. Ransomware operators know that. So they try to:</p><ol><li>Enumerate whether shadow copies / backup tooling exist</li><li>Delete shadow copies or resize the storage pool to zero</li><li>Stop or kill backup-related services and processes</li><li>Impair boot or recovery configuration when they have enough privilege</li></ol><p>You do not need every variant. You need to recognize the <em>intent</em>: remove rollback options before impact.</p><h3>Technical signals defenders should care about</h3><p>Focus on process, command-line, and service telemetry not malware names.</p><h4>1) Suspicious VSS / shadow-copy management activity</h4><p>Watch for processes commonly abused around shadow-copy manipulation, especially when launched by unusual parents or non-admin workflows:</p><ul><li>vssadmin.exe</li><li>wmic.exe with shadow-copy related operations</li><li>powershell.exe / pwsh.exe calling VSS / Win32_ShadowCopy style APIs or CIM/WMI classes</li><li>diskshadow.exe</li><li>wbadmin.exe in unexpected contexts</li></ul><p>High-signal patterns (conceptual, for detection engineering):</p><ul><li>shadow copy delete / resize style operations</li><li>commands that effectively set shadow storage to unbounded zero style outcomes</li><li>VSS tooling spawned by Office, browsers, user-written scripts, or unknown binaries</li><li>the same host also showing backup-agent kills within minutes</li></ul><p>This is not “alert on every vssadmin forever.” Backup admins and some patch/backup jobs use these tools. The win is rarity + parent process + user context + proximity to other ransomware stages.</p><h4>2) Backup discovery before destruction</h4><p>Many intrusions do a quiet look-around first:</p><ul><li>service enumeration for backup products (Veeam, Acronis, Symantec, Windows Backup, etc.)</li><li>process listing for backup agents</li><li>share / repository discovery that smells like backup storage</li></ul><p>In <strong>ATT&amp;CK language</strong> this often overlaps <strong>T1518</strong> Software Discovery and broader discovery. If you see backup discovery and then service stops on the same asset cluster, treat that as a pre-encryption cluster not isolated noise.</p><h4>3) Service stop / process kill against recovery stack</h4><p>Before encryption, operators frequently try to stop:</p><ul><li>backup agents</li><li>volume shadow related services</li><li>sometimes security products that would block mass file ops</li></ul><p><strong>Useful telemetry:</strong></p><ul><li>Service Control Manager events for unexpected stops</li><li>EDR process-kill / process-tampering events targeting backup binaries</li><li>sudden service state changes outside change windows</li></ul><p><strong>Correlate:</strong> backup discovery → service stop → shadow-copy wipe → mass file writes. That sequence is the story.</p><h4>4) Useful Windows event angles</h4><p>Exact IDs vary by logging stack, but detection programs commonly instrument around:</p><ul><li>process creation with command-line auditing (Sysmon Event ID 1 / Windows 4688)</li><li>service stop / modify events</li><li>VSS / backup operational logs where enabled</li><li>EDR equivalents of “<strong>sensitive tool executed</strong>” and “<strong>recovery artifact deleted</strong>”</li></ul><p>If command-line auditing is off, you will miss most of this stage. Turn it on in the lab first, then production with a tuning plan.</p><h3>A detection logic sketch (blue-team oriented)</h3><p>Think in rules of increasing severity:</p><p><strong>Tier 1</strong>: Suspicious recovery tool use<br>Trusted recovery/admin binary + rare user/host + unusual parent.</p><p><strong>Tier 2</strong>: Destructive recovery intent<br>Same as Tier 1, but command-line semantics indicate delete / resize-to-useless / shadow purge style intent.</p><p><strong>Tier 3</strong> : Pre-ransomware cluster<br>Tier 2 plus any of:</p><ul><li>backup service stop within N minutes</li><li>security tool impairment nearby</li><li>broad file share discovery</li><li>sudden credential dumping alerts on the same identity</li></ul><p>Tier 3 should page someone. Tier 1 can go to a queue. Do not wait for encryption alerts to confirm.</p><h3>Why this stage is a gift to defenders</h3><p>Mass encryption can look like a storage storm. It is noisy, late, and expensive to investigate under pressure.</p><p>Recovery sabotage is often:</p><ul><li>lower volume</li><li>higher intent</li><li>earlier in the chain</li><li>easier to express as a crisp detection</li></ul><p>If you catch <strong>T1490</strong> cleanly, you may still have backups, still have time, and still have options.</p><h3>Readiness checks you can run safely</h3><p>In an authorized lab / purple-team environment (not production guesswork), validate:</p><ol><li><strong>Telemetry exists:</strong> do you even see vssadmin / WMI shadow operations with full command lines?</li><li><strong>Alert quality:</strong> does destructive shadow-copy behavior page, or drown in noise?</li><li><strong>Backup monitoring:</strong> do backup consoles alert when agents die or repositories look wrong?</li><li><strong>Response path:</strong> if Tier 3 fires, does IR know to isolate, preserve remaining recovery points, and check backup infrastructure immediately?</li><li><strong>Restore proof:</strong> independent of detections, can you restore a critical system from an offline / immutable copy when local shadows are gone?</li></ol><p>That last one matters. Detections reduce risk. Immutable recovery removes the attacker’s favorite leverage.</p><h3>Common program gaps</h3><p>Most teams under-invest here for predictable reasons:</p><ul><li>“Only admins use those tools” until an attacker becomes an admin</li><li>backup alerts live in a different console nobody in SOC watches</li><li>VSS deletions are tested never, or only as a footnote in an annual tabletop</li><li>detections are signature-based and miss living-off-the-land recovery sabotage</li></ul><p>If ransomware readiness reviews only ask “would encryption be blocked?”, rewrite the question:</p><p>“<em>Would we notice recovery being murdered and could we still restore anyway?”</em></p><h3>Takeaway</h3><p>Ransomware wins twice when it encrypts your files and deletes your way back.</p><p>Volume Shadow Copies, backup agents, and restore infrastructure are not side characters. They are primary targets.</p><p>Detect Inhibit System Recovery like it is the main event because for the attacker, it often is.</p><p>If encryption is the ransom note’s soundtrack, recovery sabotage is the moment they lock the doors. Hear that moment early.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9855a180bcb3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Living Off the Land: How Ransomware Hides Inside Tools You Already Trust]]></title>
            <link>https://medium.com/@ddigvijay/living-off-the-land-how-ransomware-hides-inside-tools-you-already-trust-da986297e2f7?source=rss-bd4bfddba65------2</link>
            <guid isPermaLink="false">https://medium.com/p/da986297e2f7</guid>
            <dc:creator><![CDATA[Digvijay]]></dc:creator>
            <pubDate>Wed, 07 Oct 2026 05:17:01 GMT</pubDate>
            <atom:updated>2026-10-07T05:17:01.945Z</atom:updated>
            <content:encoded><![CDATA[<p>Most people expect ransomware to look like malware.</p><p>Strange process names. Unknown binaries. Something that screams “this should not be here.”</p><p>In a lot of real incidents, that is not what shows up first.</p><p>What shows up first looks familiar: PowerShell. cmd.exe. rundll32. msiexec. certutil. Scheduled tasks. Remote admin tools. Binaries signed by Microsoft, sitting in System32, used every day by IT teams.</p><p>That is living off the land. Attackers use the operating system’s own trusted tools to execute, download, move, and blend in. The goal is simple: make malicious activity look like normal administration.</p><h3>Why this works so well</h3><p>Security tools and analysts are trained to distrust unknown files.</p><p>Living-off-the-land activity flips that assumption. The binary is known. The publisher is trusted. The path looks legitimate. The parent process may even look like something an admin would launch.</p><p>So the question stops being “is this malware?” and becomes “is this <em>behavior</em> normal for this user, this host, and this moment?”</p><p>That is a much harder question. And ransomware operators know it.</p><h3>What “living off the land” actually means</h3><p>It does not mean there is no malware anywhere in the chain.</p><p>It means large parts of the intrusion are carried by tools that already exist on the machine:</p><ul><li>scripting hosts that can run commands and pull payloads</li><li>installers and system utilities that can execute code</li><li>admin tools that can reach other systems</li><li>built-in transfer utilities that can fetch or stage files</li></ul><p>From a defender’s seat, the host may look “clean” of exotic binaries while still being fully under attacker control.</p><h3>Why ransomware loves this stage</h3><p>Before encryption, operators need quiet room to work.</p><p>They need to run commands without lighting up every alert. They need to stage tools. They need to move laterally. They need to look boring.</p><p>Trusted Windows utilities help with all of that. If your detections only hunt for ransomware families by name or hash, this stage can pass right through.</p><p>By the time mass encryption starts, the living-off-the-land work is often already done.</p><h3>The defender shift that matters</h3><p>Stop asking only:</p><p>“Did we see a known bad file?”</p><p>Start asking:</p><p>“Did we see a trusted tool doing something it should not be doing?”</p><p>Examples of the right kind of questions:</p><ul><li>Why is this signed system binary launching unusual child processes?</li><li>Why is an admin utility running under a user who never does admin work?</li><li>Why is a transfer tool pulling content to a weird path at 2 a.m.?</li><li>Why does this “routine” script suddenly appear on servers that never see that activity?</li></ul><p>Context beats reputation.</p><h3>What good detection looks like here</h3><p>You do not need a giant list of every possible abuse case on day one.</p><p>You need coverage around patterns:</p><p>Unusual process relationships. Trusted tools launching unexpected children, or being launched by unexpected parents.</p><p>Rare use of admin utilities. Tools that exist everywhere but are used by almost nobody in your environment — until they suddenly appear.</p><p>Scripting in the wrong place. PowerShell or command shells on endpoints and servers where that activity is uncommon, especially outside change windows.</p><p>Dual-use transfer behavior. Built-in download or copy utilities touching suspicious destinations, temporary folders, or newly created working directories.</p><p>Identity context. The same command from a domain admin during a maintenance window is not the same as the same command from a helpdesk account on a finance laptop.</p><p>Behavioral baselines beat static denylists.</p><h3>A practical readiness test</h3><p>If you want to know whether you are actually ready for this stage, do not only ask whether antivirus catches a ransomware sample.</p><p>Ask:</p><p><em>If an attacker used only common administrative tools on a test host in a controlled lab, would anyone notice?</em></p><p><em>Would an alert fire?<br>Would it be high enough signal to investigate?<br>Would the analyst understand why it mattered?<br>Could you interrupt the chain before credentials, backups, or data were next?</em></p><p>If the answer is “probably not,” your ransomware problem is not only encryption. It is visibility into trusted activity.</p><h3>The trap teams fall into</h3><p>Teams often tune out living-off-the-land noise because it looks like IT work.</p><p>That is understandable. Admin tools create alerts. False positives are painful. People get alert fatigue.</p><p>But if you suppress everything that looks administrative, you also suppress one of the most common ransomware execution patterns on Windows.</p><p><em>The fix is not “alert on every PowerShell command.”<br>The fix is better context: who, where, when, parent/child, rarity, and blast radius.</em></p><h3>Takeaway</h3><p>Ransomware does not always arrive wearing a villain costume.</p><p>Sometimes it arrives wearing your own IT department’s tools.</p><p>If your detections only recognize strangers, they will miss the attacker who already has a key to the building.</p><p>Defend the behavior. Not just the binary.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da986297e2f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encryption Is the Last 5 Minutes: Why Most Ransomware Defenses Fail Too Late]]></title>
            <link>https://medium.com/@ddigvijay/encryption-is-the-last-5-minutes-why-most-ransomware-defenses-fail-too-late-76cd5bf92426?source=rss-bd4bfddba65------2</link>
            <guid isPermaLink="false">https://medium.com/p/76cd5bf92426</guid>
            <dc:creator><![CDATA[Digvijay]]></dc:creator>
            <pubDate>Wed, 07 Oct 2026 05:06:24 GMT</pubDate>
            <atom:updated>2026-10-07T05:11:52.169Z</atom:updated>
            <content:encoded><![CDATA[<p>When people hear “ransomware,” they picture locked files and a ransom note on the screen.</p><p>That’s the ending.</p><p>In real attacks, encryption is often the last few minutes of a campaign that may have been running for hours or days. By the time folders fill with strange extensions and ransom notes, the attacker has usually already gotten a foothold, learned your environment, stolen credentials, weakened backups and security tools, and staged or stolen sensitive data.</p><p>If your defenses only light up when files start changing , you are defending the credits not the movie.</p><h3>The modern ransomware story</h3><p>Think of ransomware less as a single piece of malware and more as a process:</p><p>First, the attacker gets access phishing, exposed remote services, stolen VPN or RDP credentials, or a commodity loader dropped by something that looked routine.</p><p>Next, they execute in ways that look normal. Signed Windows tools. Scripts. Admin utilities. Activity that blends into day-to-day IT work.</p><p>Then they stay and escalate. Persistence. Privilege. Credential theft. Enough access to move through the environment without setting off every alarm.</p><p>After that, they learn the terrain network shares, backup systems, domain structure, and high-value machines.</p><p>Then they remove your safety net. Security tools get impaired. Recovery points disappear. Logs get cleaned. Options shrink.</p><p>Often they steal before they lock. That is double extortion: your data leaves the building before encryption begins, so even a decryptor does not remove the leak threat.</p><p>Only then comes impact — encryption, ransom notes, and sometimes a wider blast across shares and servers.</p><p>Encryption is the finale. Everything before it is where detection and response still have a chance to win.</p><h3>Why “we have EDR” is not the same as “we’re ready”</h3><p>EDR and antivirus matter. They are not a ransomware strategy by themselves.</p><p>Modern campaigns often abuse trusted binaries so process trees look administrative. They move laterally with valid credentials instead of exotic zero-days. They sabotage backups so restore fails even if you rebuild. They exfiltrate before encryption so paying does not end the pressure.</p><p>So the useful question is not only, “Would our tool catch ransomware.exe?”</p><p>It is, “Would we notice the chain and could we stop it before impact?”</p><h3>Detect the chain, not the brand</h3><p>Chasing every ransomware name is a trap. Names change. Behaviors repeat.</p><p>For defenders, map alerts to stages:</p><p>Execution that looks like admin work. Credential access that should not be happening. Broad discovery of shares, backups, and domain structure. Defense evasion that weakens security tools or recovery. Unusual outbound staging that looks like theft. And finally, mass file impact and ransom notes.</p><p>You do not need every technique covered on day one. You need coverage across the path.</p><h3>The uncomfortable truth about the encryption alert</h3><p>Mass file encryption is a strong signal. It is also often a failure signal.</p><p>By then, backups may already be gone. Data may already be stolen. Domain admin may already be theirs. The note is a formality.</p><p>That is the point of this series: ransomware readiness is not the ability to recognize a ransom note. It is the ability to interrupt the kill chain early enough that encryption never becomes the story.</p><h3>What good looks like</h3><p>Strong programs usually do three things.</p><p>They rehearse assume-breach scenarios in a controlled way and check that detections fire on ransomware-like behaviors, not only on known malware hashes.</p><p>They measure time-to-detect by stage how long from the first odd admin behavior to a human looking at a ticket.</p><p>They treat recovery as a first-class asset: offline or immutable backups, monitored backup consoles, and alerts when recovery is being sabotaged.</p><p>If you only test whether antivirus quarantines a sample, you are testing a slice. Real operators test the whole story.</p><h3>Takeaway</h3><p>Don’t organize your ransomware defense around the ransom note.</p><p>Organize it around the minutes and days before the note.</p><p>Encryption is loud. The real fight is quieter and earlier.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76cd5bf92426" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[URLhaus Integration: Detect, Enrich and Automatically Block Malicious URLs]]></title>
            <link>https://medium.com/@ddigvijay/updated-wazuh-urlhaus-integration-detect-enrich-and-automatically-block-malicious-urls-6291078b452f?source=rss-bd4bfddba65------2</link>
            <guid isPermaLink="false">https://medium.com/p/6291078b452f</guid>
            <dc:creator><![CDATA[Digvijay]]></dc:creator>
            <pubDate>Wed, 23 Sep 2026 22:39:17 GMT</pubDate>
            <atom:updated>2026-09-23T22:39:38.815Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern security operations are no longer only about detecting malicious activity.</p><p>The real challenge starts after detection.</p><p>When an endpoint communicates with a suspicious URL or malicious infrastructure, security teams need to answer several questions:</p><p>Is this URL known to be malicious?</p><p>Has it previously been associated with malware?</p><p>What threat intelligence is available for the destination?</p><p>Can we automatically contain the endpoint?</p><p>In this article, I will demonstrate an updated Wazuh and URLhaus integration that extends the standard URLhaus integration with additional network observables and automated response capabilities.</p><p>The implementation supports:</p><ul><li>HTTP 3xx redirects</li><li>HTTP 200 URLs</li><li>TLS SNI</li><li>QUIC TLS SNI</li><li>URLhaus URL lookups</li><li>URLhaus host lookups</li><li>Threat-intelligence enrichment</li><li>Wazuh custom detection rules</li><li>IPv4 blocking</li><li>IPv6 blocking</li><li>Connection tracking cleanup</li><li>Automated Active Response</li></ul><p>The overall workflow is:</p><pre>Network Activity<br>       |<br>       v<br>   Suricata<br>       |<br>       v<br> Wazuh Agent<br>       |<br>       v<br> Wazuh Manager<br>       |<br>       v<br>custom-urlhaus.py<br>       |<br>       +---- HTTP URL ------&gt; URLhaus /v1/url/<br>       |<br>       +---- TLS SNI -------&gt; URLhaus /v1/host/<br>       |<br>       +---- QUIC SNI ------&gt; URLhaus /v1/host/<br>       |<br>       v<br>Threat Intelligence<br>       |<br>       v<br>Wazuh Detection Rule<br>       |<br>       v<br>Active Response<br>       |<br>       v<br>DNS Resolution<br>       |<br>       +---- IPv4 ------&gt; iptables<br>       |<br>       +---- IPv6 ------&gt; ip6tables<br>       |<br>       v<br>conntrack cleanup</pre><h3>Introduction</h3><p>URLhaus is a project from abuse.ch that collects and shares information about malicious URLs used for malware distribution.</p><p>Wazuh, on the other hand, provides endpoint monitoring, detection, alerting and automated response capabilities.</p><p>The official Wazuh URLhaus integration demonstrates how Suricata alerts can be enriched with URLhaus intelligence.</p><p>The standard workflow primarily looks at the HTTP redirect field and submits the URL to the URLhaus API.</p><p>That works well for redirect-based detections, but modern network traffic provides additional observables.</p><p>For example, encrypted traffic may expose the destination through TLS SNI, while HTTP traffic can provide the hostname and URL even when there is no redirect.</p><p>This implementation therefore expands the observable extraction logic.</p><p>The integration checks for an observable in the following order:</p><pre>1. HTTP 3xx redirect<br>        |<br>        v<br>2. HTTP 200 hostname + URL<br>        |<br>        v<br>3. TLS SNI<br>        |<br>        v<br>4. QUIC TLS SNI<br>        |<br>        v<br>5. No observable -&gt; Skip</pre><p>The type of observable determines which URLhaus API endpoint is used.</p><pre>URL<br> |<br> +---- /v1/url/</pre><pre>HOST<br> |<br> +---- /v1/host/</pre><p>This provides a more flexible threat-intelligence enrichment layer.</p><h3>Lab Environment</h3><p>For this implementation, I used the following components:</p><pre>Wazuh Manager<br>Wazuh Agent<br>Suricata<br>URLhaus<br>Python<br>Bash<br>iptables<br>ip6tables<br>conntrack<br>jq</pre><p>The Wazuh Manager receives alerts from the endpoint and executes the custom URLhaus integration.</p><p>The endpoint runs the Active Response script that performs the actual network containment.</p><h3>1. Create the URLhaus Integration</h3><p>The first component is the custom Wazuh integration.</p><p>Create the following file on the Wazuh Manager:</p><pre>sudo vi /var/ossec/integrations/custom-urlhaus.py</pre><p>The complete integration script is:</p><pre>#!/var/ossec/framework/python/bin/python3</pre><pre># Author: @Digvijay Singh</pre><pre>import json<br>import sys<br>import time<br>import os<br>from socket import socket, AF_UNIX, SOCK_DGRAM</pre><pre>try:<br>    import requests<br>    from requests.auth import HTTPBasicAuth<br>except Exception:<br>    print(&quot;No module &#39;requests&#39; found. Install: pip install requests&quot;)<br>    sys.exit(1)<br></pre><pre># Global variables</pre><pre>debug_enabled = True</pre><pre>pwd = os.path.dirname(<br>    os.path.dirname(<br>        os.path.realpath(__file__)<br>    )<br>)</pre><pre>now = time.strftime(<br>    &quot;%a %b %d %H:%M:%S %Z %Y&quot;<br>)<br></pre><pre># Set paths</pre><pre>log_file = &quot;{0}/logs/integrations.log&quot;.format(pwd)</pre><pre>socket_addr = &quot;{0}/queue/sockets/queue&quot;.format(pwd)<br></pre><pre>def main(args):</pre><pre>    debug(&quot;# Starting&quot;)</pre><pre>    # Read arguments</pre><pre>    alert_file_location = args[1]</pre><pre>    debug(&quot;# File location&quot;)</pre><pre>    debug(alert_file_location)<br></pre><pre>    # Load alert</pre><pre>    with open(alert_file_location) as alert_file:</pre><pre>        json_alert = json.load(alert_file)<br></pre><pre>    debug(&quot;# Processing alert&quot;)</pre><pre>    debug(json_alert)<br></pre><pre>    # Request URLhaus information</pre><pre>    msg = request_urlhaus_info(json_alert)<br></pre><pre>    # If we received a response, send event</pre><pre>    if msg:</pre><pre>        send_event(<br>            msg,<br>            json_alert.get(&quot;agent&quot;)<br>        )<br></pre><pre>def debug(msg):</pre><pre>    if debug_enabled:</pre><pre>        line = &quot;{0}: {1}\n&quot;.format(<br>            now,<br>            msg<br>        )</pre><pre>        print(<br>            line,<br>            end=&quot;&quot;<br>        )</pre><pre>        with open(<br>            log_file,<br>            &quot;a&quot;<br>        ) as f:</pre><pre>            f.write(line)<br></pre><pre>def collect(data):</pre><pre>    return (<br>        data.get(&quot;urlhaus_reference&quot;),<br>        data.get(&quot;url_status&quot;),<br>        data.get(&quot;date_added&quot;),<br>        data.get(&quot;threat&quot;),<br>        data.get(&quot;blacklists&quot;, {}).get(&quot;spamhaus_dbl&quot;),<br>        data.get(&quot;blacklists&quot;, {}).get(&quot;surbl&quot;),<br>        data.get(&quot;tags&quot;),<br>    )<br></pre><pre>def in_database(data):</pre><pre>    return data.get(&quot;query_status&quot;) == &quot;ok&quot;<br></pre><pre>def query_api(url):</pre><pre>    params = {<br>        &quot;url&quot;: url<br>    }</pre><pre>    r = requests.post(<br>        &quot;https://urlhaus-api.abuse.ch/v1/url/&quot;,<br>        params,<br>        timeout=10<br>    )</pre><pre>    return r.json()<br></pre><pre>def query_api_host(host):</pre><pre>    params = {<br>        &quot;host&quot;: host<br>    }</pre><pre>    r = requests.post(<br>        &quot;https://urlhaus-api.abuse.ch/v1/host/&quot;,<br>        params,<br>        timeout=10<br>    )</pre><pre>    return r.json()<br></pre><pre>def request_urlhaus_info(alert):</pre><pre>    alert_output = {}</pre><pre>    data = alert.get(<br>        &quot;data&quot;,<br>        {}<br>    )<br></pre><pre>    # -------------------------------------------------<br>    # 1. HTTP 3xx redirect<br>    # -------------------------------------------------</pre><pre>    http = data.get(<br>        &quot;http&quot;,<br>        {}<br>    )</pre><pre>    redirect = http.get(<br>        &quot;redirect&quot;<br>    )<br></pre><pre>    if redirect:</pre><pre>        observable = redirect</pre><pre>        kind = &quot;url&quot;<br></pre><pre>    # -------------------------------------------------<br>    # 2. HTTP 200<br>    # -------------------------------------------------</pre><pre>    elif (<br>        http.get(&quot;hostname&quot;)<br>        and<br>        http.get(&quot;url&quot;)<br>    ):</pre><pre>        observable = (<br>            f&quot;http://{http[&#39;hostname&#39;]}{http[&#39;url&#39;]}&quot;<br>        )</pre><pre>        kind = &quot;url&quot;<br></pre><pre>    else:</pre><pre>        # -------------------------------------------------<br>        # 3. TLS SNI<br>        # -------------------------------------------------</pre><pre>        tls = data.get(<br>            &quot;tls&quot;,<br>            {}<br>        )</pre><pre>        sni = tls.get(<br>            &quot;sni&quot;<br>        )<br></pre><pre>        if sni:</pre><pre>            observable = sni</pre><pre>            kind = &quot;host&quot;<br></pre><pre>        else:</pre><pre>            # -------------------------------------------------<br>            # 4. QUIC TLS SNI<br>            # -------------------------------------------------</pre><pre>            quic = data.get(<br>                &quot;quic_tls_sni&quot;<br>            )<br></pre><pre>            if quic:</pre><pre>                observable = quic</pre><pre>                kind = &quot;host&quot;<br></pre><pre>            else:</pre><pre>                debug(<br>                    &quot;# No observable found - skipping&quot;<br>                )</pre><pre>                return 0<br></pre><pre>    debug(<br>        f&quot;# Observable ({kind}): {observable}&quot;<br>    )<br></pre><pre>    # -------------------------------------------------<br>    # Query URLhaus<br>    # -------------------------------------------------</pre><pre>    if kind == &quot;url&quot;:</pre><pre>        resp = query_api(<br>            observable<br>        )</pre><pre>    else:</pre><pre>        resp = query_api_host(<br>            observable<br>        )<br></pre><pre>    # -------------------------------------------------<br>    # Build output<br>    # -------------------------------------------------</pre><pre>    alert_output[&quot;urlhaus&quot;] = {}</pre><pre>    alert_output[&quot;integration&quot;] = (<br>        &quot;custom-urlhaus&quot;<br>    )</pre><pre>    alert_output[&quot;urlhaus&quot;][&quot;found&quot;] = (<br>        1 if in_database(resp) else 0<br>    )<br></pre><pre>    src = {</pre><pre>        &quot;alert_id&quot;: alert.get(&quot;id&quot;),</pre><pre>        &quot;rule&quot;: alert.get(<br>            &quot;rule&quot;,<br>            {}<br>        ).get(&quot;id&quot;),</pre><pre>        &quot;description&quot;: alert.get(<br>            &quot;rule&quot;,<br>            {}<br>        ).get(&quot;description&quot;),</pre><pre>        &quot;url&quot;: observable,<br>    }<br></pre><pre>    alert_output[&quot;urlhaus&quot;][&quot;source&quot;] = src<br></pre><pre>    # -------------------------------------------------<br>    # URLhaus match<br>    # -------------------------------------------------</pre><pre>    if alert_output[&quot;urlhaus&quot;][&quot;found&quot;]:</pre><pre>        (<br>            ref,<br>            status,<br>            date_added,<br>            threat,<br>            bl_spam,<br>            bl_surbl,<br>            tags<br>        ) = collect(resp)<br></pre><pre>        alert_output[&quot;urlhaus&quot;].update({</pre><pre>            &quot;urlhaus_reference&quot;: ref,</pre><pre>            &quot;url_status&quot;: status,</pre><pre>            &quot;url_date_added&quot;: date_added,</pre><pre>            &quot;url_threat&quot;: threat,</pre><pre>            &quot;url_blacklist_spamhaus&quot;: bl_spam,</pre><pre>            &quot;url_blacklist_surbl&quot;: bl_surbl,</pre><pre>            &quot;url_tags&quot;: tags,</pre><pre>        })<br></pre><pre>    else:</pre><pre>        error = resp.get(<br>            &quot;errors&quot;,<br>            [{}]<br>        )[0].get(<br>            &quot;detail&quot;,<br>            &quot;no_result&quot;<br>        )</pre><pre>        alert_output[&quot;urlhaus&quot;][&quot;error&quot;] = error<br></pre><pre>    debug(<br>        alert_output<br>    )<br></pre><pre>    return alert_output<br></pre><pre>def send_event(<br>    msg,<br>    agent=None<br>):</pre><pre>    if (<br>        not agent<br>        or<br>        agent.get(&quot;id&quot;) == &quot;000&quot;<br>    ):</pre><pre>        string = (<br>            &quot;1:urlhaus:{0}&quot;<br>            .format(<br>                json.dumps(msg)<br>            )<br>        )<br></pre><pre>    else:</pre><pre>        string = (<br>            &quot;1:[{0}] ({1}) {2}-&gt;urlhaus:{3}&quot;<br>            .format(<br>                agent.get(&quot;id&quot;),<br>                agent.get(&quot;name&quot;),<br>                agent.get(&quot;ip&quot;, &quot;any&quot;),<br>                json.dumps(msg),<br>            )<br>        )<br></pre><pre>    debug(<br>        string<br>    )<br></pre><pre>    sock = socket(<br>        AF_UNIX,<br>        SOCK_DGRAM<br>    )<br></pre><pre>    sock.connect(<br>        socket_addr<br>    )<br></pre><pre>    sock.send(<br>        string.encode()<br>    )<br></pre><pre>    sock.close()<br></pre><pre>if __name__ == &quot;__main__&quot;:</pre><pre>    try:</pre><pre>        bad_arguments = False<br></pre><pre>        if len(sys.argv) &gt;= 4:</pre><pre>            debug_enabled = (<br>                len(sys.argv) &gt; 4<br>                and<br>                sys.argv[4] == &quot;debug&quot;<br>            )<br></pre><pre>        else:</pre><pre>            bad_arguments = True<br></pre><pre>        if bad_arguments:</pre><pre>            debug(<br>                &quot;# Exiting: Wrong arguments.&quot;<br>            )</pre><pre>            sys.exit(1)<br></pre><pre>        main(<br>            sys.argv<br>        )<br></pre><pre>    except Exception as e:</pre><pre>        debug(<br>            str(e)<br>        )</pre><pre>        raise</pre><h3>2. Make the Integration Executable</h3><p>Set the required permissions:</p><pre>sudo chmod 750 /var/ossec/integrations/custom-urlhaus.py</pre><p>Then set the ownership:</p><pre>sudo chown root:wazuh /var/ossec/integrations/custom-urlhaus.py</pre><p>Verify:</p><pre>ls -l /var/ossec/integrations/custom-urlhaus.py</pre><p>You should see permissions similar to:</p><pre>-rwxr-x--- root wazuh custom-urlhaus.py</pre><h3>3. Configure Wazuh</h3><p>Edit the Wazuh Manager configuration:</p><pre>sudo vi /var/ossec/etc/ossec.conf</pre><p>Add the integration:</p><pre>&lt;integration&gt;<br>    &lt;name&gt;custom-urlhaus.py&lt;/name&gt;<br>    &lt;hook_url&gt;https://urlhaus-api.abuse.ch/v1/url/&lt;/hook_url&gt;<br>    &lt;alert_format&gt;json&lt;/alert_format&gt;<br>&lt;/integration&gt;</pre><p>However, I recommend filtering the integration to only the alerts that actually contain network observables.</p><p>For example:</p><pre>&lt;integration&gt;<br>    &lt;name&gt;custom-urlhaus.py&lt;/name&gt;<br>    &lt;rule_id&gt;86601&lt;/rule_id&gt;<br>    &lt;alert_format&gt;json&lt;/alert_format&gt;<br>&lt;/integration&gt;</pre><p>The exact rule ID depends on your environment and the rules you are using for network detection.</p><p>Restart Wazuh:</p><pre>sudo systemctl restart wazuh-manager</pre><h3>4. How the Observable Detection Works</h3><p>This is the most important part of the updated integration.</p><p>The script doesn’t assume that every malicious network event contains:</p><pre>http.redirect</pre><p>Instead, it attempts several different observables.</p><h3>HTTP 3xx Redirect</h3><p>The first check is:</p><pre>http = data.get(&quot;http&quot;, {})<br>redirect = http.get(&quot;redirect&quot;)</pre><p>If a redirect exists:</p><pre>observable = redirect<br>kind = &quot;url&quot;</pre><p>The integration then sends the URL to:</p><pre>https://urlhaus-api.abuse.ch/v1/url/</pre><h3>5. HTTP 200 Traffic</h3><p>A HTTP 200 response may not contain a redirect.</p><p>For this scenario, the script checks:</p><pre>http.get(&quot;hostname&quot;)<br>http.get(&quot;url&quot;)</pre><p>It then reconstructs the URL:</p><pre>observable = f&quot;http://{http[&#39;hostname&#39;]}{http[&#39;url&#39;]}&quot;</pre><p>For example:</p><pre>Hostname:<br>malicious.example.com</pre><pre>URL:<br>/payload.exe</pre><p>becomes:</p><pre>http://malicious.example.com/payload.exe</pre><p>This URL is then submitted to the URLhaus URL API.</p><h3>6. TLS SNI</h3><p>HTTPS traffic creates another challenge.</p><p>The HTTP request itself is encrypted, but the TLS handshake can expose the Server Name Indication, depending on the protocol and deployment.</p><p>The integration checks:</p><pre>tls = data.get(&quot;tls&quot;, {})<br>sni = tls.get(&quot;sni&quot;)</pre><p>If SNI is available:</p><pre>observable = sni<br>kind = &quot;host&quot;</pre><p>The integration then queries:</p><pre>https://urlhaus-api.abuse.ch/v1/host/</pre><p>Instead of performing a URL lookup, we are now performing a host lookup.</p><h3>7. QUIC TLS SNI</h3><p>HTTP/3 uses QUIC instead of traditional TCP-based HTTP transport.</p><p>The integration therefore also checks:</p><pre>quic = data.get(&quot;quic_tls_sni&quot;)</pre><p>If available:</p><pre>observable = quic<br>kind = &quot;host&quot;</pre><p>The host is then queried using the URLhaus host API.</p><p>This gives us coverage across:</p><pre>HTTP<br>TLS<br>QUIC</pre><p>rather than depending exclusively on HTTP redirect events.</p><h3>8. URLhaus Response</h3><p>After querying URLhaus, the integration builds a new Wazuh event.</p><p>A successful result looks conceptually like:</p><pre>{<br>  &quot;integration&quot;: &quot;custom-urlhaus&quot;,<br>  &quot;urlhaus&quot;: {<br>    &quot;found&quot;: 1,<br>    &quot;source&quot;: {<br>      &quot;alert_id&quot;: &quot;123456&quot;,<br>      &quot;rule&quot;: &quot;86601&quot;,<br>      &quot;description&quot;: &quot;Network alert&quot;,<br>      &quot;url&quot;: &quot;http://malicious.example/payload.exe&quot;<br>    },<br>    &quot;urlhaus_reference&quot;: &quot;https://urlhaus.abuse.ch/url/...&quot;,<br>    &quot;url_status&quot;: &quot;online&quot;,<br>    &quot;url_date_added&quot;: &quot;2026-09-23&quot;,<br>    &quot;url_threat&quot;: &quot;malware_download&quot;,<br>    &quot;url_blacklist_spamhaus&quot;: &quot;...&quot;,<br>    &quot;url_blacklist_surbl&quot;: &quot;...&quot;,<br>    &quot;url_tags&quot;: [<br>      &quot;malware&quot;<br>    ]<br>  }<br>}</pre><p>The important field is:</p><pre>urlhaus.found</pre><p>When:</p><pre>urlhaus.found = 1</pre><p>the observable was found in the URLhaus database.</p><h3>9. Create a Wazuh Detection Rule</h3><p>Now that the event contains URLhaus intelligence, we can create a custom Wazuh rule.</p><p>Edit:</p><pre>sudo vi /var/ossec/etc/rules/local_rules.xml</pre><p>Add:</p><pre>&lt;group name=&quot;urlhaus,threat_intelligence,&quot;&gt;</pre><pre>    &lt;rule id=&quot;100004&quot; level=&quot;12&quot;&gt;</pre><pre>        &lt;field name=&quot;urlhaus.found&quot;&gt;1&lt;/field&gt;</pre><pre>        &lt;description&gt;<br>            URLhaus: Endpoint connected to known malicious URL or host<br>        &lt;/description&gt;</pre><pre>        &lt;group&gt;<br>            threat_intelligence,<br>            malicious_url,<br>        &lt;/group&gt;</pre><pre>    &lt;/rule&gt;</pre><pre>&lt;/group&gt;</pre><p>You can create additional rules for specific URLhaus threat categories.</p><p>For example:</p><pre>&lt;rule id=&quot;100005&quot; level=&quot;13&quot;&gt;</pre><pre>    &lt;field name=&quot;urlhaus.url_threat&quot;&gt;malware_download&lt;/field&gt;</pre><pre>    &lt;description&gt;<br>        URLhaus: Endpoint connected to infrastructure associated with malware delivery<br>    &lt;/description&gt;</pre><pre>    &lt;group&gt;<br>        threat_intelligence,<br>        malware,<br>        malicious_url,<br>    &lt;/group&gt;</pre><pre>&lt;/rule&gt;</pre><p>Restart Wazuh:</p><pre>sudo systemctl restart wazuh-manager</pre><h3>10. Test the Integration</h3><p>The first place to check is:</p><pre>sudo tail -f /var/ossec/logs/integrations.log</pre><p>When the integration processes an alert, you should see output similar to:</p><pre># Starting<br># File location<br># Processing alert<br># Observable (url): http://example.com/payload.exe</pre><p>For TLS:</p><pre># Observable (host): malicious.example.com</pre><p>For QUIC:</p><pre># Observable (host): malicious.example.com</pre><p>If no supported observable is available:</p><pre># No observable found - skipping</pre><p>This prevents unnecessary API calls.</p><h3>11. Adding Automated Response</h3><p>Detection and threat intelligence are useful, but we can take the workflow one step further.</p><p>Once URLhaus confirms that the destination is malicious, Wazuh can trigger an Active Response.</p><p>The response performs:</p><pre>URLhaus Detection<br>       |<br>       v<br>Extract URL<br>       |<br>       v<br>Extract Host<br>       |<br>       v<br>DNS Resolution<br>       |<br>       v<br>IPv4 / IPv6<br>       |<br>       +------&gt; iptables<br>       |<br>       +------&gt; ip6tables<br>       |<br>       v<br>conntrack cleanup</pre><p>This changes the workflow from:</p><pre>Detect -&gt; Alert</pre><p>to:</p><pre>Detect -&gt; Enrich -&gt; Correlate -&gt; Contain</pre><h3>12. Create the Active Response Script</h3><p>On the Wazuh endpoint, create:</p><pre>sudo vi /var/ossec/active-response/bin/block_urlhaus.sh</pre><p>Use the following script:</p><pre>#!/usr/bin/env bash</pre><pre>PATH=/usr/sbin:/sbin:/usr/bin:/bin</pre><pre>LOGTAG=&quot;block_urlhaus&quot;<br></pre><pre># -------------------------------------------------<br># Read the complete Active Response envelope<br># -------------------------------------------------</pre><pre>read -r ACTION AGENT_ID ENVELOPE || exit 1<br></pre><pre>[[ &quot;$ACTION&quot; =~ ^(add|delete)$ ]] || {</pre><pre>    ENVELOPE=&quot;$ACTION $AGENT_ID $ENVELOPE&quot;</pre><pre>    ACTION=add<br>}<br></pre><pre># -------------------------------------------------<br># Verify jq<br># -------------------------------------------------</pre><pre>command -v jq &gt;/dev/null 2&gt;&amp;1 || {</pre><pre>    logger -t &quot;$LOGTAG&quot; &quot;jq missing&quot;</pre><pre>    echo &quot;0 jq missing&quot;</pre><pre>    exit 1<br>}<br></pre><pre># -------------------------------------------------<br># Extract URL from the Wazuh alert<br># -------------------------------------------------</pre><pre>URL=$(echo &quot;$ENVELOPE&quot; |<br>    jq -r &#39;.parameters.alert.data.urlhaus.source.url // empty&#39;)<br></pre><pre>[[ -z &quot;$URL&quot; ]] &amp;&amp; {</pre><pre>    logger -t &quot;$LOGTAG&quot; &quot;no URL in envelope&quot;</pre><pre>    echo &quot;0 no URL&quot;</pre><pre>    exit 0<br>}<br></pre><pre># -------------------------------------------------<br># Extract hostname<br># -------------------------------------------------</pre><pre>HOST=$(printf &#39;%s\n&#39; &quot;$URL&quot; |<br>    sed -E &#39;s|^[a-zA-Z]+://||; s|/.*$||&#39;)<br></pre><pre>[[ -z &quot;$HOST&quot; ]] &amp;&amp; {</pre><pre>    logger -t &quot;$LOGTAG&quot; &quot;cannot parse host&quot;</pre><pre>    echo &quot;0 bad host&quot;</pre><pre>    exit 1<br>}<br></pre><pre># -------------------------------------------------<br># Resolve IPv4 and IPv6 addresses<br># -------------------------------------------------</pre><pre>IPS=$(getent ahosts &quot;$HOST&quot; |<br>    awk &#39;{print $1}&#39; |<br>    sort -u)<br></pre><pre>[[ -z &quot;$IPS&quot; ]] &amp;&amp; {</pre><pre>    logger -t &quot;$LOGTAG&quot; &quot;DNS failed for $HOST&quot;</pre><pre>    echo &quot;0 NXDOMAIN&quot;</pre><pre>    exit 1<br>}<br></pre><pre># -------------------------------------------------<br># Add or remove firewall rules<br># -------------------------------------------------</pre><pre>for IP in $IPS; do</pre><pre>    if [ &quot;$ACTION&quot; = &quot;add&quot; ]; then</pre><pre>        iptables \<br>            -C OUTPUT \<br>            -d &quot;$IP&quot; \<br>            -j DROP 2&gt;/dev/null ||</pre><pre>        iptables \<br>            -I OUTPUT \<br>            -d &quot;$IP&quot; \<br>            -j DROP<br></pre><pre>        ip6tables \<br>            -C OUTPUT \<br>            -d &quot;$IP&quot; \<br>            -j DROP 2&gt;/dev/null ||</pre><pre>        ip6tables \<br>            -I OUTPUT \<br>            -d &quot;$IP&quot; \<br>            -j DROP<br></pre><pre>        # -------------------------------------------------<br>        # Remove existing tracked connections<br>        # -------------------------------------------------</pre><pre>        if command -v conntrack &gt;/dev/null 2&gt;&amp;1; then</pre><pre>            conntrack \<br>                -D \<br>                -d &quot;$IP&quot; \<br>                2&gt;/dev/null</pre><pre>            conntrack \<br>                -D \<br>                -s &quot;$IP&quot; \<br>                2&gt;/dev/null</pre><pre>        fi<br></pre><pre>    else</pre><pre>        iptables \<br>            -D OUTPUT \<br>            -d &quot;$IP&quot; \<br>            -j DROP \<br>            2&gt;/dev/null<br></pre><pre>        ip6tables \<br>            -D OUTPUT \<br>            -d &quot;$IP&quot; \<br>            -j DROP \<br>            2&gt;/dev/null</pre><pre>    fi</pre><pre>done<br></pre><pre># -------------------------------------------------<br># Log result<br># -------------------------------------------------</pre><pre>MSG=&quot;$ACTION $(echo &quot;$IPS&quot; | xargs) ($HOST)&quot;</pre><pre>logger \<br>    -t &quot;$LOGTAG&quot; \<br>    &quot;$MSG&quot;<br></pre><pre>echo &quot;1 $MSG&quot;</pre><pre>exit 0</pre><p>Make the script executable:</p><pre>sudo chmod 750 /var/ossec/active-response/bin/block_urlhaus.sh</pre><p>Set ownership:</p><pre>sudo chown root:wazuh /var/ossec/active-response/bin/block_urlhaus.sh</pre><h3>13. How the Active Response Works</h3><p>The Active Response receives the Wazuh alert through STDIN.</p><p>The relevant field is:</p><pre>.parameters.alert.data.urlhaus.source.url</pre><p>The script extracts this field using jq:</p><pre>jq -r &#39;.parameters.alert.data.urlhaus.source.url // empty&#39;</pre><p>For example:</p><pre>http://malicious.example.com/payload.exe</pre><p>The script extracts:</p><pre>malicious.example.com</pre><p>using:</p><pre>sed -E &#39;s|^[a-zA-Z]+://||; s|/.*$||&#39;</pre><p>The hostname is then resolved.</p><h3>14. DNS Resolution</h3><p>The script uses:</p><pre>getent ahosts &quot;$HOST&quot;</pre><p>and extracts the unique addresses:</p><pre>awk &#39;{print $1}&#39; | sort -u</pre><p>For example:</p><pre>malicious.example.com</pre><pre>203.0.113.10<br>203.0.113.11<br>2001:db8::10</pre><p>Every returned address is processed.</p><h3>15. IPv4 Blocking</h3><p>For IPv4, the script checks whether an existing rule already exists:</p><pre>iptables -C OUTPUT -d &quot;$IP&quot; -j DROP</pre><p>If it does not exist, the script inserts:</p><pre>iptables -I OUTPUT -d &quot;$IP&quot; -j DROP</pre><p>This prevents the endpoint from sending outbound traffic to the destination.</p><p>The check-before-insert behavior is important because it prevents duplicate firewall rules.</p><h3>16. IPv6 Blocking</h3><p>IPv6 is handled separately:</p><pre>ip6tables -C OUTPUT -d &quot;$IP&quot; -j DROP</pre><p>If the rule does not exist:</p><pre>ip6tables -I OUTPUT -d &quot;$IP&quot; -j DROP</pre><p>This is important because blocking only IPv4 can leave an alternative IPv6 communication path available.</p><h3>17. Why Conntrack Cleanup?</h3><p>Adding a firewall rule does not necessarily mean an already-established connection immediately disappears.</p><p>Consider:</p><pre>10:00:00<br>Endpoint connects to malicious server</pre><pre>10:00:01<br>URLhaus confirms malicious infrastructure</pre><pre>10:00:02<br>iptables DROP rule added</pre><p>An existing connection may still be tracked by the kernel.</p><p>The script therefore attempts to delete the connection-tracking entries:</p><pre>conntrack -D -d &quot;$IP&quot;</pre><p>and:</p><pre>conntrack -D -s &quot;$IP&quot;</pre><p>This helps terminate existing tracked connections to the destination.</p><h3>18. Configure Active Response</h3><p>Edit the Wazuh Manager configuration:</p><pre>sudo vi /var/ossec/etc/ossec.conf</pre><p>Add:</p><pre>&lt;command&gt;<br>    &lt;name&gt;block-urlhaus&lt;/name&gt;<br>    &lt;executable&gt;block_urlhaus.sh&lt;/executable&gt;<br>    &lt;timeout_allowed&gt;yes&lt;/timeout_allowed&gt;<br>&lt;/command&gt;</pre><p>Then configure the Active Response:</p><pre>&lt;active-response&gt;<br>    &lt;disabled&gt;no&lt;/disabled&gt;<br>    &lt;command&gt;block-urlhaus&lt;/command&gt;<br>    &lt;location&gt;local&lt;/location&gt;<br>    &lt;rules_id&gt;100004&lt;/rules_id&gt;<br>&lt;/active-response&gt;</pre><p>In this example, rule 100004 is the rule that identifies a URLhaus match.</p><p>Restart the manager:</p><pre>sudo systemctl restart wazuh-manager</pre><h3>19. Verify Active Response</h3><p>On the endpoint, monitor:</p><pre>sudo tail -f /var/ossec/logs/active-responses.log</pre><p>You can also inspect the system log:</p><pre>journalctl -t block_urlhaus</pre><p>Check the IPv4 firewall:</p><pre>sudo iptables -L OUTPUT -n -v</pre><p>Check IPv6:</p><pre>sudo ip6tables -L OUTPUT -n -v</pre><p>You should see a DROP rule for the resolved destination.</p><h3>20. End-to-End Flow</h3><p>At this point, the complete workflow looks like this:</p><pre>1. Endpoint generates network traffic            |<br>            v<br>2. Suricata detects network activity<br>            |<br>            v<br>3. Wazuh receives the event<br>            |<br>            v<br>4. custom-urlhaus.py extracts observable<br>            |<br>            +---- HTTP Redirect<br>            |<br>            +---- HTTP URL<br>            |<br>            +---- TLS SNI<br>            |<br>            +---- QUIC SNI<br>            |<br>            v<br>5. URLhaus API lookup<br>            |<br>            v<br>6. Threat intelligence enrichment<br>            |<br>            v<br>7. Wazuh custom rule<br>            |<br>            v<br>8. Active Response<br>            |<br>            v<br>9. DNS resolution<br>            |<br>            +---- IPv4<br>            |<br>            +---- IPv6<br>            |<br>            v<br>10. Firewall blocking<br>            |<br>            v<br>11. Conntrack cleanup</pre><h3>21. Troubleshooting</h3><p>If the integration is not working, start with the Wazuh integration log:</p><pre>sudo tail -f /var/ossec/logs/integrations.log</pre><p>Then check the Wazuh Manager log:</p><pre>sudo tail -f /var/ossec/logs/ossec.log</pre><p>For Active Response:</p><pre>sudo tail -f /var/ossec/logs/active-responses.log</pre><p>Check the integration permissions:</p><pre>ls -l /var/ossec/integrations/custom-urlhaus.py</pre><p>Check the Active Response permissions:</p><pre>ls -l /var/ossec/active-response/bin/block_urlhaus.sh</pre><p>Verify the Python requests module:</p><pre>/var/ossec/framework/python/bin/python3 \<br>-c &quot;import requests; print(requests.__version__)&quot;</pre><p>Verify DNS resolution:</p><pre>getent ahosts example.com</pre><p>Verify jq:</p><pre>command -v jq</pre><p>Verify conntrack:</p><pre>command -v conntrack</pre><p>Verify firewall utilities:</p><pre>command -v iptables<br>command -v ip6tables</pre><h3>22. Important Production Considerations</h3><p>There is an important difference between URL blocking and IP blocking.</p><p>URLhaus may identify:</p><pre>http://malicious.example.com/payload.exe</pre><p>but the Active Response ultimately blocks:</p><pre>203.0.113.10</pre><p>That means the response is operating at the IP layer.</p><p>This can have consequences.</p><h3>Shared Hosting</h3><p>Multiple domains can resolve to the same IP.</p><p>Blocking the IP could therefore affect legitimate services hosted on the same infrastructure.</p><h3>CDN Infrastructure</h3><p>The same situation can occur with CDNs and reverse proxies.</p><p>A single IP can represent many unrelated domains.</p><h3>Dynamic DNS</h3><p>The hostname may resolve to different IP addresses over time.</p><p>The firewall rule created during the Active Response will not automatically follow future DNS changes.</p><h3>IPv6</h3><p>IPv6 must be handled independently.</p><p>Blocking only IPv4 does not guarantee that communication cannot continue over IPv6.</p><p>For these reasons, automated blocking should be tested carefully before being deployed broadly in production.</p><h3>23. Detection vs. Containment</h3><p>One of the main design principles behind this implementation is keeping threat intelligence and enforcement as separate layers.</p><p>URLhaus answers:</p><blockquote><em>Is this URL or host known to be associated with malicious activity?</em></blockquote><p>Wazuh answers:</p><blockquote><em>Which endpoint generated the event and which detection rule identified it?</em></blockquote><p>Active Response answers:</p><blockquote><em>What action should be taken on the endpoint?</em></blockquote><p>Together they create:</p><pre>Telemetry<br>    |<br>    v<br>Detection<br>    |<br>    v<br>Threat Intelligence<br>    |<br>    v<br>Correlation<br>    |<br>    v<br>Decision<br>    |<br>    v<br>Containment</pre><p>This architecture can also be extended later with additional threat-intelligence providers.</p><p>For example:</p><pre>Wazuh<br>                   |<br>          +--------+--------+<br>          |        |        |<br>          v        v        v<br>       URLhaus   Yeti    Other TI<br>          |        |        |<br>          +--------+--------+<br>                   |<br>                   v<br>             Correlation<br>                   |<br>                   v<br>             Risk Decision<br>                   |<br>                   v<br>            Active Response</pre><h3>24. What Makes This Integration Different?</h3><p>The important improvement is not simply adding another API call.</p><p>The integration expands the observable extraction layer.</p><p>Instead of relying only on:</p><pre>HTTP Redirect</pre><p>we can now process:</p><pre>HTTP Redirect<br>HTTP 200<br>TLS SNI<br>QUIC TLS SNI</pre><p>The integration also understands the difference between a URL and a hostname.</p><p>URLs are sent to:</p><pre>/v1/url/</pre><p>while hostnames are sent to:</p><pre>/v1/host/</pre><p>This gives the integration a more flexible architecture for network telemetry.</p><p>The second major improvement is automated containment.</p><p>Instead of:</p><pre>Detect -&gt; Alert</pre><p>the workflow becomes:</p><pre>Detect<br>   |<br>   v<br>Enrich<br>   |<br>   v<br>Correlate<br>   |<br>   v<br>Alert<br>   |<br>   v<br>Contain</pre><h3>25. Final Architecture</h3><p>The final implementation can be summarized as:</p><pre>INTERNET<br>                             |<br>                             v<br>                    +----------------+<br>                    |    Endpoint    |<br>                    +-------+--------+<br>                            |<br>                            v<br>                    +---------------+<br>                    |   Suricata    |<br>                    +-------+-------+<br>                            |<br>                            v<br>                    +---------------+<br>                    |  Wazuh Agent  |<br>                    +-------+-------+<br>                            |<br>                            v<br>                    +---------------+<br>                    | Wazuh Manager  |<br>                    +-------+-------+<br>                            |<br>                            v<br>                  +---------------------+<br>                  | custom-urlhaus.py   |<br>                  +----------+----------+<br>                             |<br>             +---------------+---------------+<br>             |               |               |<br>             v               v               v<br>         HTTP URL         TLS SNI        QUIC SNI<br>             |               |               |<br>             v               v               v<br>       /v1/url/          /v1/host/       /v1/host/<br>             |               |               |<br>             +---------------+---------------+<br>                             |<br>                             v<br>                      +-------------+<br>                      |   URLhaus   |<br>                      +------+------+ <br>                             |<br>                             v<br>                    Threat Intelligence<br>                             |<br>                             v<br>                     Wazuh Rule Match<br>                             |<br>                             v<br>                    Active Response<br>                             |<br>                             v<br>                       DNS Resolve<br>                             |<br>                  +----------+----------+<br>                  |                     |<br>                  v                     v<br>                IPv4                  IPv6<br>                  |                     |<br>                  v                     v<br>              iptables              ip6tables<br>                  |                     |<br>                  +----------+----------+<br>                             |<br>                             v<br>                       conntrack<br>                             |<br>                             v<br>                      CONNECTION STOP</pre><h3>Conclusion</h3><p>Threat intelligence becomes significantly more valuable when it is connected directly to detection and response.</p><p>The standard Wazuh and URLhaus integration provides a useful foundation for enriching network alerts with malicious URL intelligence.</p><p>This implementation extends that approach by supporting additional observables:</p><pre>HTTP 3xx redirects<br>HTTP 200 URLs<br>TLS SNI<br>QUIC TLS SNI</pre><p>It also supports both URL and host lookups through the URLhaus API.</p><p>Finally, Wazuh Active Response can take the enriched alert and automatically perform endpoint containment through:</p><pre>DNS resolution<br>       |<br>       +---- IPv4 -&gt; iptables<br>       |<br>       +---- IPv6 -&gt; ip6tables<br>       |<br>       v<br>conntrack cleanup</pre><p>The resulting architecture is:</p><pre>Detect -&gt; Enrich -&gt; Correlate -&gt; Contain</pre><p>For security teams operating Wazuh at scale, this type of integration can help turn threat intelligence from a passive enrichment source into an active part of the detection and response pipeline.</p><p>As with any automated containment mechanism, IP-based blocking should be validated carefully in a controlled environment before being enabled broadly in production.</p><h3>References</h3><p>Wazuh — Detecting malicious URLs using Wazuh and URLhaus</p><p><a href="https://wazuh.com/blog/detecting-malicious-urls-using-wazuh-and-urlhaus/">https://wazuh.com/blog/detecting-malicious-urls-using-wazuh-and-urlhaus/</a></p><p>Wazuh — Integration configuration</p><p><a href="https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/integration.html">https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/integration.html</a></p><p>Wazuh — Custom Active Response scripts</p><p><a href="https://documentation.wazuh.com/current/user-manual/capabilities/active-response/custom-active-response-scripts.html">https://documentation.wazuh.com/current/user-manual/capabilities/active-response/custom-active-response-scripts.html</a></p><p>Wazuh — Active Response configuration</p><p><a href="https://documentation.wazuh.com/current/user-manual/capabilities/active-response/how-to-configure.html">https://documentation.wazuh.com/current/user-manual/capabilities/active-response/how-to-configure.html</a></p><p>URLhaus — abuse.ch</p><p><a href="https://urlhaus.abuse.ch/">https://urlhaus.abuse.ch/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6291078b452f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Updated :Wazuh–Yeti Integration]]></title>
            <link>https://medium.com/@ddigvijay/updated-wazuh-yeti-integration-5834fab6bc70?source=rss-bd4bfddba65------2</link>
            <guid isPermaLink="false">https://medium.com/p/5834fab6bc70</guid>
            <category><![CDATA[wazuh]]></category>
            <category><![CDATA[wazuh-yeti]]></category>
            <category><![CDATA[wazuh-integration]]></category>
            <category><![CDATA[wazuh-active-response]]></category>
            <category><![CDATA[yeti]]></category>
            <dc:creator><![CDATA[Digvijay]]></dc:creator>
            <pubDate>Mon, 21 Apr 2025 10:41:15 GMT</pubDate>
            <atom:updated>2025-05-11T06:58:44.509Z</atom:updated>
            <content:encoded><![CDATA[<p>Organizations often struggle to bring together <strong>Cyber Threat Intelligence</strong> (CTI) and <strong>Digital Forensics &amp; Incident Response</strong> (DFIR). Threat data lives in one tool, alerts in another — and valuable indicators get lost in the shuffle.</p><p><strong>Wazuh</strong> excels at monitoring and alerting, while <strong>Yeti</strong> (Your Everyday Threat Intelligence) offers a rich repository of observables — malware hashes, IP reputations, phishing domains, and more. By integrating them, you empower your SOC to enrich every alert with threat context.</p><blockquote><em>🚧 </em><strong><em>Heads‑up:</em></strong><em> The current </em>official<em> Wazuh documentation for Yeti integration is failing due to upstream API changes on Yeti’s side. When you run the script, you’ll see something like:</em></blockquote><pre># Querying Yeti API<br># Request result from Yeti server: 1:yeti:{&quot;yeti&quot;: {&quot;error&quot;: 405, &quot;description&quot;: &quot;Error: API request failed.&quot;}, &quot;integration&quot;: &quot;yeti&quot;}<br># Error: Yeti API request failed with status code 405<br># Running Yeti script</pre><blockquote><em>We’ll show you how to apply the same technical setup — but with updated notes — so you can detect malware hashes and abused IPs as soon as Yeti restores compatibility.</em></blockquote><h3>What We’ll Achieve</h3><ol><li><strong>Malware detection</strong> using the AbuseCHMalwareBazaar feed</li><li><strong>Suspicious IP tracking</strong> with AlienVaultIPReputation</li></ol><h3>Lab Environment</h3><ul><li><strong>Wazuh manager</strong>: OVA 4.10.1 (Ubuntu‑based)</li><li><strong>Endpoint</strong>: Ubuntu 24.04 with Docker &amp; Wazuh agent 4.10.1</li><li><strong>Yeti</strong>: Deployed via Docker‑Compose (ArangoDB v3.9+ with AVX CPU support)</li></ul><blockquote><strong><em>Tip:</em></strong><em> If your CPU lacks AVX, pin ArangoDB to v3.8.9 in </em><em>docker-compose.yml.</em></blockquote><h3>1. Prepare Yeti</h3><ol><li>Log into Yeti → <strong>ADMIN &gt; Users</strong> → copy your <strong>API key</strong>.</li><li>Go to <strong>AUTOMATION &gt; Feeds</strong> and enable:</li></ol><ul><li><strong>AbuseCHMalwareBazaar</strong></li><li><strong>AlienVaultIPReputation</strong></li></ul><h3>2. Configure the Wazuh Manager</h3><h3>a) Deployment of the integration script</h3><p>Updated Script:</p><p>Create /var/ossec/integrations/custom-yeti.py with <strong>exactly</strong> this content:</p><pre>#!/var/ossec/framework/python/bin/python3<br>import json<br>import os<br>import re<br>import sys<br>import requests<br>from requests.exceptions import Timeout<br>from socket import AF_UNIX, SOCK_DGRAM, socket<br><br># Exit error codes<br>ERR_NO_REQUEST_MODULE = 1<br>ERR_BAD_ARGUMENTS = 2<br>ERR_BAD_MD5_SUM = 3<br>ERR_NO_RESPONSE_YETI = 4<br>ERR_SOCKET_OPERATION = 5<br>ERR_FILE_NOT_FOUND = 6<br>ERR_INVALID_JSON = 7<br><br># Global vars<br>debug_enabled = True<br>timeout = 10<br>retries = 3<br>pwd = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))<br>json_alert = {}<br><br># Log and socket path<br>LOG_FILE = f&#39;{pwd}/logs/integrations.log&#39;<br>SOCKET_ADDR = f&#39;{pwd}/queue/sockets/queue&#39;<br><br># Constants<br>ALERT_INDEX = 1<br>APIKEY_INDEX = 2<br>TIMEOUT_INDEX = 6<br>RETRIES_INDEX = 7<br>YETI_INSTANCE = &#39;http://192.168.56.1&#39;<br><br>def debug(msg: str) -&gt; None:<br>    &quot;&quot;&quot;Log the message in the log file with the timestamp, if debug flag<br>    is enabled.&quot;&quot;&quot;<br>    if debug_enabled:<br>        print(msg)<br>        with open(LOG_FILE, &#39;a&#39;) as f:<br>            f.write(msg + &#39;\n&#39;)<br><br>def main(args):<br>    global debug_enabled<br>    global timeout<br>    global retries<br>    try:<br>        # Read arguments<br>        bad_arguments: bool = False<br>        msg = &#39;&#39;<br>        if len(args) &gt;= 4:<br>            debug_enabled = len(args) &gt; 4 and args[4] == &#39;debug&#39;<br>            if len(args) &gt; TIMEOUT_INDEX:<br>                timeout = int(args[TIMEOUT_INDEX])<br>            if len(args) &gt; RETRIES_INDEX:<br>                retries = int(args[RETRIES_INDEX])<br>        else:<br>            msg = &#39;# Error: Wrong arguments\n&#39;<br>            bad_arguments = True<br><br>        # Logging the call<br>        with open(LOG_FILE, &#39;a&#39;) as f:<br>            f.write(msg)<br><br>        if bad_arguments:<br>            debug(&#39;# Error: Exiting, bad arguments. Inputted: %s&#39; % args)<br>            sys.exit(ERR_BAD_ARGUMENTS)<br><br>        # Read args<br>        apikey: str = args[APIKEY_INDEX]<br><br>        # Obtain the access token<br>        access_token = getAccessToken(apikey)<br><br>        # Core function<br>        process_args(args, access_token)<br><br><br>    except Exception as e:<br>        debug(str(e))<br>        raise<br><br>def getAccessToken(apikey):<br>    &quot;&quot;&quot;Exchange API key for a JWT access token.&quot;&quot;&quot;<br><br>    url = f&quot;{YETI_INSTANCE}/api/v2/auth/api-token&quot;<br>    headers = {&quot;x-yeti-apikey&quot;: apikey}<br>    try:<br>        response = requests.post(url, headers=headers)<br>        response.raise_for_status()<br>        access_token = response.json().get(&quot;access_token&quot;)<br>        if not access_token:<br>            raise ValueError(&quot;Access token missing in the response.&quot;)<br>        return access_token<br>    except requests.exceptions.RequestException as e:<br>        debug(f&quot;Error obtaining access token from API: {e}&quot;)<br>        sys.exit(1)<br><br>def process_args(args, access_token: str) -&gt; None:<br>    &quot;&quot;&quot;This is the core function, creates a message with all valid fields<br>    and overwrite or add with the optional fields.&quot;&quot;&quot;<br>    debug(&#39;# Running Yeti script&#39;)<br><br>    # Read args<br>    alert_file_location: str = args[ALERT_INDEX]<br><br>    # Load alert. Parse JSON object.<br>    json_alert = get_json_alert(alert_file_location)<br>    debug(f&quot;# Opening alert file at &#39;{alert_file_location}&#39; with &#39;{json_alert}&#39;&quot;)<br><br>    # Determine the type of alert and process accordingly<br>    if &#39;data&#39; in json_alert and (&#39;sshd&#39; in json_alert or &#39;srcip&#39; in json_alert[&#39;data&#39;]):<br>        debug(&#39;# Detected an SSH-related alert&#39;)<br>        msg: any = request_ssh_info(json_alert, access_token)<br><br>    elif &#39;syscheck&#39; in json_alert or &#39;md5_after&#39; in json_alert[&#39;syscheck&#39;]:<br>        debug(&#39;# Detected a file integrity alert (MD5 check)&#39;)<br>        msg: any = request_md5_info(json_alert, access_token)<br><br>    else:<br>        debug(&#39;# Alert does not match known types (SSH or MD5). Skipping processing.&#39;)<br>        return None<br><br>    # If a valid message is generated, send it<br>    if msg:<br>        send_msg(msg, json_alert[&#39;agent&#39;])<br>    else:<br>        debug(&#39;# No valid message generated. Skipping sending.&#39;)<br><br>def get_json_alert(file_location: str) -&gt; any:<br>    &quot;&quot;&quot;Read JSON alert object from file.&quot;&quot;&quot;<br>    try:<br>        with open(file_location) as alert_file:<br>            return json.load(alert_file)<br>    except FileNotFoundError:<br>        debug(&quot;# JSON file for alert %s doesn&#39;t exist&quot; % file_location)<br>        sys.exit(ERR_FILE_NOT_FOUND)<br>    except json.decoder.JSONDecodeError as e:<br>        debug(&#39;Failed getting JSON alert. Error: %s&#39; % e)<br>        sys.exit(ERR_INVALID_JSON)<br><br>def request_ssh_info(alert: any, access_token: str):<br>    &quot;&quot;&quot;Generate the JSON object with the message to be send.&quot;&quot;&quot;<br>    alert_output = {&#39;yeti&#39;: {}, &#39;integration&#39;: &#39;yeti&#39;}<br><br>    # Extract source IP<br>    src_ip = alert[&#39;data&#39;][&#39;srcip&#39;]<br><br>    # Inline validation of the source IP<br>    if not isinstance(src_ip, str):<br>        debug(f&quot;# Invalid src_ip: &#39;{src_ip}&#39; is not a string&quot;)<br>        return None<br><br>    octets = src_ip.split(&#39;.&#39;)<br>    if len(octets) != 4 or not all(octet.isdigit() for octet in octets):<br>        debug(f&quot;# Invalid src_ip format: &#39;{src_ip}&#39;&quot;)<br>        return None<br><br>    octets = list(map(int, octets))<br>    if (<br>        any(octet &lt; 0 or octet &gt; 255 for octet in octets) or  # Octet range validation<br>        octets[0] in [10, 127] or  # Exclude private (10.x.x.x) and loopback (127.x.x.x)<br>        (octets[0] == 192 and octets[1] == 168) or  # Exclude private (192.168.x.x)<br>        (octets[0] == 172 and 16 &lt;= octets[1] &lt;= 31) or  # Exclude private (172.16.x.x to 172.31.x.x)<br>        octets[0] &gt;= 240  # Exclude reserved and invalid ranges (240.x.x.x and above)<br>    ):<br>        debug(f&quot;# Invalid src_ip: &#39;{src_ip}&#39; is private, reserved, or out of range&quot;)<br>        return None<br><br>    # Request info using Yeti API<br>    yeti_response_data = request_info_from_api(alert_output, access_token, src_ip)<br><br>    if not yeti_response_data:<br>        debug(&quot;No data returned from the Yeti API.&quot;)<br>        return None<br>   <br>    alert_output[&#39;yeti&#39;][&#39;source&#39;] = {<br>        &#39;alert_id&#39;: alert[&#39;id&#39;],<br>        &#39;src_ip&#39;: alert[&#39;data&#39;][&#39;srcip&#39;],<br>        &#39;src_port&#39;: alert[&#39;data&#39;][&#39;srcport&#39;],<br>        &#39;dst_user&#39;: alert[&#39;data&#39;][&#39;dstuser&#39;],<br>    }<br><br>    # Check if Yeti has any info about the source IP<br>    &quot;&quot;&quot;Filter YETI results for entries with source &#39;AlienVaultIPReputation&#39;.&quot;&quot;&quot;<br>    if not yeti_response_data:<br>        debug(&quot;No data returned from the YETI API.&quot;)<br>        return None<br><br>    observables = yeti_response_data.get(&#39;observables&#39;, [])<br>    for observable in observables:<br>        if isinstance(observable, dict):  # Ensure observable is a dictionary<br>            for context_entry in observable.get(&quot;context&quot;, []):<br>                if context_entry.get(&quot;source&quot;) == &quot;AlienVaultIPReputation&quot;:<br>                    observable_value = observable.get(&quot;value&quot;)<br>                    if observable_value == src_ip:<br>                        alert_output[&#39;yeti&#39;].update(<br>                            {<br>                            &#39;info&#39;: {<br>                                &#39;country_code&#39;: context_entry.get(&quot;country&quot;),<br>                                &#39;threat&#39;: context_entry.get(&quot;threat&quot;),<br>                                &#39;reliability&#39;: context_entry.get(&quot;reliability&quot;),<br>                                &#39;risk&#39;: context_entry.get(&quot;risk&quot;),<br>                                &#39;source&#39;: &quot;AlienVaultIPReputation&quot;,<br>                                }<br>                            }<br>                        )<br>                        return alert_output<br>        else:<br>            debug(f&quot;Invalid observable format: {observable}&quot;)<br><br>    debug(f&quot;No matching IP address &#39;{src_ip}&#39; found in YETI API for source &#39;AlienVaultIPReputation&#39;.&quot;)<br>    return None<br><br>def request_md5_info(alert: any, access_token: str):<br>    &quot;&quot;&quot;Generate the JSON object with the message to be send.&quot;&quot;&quot;<br>    alert_output = {&#39;yeti&#39;: {}, &#39;integration&#39;: &#39;yeti&#39;}<br><br>    # Extract MD5 hash<br>    md5_hash = alert[&#39;syscheck&#39;][&#39;md5_after&#39;]<br><br>    # Validate MD5 hash<br>    if not isinstance(alert[&#39;syscheck&#39;][&#39;md5_after&#39;], str) or len(re.findall(r&#39;\b([a-f\d]{32}|[A-F\d]{32})\b&#39;, alert[&#39;syscheck&#39;][&#39;md5_after&#39;])) != 1:<br>        debug(f&quot;# Invalid md5_after value: &#39;{alert[&#39;syscheck&#39;][&#39;md5_after&#39;]}&#39;&quot;)<br>        return None<br><br>    # Request info using Yeti API<br>    yeti_response_data = request_info_from_api(alert_output, access_token, md5_hash)<br><br>    if not yeti_response_data:<br>        debug(&quot;No data returned from the Yeti API.&quot;)<br>        return None<br>   <br>    alert_output[&#39;yeti&#39;][&#39;source&#39;] = {<br>        &#39;alert_id&#39;: alert[&#39;id&#39;],<br>        &#39;file&#39;: alert[&#39;syscheck&#39;][&#39;path&#39;],<br>        &#39;md5&#39;: alert[&#39;syscheck&#39;][&#39;md5_after&#39;],<br>        &#39;sha1&#39;: alert[&#39;syscheck&#39;][&#39;sha1_after&#39;],<br>    }<br><br>    # Check if Yeti has any info about the hash<br>    &quot;&quot;&quot;Filter YETI results for entries with source &#39;AbuseCHMalwareBazaaar&#39;.&quot;&quot;&quot;<br>    if not yeti_response_data:<br>        debug(&quot;No data returned from the YETI API.&quot;)<br>        return None<br><br>    observables = yeti_response_data.get(&#39;observables&#39;, [])<br>    for observable in observables:<br>        if isinstance(observable, dict):  # Ensure observable is a dictionary<br>            for context_entry in observable.get(&quot;context&quot;, []):<br>                if context_entry.get(&quot;source&quot;) == &quot;AbuseCHMalwareBazaaar&quot;:<br>                    observable_value = observable.get(&quot;value&quot;)<br>                    if observable_value == md5_hash:<br>                        alert_output[&#39;yeti&#39;].update(<br>                            {<br>                            &#39;info&#39;: {<br>                                &#39;country_code&#39;: context_entry.get(&quot;country&quot;),<br>                                &#39;threat&#39;: context_entry.get(&quot;threat&quot;),<br>                                &#39;reliability&#39;: context_entry.get(&quot;reliability&quot;),<br>                                &#39;risk&#39;: context_entry.get(&quot;risk&quot;),<br>                                &#39;source&#39;: &quot;AbuseCHMalwareBazaaar&quot;,<br>                                }<br>                            }<br>                        )<br>                        return alert_output<br>        else:<br>            debug(f&quot;Invalid observable format: {observable}&quot;)<br><br>    debug(f&quot;No matching IP address &#39;{md5_hash}&#39; found in YETI API for source &#39;AbuseCHMalwareBazaaar&#39;.&quot;)<br>    return None<br><br><br>def request_info_from_api(alert_output, access_token, src_ip):<br>    &quot;&quot;&quot;Request information from Yeti API.&quot;&quot;&quot;<br>    for attempt in range(retries + 1):<br>        try:<br>            yeti_response_data = query_api(src_ip, access_token)<br>            return yeti_response_data<br>        except Timeout:<br>            debug(&#39;# Error: Request timed out. Remaining retries: %s&#39; % (retries - attempt))<br>            continue<br>        except Exception as e:<br>            debug(str(e))<br>            sys.exit(ERR_NO_RESPONSE_YETI)<br><br>    debug(&#39;# Error: Request timed out and maximum number of retries was exceeded&#39;)<br>    alert_output[&#39;yeti&#39;][&#39;error&#39;] = 408<br>    alert_output[&#39;yeti&#39;][&#39;description&#39;] = &#39;Error: API request timed out&#39;<br>    send_msg(alert_output)<br>    sys.exit(ERR_NO_RESPONSE_YETI)<br><br>def query_api(src_ip, access_token: str) -&gt; any:<br>    &quot;&quot;&quot;Query the API for observables.&quot;&quot;&quot;<br>    headers = {<br>        &quot;Authorization&quot;: f&quot;Bearer {access_token}&quot;,<br>        &quot;Content-Type&quot;: &quot;application/json&quot;<br>    }<br>    data = json.dumps({<br>        &quot;page&quot;: 0,<br>        &quot;count&quot;: 25,<br>        &quot;query&quot;: {&quot;value&quot;: src_ip},<br>        &quot;sorting&quot;: [[&quot;created&quot;, False]]<br>    })<br>    debug(&#39;# Querying Yeti API&#39;)<br>    response = requests.post(<br>        f&#39;{YETI_INSTANCE}/api/v2/observables/search&#39;, headers=headers, data=data, timeout=timeout<br>    )<br>    if response.status_code == 200:<br>        return response.json()<br>    else:<br>        handle_api_error(response.status_code)<br><br>def handle_api_error(status_code):<br>    &quot;&quot;&quot;Handle errors from the Yeti API.&quot;&quot;&quot;<br>    alert_output = {}<br>    alert_output[&#39;yeti&#39;] = {}<br>    alert_output[&#39;integration&#39;] = &#39;yeti&#39;<br><br>    if status_code == 401:<br>        alert_output[&#39;yeti&#39;][&#39;error&#39;] = status_code<br>        alert_output[&#39;yeti&#39;][&#39;description&#39;] = &#39;Error: Unauthorized. Check your API key.&#39;<br>        send_msg(alert_output)<br>        raise Exception(&#39;# Error: Yeti credentials, required privileges error&#39;)<br>    elif status_code == 404:<br>        alert_output[&#39;yeti&#39;][&#39;error&#39;] = status_code<br>        alert_output[&#39;yeti&#39;][&#39;description&#39;] = &#39;Error: Resource not found.&#39;<br>    elif status_code == 500:<br>        alert_output[&#39;yeti&#39;][&#39;error&#39;] = status_code<br>        alert_output[&#39;yeti&#39;][&#39;description&#39;] = &#39;Error: Internal server error.&#39;<br>    else:<br>        alert_output[&#39;yeti&#39;][&#39;error&#39;] = status_code<br>        alert_output[&#39;yeti&#39;][&#39;description&#39;] = &#39;Error: API request failed.&#39;<br><br>    send_msg(alert_output)<br>    raise Exception(f&#39;# Error: Yeti API request failed with status code {status_code}&#39;)<br><br>def send_msg(msg: any, agent: any = None) -&gt; None:<br>    if not agent or agent[&#39;id&#39;] == &#39;000&#39;:<br>        string = &#39;1:yeti:{0}&#39;.format(json.dumps(msg))<br>    else:<br>        location = &#39;[{0}] ({1}) {2}&#39;.format(agent[&#39;id&#39;], agent[&#39;name&#39;], agent[&#39;ip&#39;] if &#39;ip&#39; in agent else &#39;any&#39;)<br>        location = location.replace(&#39;|&#39;, &#39;||&#39;).replace(&#39;:&#39;, &#39;|:&#39;)<br>        string = &#39;1:{0}-&gt;yeti:{1}&#39;.format(location, json.dumps(msg))<br><br>    debug(&#39;# Request result from Yeti server: %s&#39; % string)<br>    try:<br>        sock = socket(AF_UNIX, SOCK_DGRAM)<br>        sock.connect(SOCKET_ADDR)<br>        sock.send(string.encode())<br>        sock.close()<br>    except FileNotFoundError:<br>        debug(&#39;# Error: Unable to open socket connection at %s&#39; % SOCKET_ADDR)<br>        sys.exit(ERR_SOCKET_OPERATION)<br><br>if __name__ == &#39;__main__&#39;:<br>    main(sys.argv)<br> </pre><p>Then run:</p><pre>chmod 750 /var/ossec/integrations/custom-yeti.py<br>chown root:wazuh /var/ossec/integrations/custom-yeti.py</pre><h3>b) Register the integration</h3><p>In /var/ossec/etc/ossec.conf, add inside &lt;ossec_config&gt;:</p><pre>&lt;integration&gt;<br>  &lt;name&gt;custom-yeti.py&lt;/name&gt;<br>  &lt;api_key&gt;&lt;YETI_API_KEY&gt;&lt;/api_key&gt;<br>  &lt;group&gt;syscheck,sshd,ids&lt;/group&gt;<br>  &lt;alert_format&gt;json&lt;/alert_format&gt;<br>&lt;/integration&gt;</pre><h3>c) Define alert rules</h3><p>Create /var/ossec/etc/rules/yeti_rules.xml with:</p><pre>&lt;group name=&quot;yeti,&quot;&gt;<br>  &lt;rule id=&quot;100500&quot; level=&quot;0&quot;&gt;<br>    &lt;decoded_as&gt;json&lt;/decoded_as&gt;<br>    &lt;field name=&quot;integration&quot;&gt;yeti&lt;/field&gt;<br>    &lt;description&gt;yeti integration messages.&lt;/description&gt;<br>    &lt;options&gt;no_full_log&lt;/options&gt;<br>  &lt;/rule&gt;<br>  &lt;rule id=&quot;100501&quot; level=&quot;12&quot;&gt;<br>    &lt;if_sid&gt;100500&lt;/if_sid&gt;<br>    &lt;field name=&quot;yeti.info.source&quot;&gt;AbuseCHMalwareBazaaar&lt;/field&gt;<br>    &lt;description&gt;&quot;Yeti Alert - &quot; $(yeti.info.source) detected this file: $(yeti.source.file)&lt;/description&gt;<br>    &lt;group&gt;pci_dss_10.6.1,pci_dss_11.4,gdpr_IV_35.7.d,&lt;/group&gt;<br>    &lt;options&gt;no_full_log&lt;/options&gt;<br>    &lt;mitre&gt;<br>      &lt;id&gt;T1203&lt;/id&gt;<br>    &lt;/mitre&gt;<br>  &lt;/rule&gt;<br>  &lt;rule id=&quot;100502&quot; level=&quot;12&quot;&gt;<br>    &lt;if_sid&gt;100500&lt;/if_sid&gt;<br>    &lt;field name=&quot;yeti.info.source&quot;&gt;AlienVaultIPReputation&lt;/field&gt;<br>    &lt;description&gt;&quot;Yeti Alert - &quot; $(yeti.info.source) detected IP address: $(yeti.source.src_ip)&lt;/description&gt;<br>    &lt;group&gt;pci_dss_10.2.4,pci_dss_10.2.5,&lt;/group&gt;<br>    &lt;options&gt;no_full_log&lt;/options&gt;<br>  &lt;/rule&gt;<br>&lt;/group&gt;</pre><p>Restart the manager:</p><pre>systemctl restart wazuh-manager</pre><h3>3. Configure Your Ubuntu Endpoint</h3><p><strong>Malware (FIM) use case</strong><br> In /var/ossec/etc/ossec.conf under &lt;syscheck&gt;:</p><pre>&lt;directories realtime=&quot;yes&quot;&gt;/home/&lt;USER_NAME&gt;&lt;/directories&gt;</pre><p><strong>IP reputation use case</strong></p><pre>touch /var/log/test.log</pre><p>In /var/ossec/etc/ossec.conf under &lt;ossec_config&gt;:</p><pre>&lt;localfile&gt;<br>  &lt;log_format&gt;syslog&lt;/log_format&gt;<br>  &lt;location&gt;/var/log/test.log&lt;/location&gt;<br>&lt;/localfile&gt;</pre><pre>systemctl restart wazuh-agent</pre><h3>4. Verify Your Integration</h3><p><strong>Malware detection</strong><br> Place known MalwareBazaar samples into your home directory.</p><p><strong>IP reputation</strong></p><pre>echo &quot;Jan 25 10:05:30 ubuntu sshd[3434]: Accepted password for aonymous from 61.0.168.149 port 55094 ssh2&quot; &gt;&gt; /var/log/test.log<br>echo &quot;Jan 24 04:58:38 ubuntu sshd[2788]: Failed password for anonymous from 49.143.32.6 port 54647 ssh2&quot; &gt;&gt; /var/log/test.log<br>echo &quot;Jan 24 04:58:47 ubuntu sshd[2788]: Connection reset by authenticating user anonymous 176.111.173.139 port 54647 [preauth]&quot; &gt;&gt; /var/log/test.log<br>echo &quot;Jan 24 09:49:35 ubuntu sshd[5620]: Connection reset by invalid user test 110.89.11.143 port 56739 [preauth]&quot; &gt;&gt; /var/log/test.log</pre><p>Then filter <strong>rule.groups is yeti</strong> on <strong>Wazuh Dashboard → Threat Hunting</strong>.</p><h3>5. Handling the Broken API</h3><p>As noted, Yeti’s /api/v2/observables/ endpoint currently returns <strong>405 Method Not Allowed</strong>, so the official script cannot retrieve observables. You’ll see:</p><pre># Querying Yeti API<br># Request result from Yeti server: 1:yeti:{&quot;yeti&quot;: {&quot;error&quot;: 405, &quot;description&quot;: &quot;Error: API request failed.&quot;}, &quot;integration&quot;: &quot;yeti&quot;}<br># Error: Yeti API request failed with status code 405</pre><p><strong>Immediate remedies</strong>:</p><ul><li>Watch Yeti’s CHANGELOG for updated endpoints (e.g. /api/v2/observables/search).</li><li>Temporarily patch query_api() to use the new URI.</li><li>Revert to the official path once Yeti restores support.</li></ul><p>Even when upstream changes break the guide, you now have a <strong>complete, actionable</strong> reference — ready to enrich your Wazuh alerts with CTI feeds the moment Yeti’s API is back online. Happy threat hunting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5834fab6bc70" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing Secure Access in the Cloud: A Comparative Study of GCP and AWS IAM Solutions]]></title>
            <link>https://medium.com/@ddigvijay/managing-secure-access-in-the-cloud-a-comparative-study-of-gcp-and-aws-iam-solutions-5c222c841823?source=rss-bd4bfddba65------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c222c841823</guid>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[cloud-security]]></category>
            <dc:creator><![CDATA[Digvijay]]></dc:creator>
            <pubDate>Wed, 26 Jul 2023 14:50:32 GMT</pubDate>
            <atom:updated>2023-07-26T14:53:13.236Z</atom:updated>
            <content:encoded><![CDATA[<p>Identity and Access Management (IAM) are fundamental aspects of any cloud infrastructure. They allow you to control who has access to your resources and what they can do with those resources. In this article, we’ll delve into the IAM services provided by two of the largest cloud providers: Amazon Web Services (AWS) and Google Cloud Platform (GCP).</p><p><strong>AWS IAM Services</strong></p><p>Amazon’s IAM is a web service that assists in securely controlling access to AWS resources. IAM enables you to create and manage AWS users and groups, and use permissions to allow and deny their access to AWS resources.</p><p><strong>Key aspects of AWS IAM include:</strong></p><ul><li><strong>Users and Groups:</strong> AWS users represent individual people or services that interact with AWS resources. Groups, meanwhile, are collections of users, allowing easier management of permissions.</li><li><strong>Roles and Policies:</strong> IAM roles are identities with specific permission policies that determine what the identity can and can’t do in AWS. IAM policies, typically stored as JSON documents, define the permissions of an identity.</li><li><strong>Security tools:</strong> AWS provides several security tools, such as MFA for enhanced security, a credential report for a snapshot of the status of various credentials, and Access Analyser, which helps identify resources shared with entities outside your AWS account.</li></ul><p><strong>GCP IAM Services</strong></p><p>Google Cloud IAM lets you manage access control by defining who (identity) has what access (role) for which resource.</p><p><strong><em>Key aspects of GCP IAM include:</em></strong></p><ul><li><strong>Resources and Members: </strong>In GCP, resources are individual service instances, and members can be anything from end users to service accounts.</li><li><strong>Roles and IAM Policy: </strong>Roles are collections of permissions, and the IAM policy attached to a resource specifies who has what access for that resource.</li><li><strong>Service Accounts and IAM Recommender:</strong> Service accounts are used by apps and VMs. The IAM Recommender uses machine learning to generate IAM role recommendations, ensuring the principle of least privilege.</li></ul><p><strong>Comparing AWS and GCP IAM</strong></p><p>While both AWS and GCP IAM provide secure, granular access control to resources, the services have several differences. AWS emphasises user and group management, with policies attached to identities or resources.</p><p>GCP, on the other hand, utilizes a hierarchical structure of resources, with IAM policies attached to these resources defining access control.</p><p>Moreover, GCP’s IAM Recommender offers an intelligent tool to optimize permission configurations, while AWS’s Access Analyser provides insights into resource sharing.</p><p>Both AWS and GCP IAM services have a rich set of features, with different strengths and toolsets, making each suitable for different use cases. Choosing between them often depends on the specifics of the infrastructure requirements and the cloud strategy of your organization.</p><p><strong>Conclusion</strong></p><p>As cloud infrastructures become more complex and integral to operations, secure and efficient access management is increasingly critical. Understanding the capabilities and advantages of IAM services like those provided by AWS and GCP is a key component of effective cloud management. Organizations must ensure they fully leverage these IAM features to protect their resources and optimize their cloud operations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c222c841823" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancements to the EC2 Instance Metadata Service can secure SSRF Vulnerabilities, reverse proxy…]]></title>
            <link>https://medium.com/@ddigvijay/enhancements-to-the-ec2-instance-metadata-service-can-secure-ssrf-vulnerabilities-reverse-proxy-7140ed889d6e?source=rss-bd4bfddba65------2</link>
            <guid isPermaLink="false">https://medium.com/p/7140ed889d6e</guid>
            <category><![CDATA[ssrf]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[bugbounting]]></category>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[aws-security]]></category>
            <dc:creator><![CDATA[Digvijay]]></dc:creator>
            <pubDate>Wed, 24 Jun 2020 17:41:47 GMT</pubDate>
            <atom:updated>2020-06-24T17:41:47.700Z</atom:updated>
            <content:encoded><![CDATA[<h3>Enhancements to the EC2 Instance Metadata Service can secure SSRF Vulnerabilities, reverse proxy and open firewalls</h3><h3>What is AWS IMDS:</h3><p>AWS EC2 instance metadata service (IMDS) has been in use by AWS customers for a long time, even though they don’t always realize it. IMDS provides a great deal of information about the instance and is very useful for application configuration. In this article, I would like to talk about the impact of this service on the security of the instance and how to apply mitigations, based on the new IMDSv2. I hope the content is beneficial not only to the “hands-on” security people but also for architects, operators, developers and auditors.</p><p>The Amazon EC2 Instance Metadata Service (IMDS) has helped customers build secure and scalable applications. The IMDS solved a big security headache for cloud users by providing access to temporary, frequently rotated credentials, removing the need to hardcode or distribute sensitive credentials to instances manually or programmatically. Attached locally to every EC2 instance, the IMDS runs on a special “link local” IP address of 169.254.169.254 that means only software running on the instance can access it. For applications with access to IMDS, it makes available metadata about the instance, its network, and its storage. The IMDS also makes the AWS credentials available for any IAM role that is attached to the instance.</p><p>When you run applications in the cloud, application security is as critical as instance security; if the applications running on an instance have vulnerabilities or misconfigurations, there can be serious consequences. While application security plays an important role in a layered defense.</p><h3>What is SSRF:</h3><p>Server-side request forgery (also known as SSRF) is a web security vulnerability that allows an attacker to induce the server-side application to make HTTP requests to an arbitrary domain of the attacker’s choosing.</p><p>In typical SSRF examples, the attacker might cause the server to make a connection back to itself, or to other web-based services within the organisation’s infrastructure, or to external third-party systems.</p><p>Server Side Request Forgery can be an extremely lucrative finding to an attacker because of the ability to make requests from the target machine. When discovered on a cloud instance, things get a little more interesting as attackers can access the metadata instance, available via an API, range IP address over HTTP — <a href="http://169.254.169.254/,"><strong><em>http://169.254.169.254/</em></strong>,</a> and accessible only from the target.</p><p>For AWS this has always been a cause for concern as there was no authentication present to access this instance, and no requirement for a custom header that both GCP and Azure have.</p><p><a href="https://gist.github.com/jhaddix/78cece26c91c6263653f31ba453e273b"><strong><em>https://gist.github.com/jhaddix/78cece26c91c6263653f31ba453e273b</em></strong></a></p><p>An attacker could then impersonate the role attached to the machine using the temporary credentials and do additional discovery or damage.</p><h3>POC:</h3><ol><li>I found a punch out Url feature and tried to check for SSRF or OOB SSRF but didn’t work properly, by using my own collaborator service.</li><li>After some recon, i found out that the application is hosted on AWS cloud.</li><li>I quickly browse AWS MetaData URL i.e. “<strong><em>http://169.254.169.254/latest/user-data</em></strong>”</li><li>After using the AWS metadata URL, i was completely shocked with the results as i am able to read ssh, AMI snapshots and many more things.</li><li>Now, I was able to exfiltrate all the data and local files presents inside the server.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tt7Yooct6KZYh0kv" /><figcaption>Fig-1: Leaking Secrets through AWS IMDSv1</figcaption></figure><h4>IMDSv2 to the rescue!</h4><p>The <a href="https://aws.amazon.com/blogs/security/defense-in-depth-open-firewalls-reverse-proxies-ssrf-vulnerabilities-ec2-instance-metadata-service/">main blog post by AWS </a>regarding IMDSv2 explains it in great detail, so I will discuss the additional security measures in brief:</p><ul><li>With IMDSv2, you must obtain a token by performing a PUT request and this is not possible to achieve in most cases remotely.</li><li>When passing through a proxy, a header called X-Forwarded-For is usually added. If IMDSv2 detects this header, it will not respond to the request.</li><li>The instance contacts the metadata service directly, i.e. using a single network hop. If the request originates remotely, such as with a remote attack over the network, the number of hops will likely be greater. The default number of hops IMDSv2 is configured with is 1 (single hop), meaning that the packet will be dropped on the way and will not reach the attacker.</li></ul><h3>How to Enable IMDSv2 and Mitigations</h3><p>it is important to understand that if you do nothing, both IMDSv1 and IMDSv2 are available to the instance. Meaning, just having access to IMDSv2 does not improve your security posture; you must actively disable IMDSv1!</p><ol><li>Make sure your SDK / any type of software client you use on the instance is capable of supporting IMDSv2. If it is, the software client will continue to work using IMDSv2 with no issues. Do not underestimate the importance of IMDSv1! Since enabling the CloudWatch+Lambda automatic solution to disable IMDSv1, I have seen many cases of various 3rd party scripts and agents that are broken by disabling IMDSv1. Literally anything coming from the AWS marketplace and having some interaction with AWS or IMDS data sources have been broken by automatically disabling IMDSv1. So again, make sure that you test this thoroughly before broadly disabling IMDSv1 in your accounts, update your operational teams of the possible consequences and have an exception model in place. I use a specific “exception” tag so that if the Lambda is detecting an instance launch and the instance have IMDSv1 enabled, the first thing it will check if there is an “exception” tag present; if the answer is “yes”, this instance is skipped from IMDS configuration and an appropriate event is written to a CloudWatch log.</li><li>If your applications or scripts extract credentials from the instance metadata as I described in the intro, make sure they are updated to use the access token.</li><li>Currently, there is no possibility to automatically disable IMDSv1 on instances at their creation — account-wide. If you would like this to be enforced, you need to take action — as described later in this article.</li><li>AWS has added the possibility to select the IMDS version during instance launch in the AWS Console. It is near the user data selection, in the “Advanced Details” section of the “Configure Instance” screen.</li><li>An additional consideration point is that in many cases new instances are created automatically via Auto Scaling groups (ASGs). Currently, launch templates support IMDS version configuration during launch while launch configurations do not support the instance metadata parameter.</li></ol><h3>Detection by Monitoring using AWS services:</h3><p>AWS has created a dedicated CloudWatch instance metric called “MetadataNoToken”. It can be monitored to detect instances making calls to the instance metadata service without the IMDSv2 token. Once detected, you can locate the software responsible for these calls and update it to use IMDSv2.</p><p>If you have finished your transition phase and would like to find out if you still have instances not configured with IMDSv2 only, you can perform a DescribeInstances call in each region and check the “MetadataOptions/HttpTokens” field in the instance metadata from a management station.</p><p><strong><em>Note: IMDSv2 not only prevents SSRF vulnerabilities but also provides defense in depth against open firewalls, reverse proxies, and protection against open layer 3 firewalls and NATs.</em></strong></p><h4><strong><em>References:</em></strong></h4><p><a href="https://aws.amazon.com/blogs/security/defense-in-depth-open-firewalls-reverse-proxies-ssrf-vulnerabilities-ec2-instance-metadata-service/"><strong><em>https://aws.amazon.com/blogs/security/defense-in-depth-open-firewalls-reverse-proxies-ssrf-vulnerabilities-ec2-instance-metadata-service/</em></strong></a></p><p><a href="https://duo.com/decipher/aws-adds-new-protections-against-ssrf-other-web-app-attacks"><strong><em>https://duo.com/decipher/aws-adds-new-protections-against-ssrf-other-web-app-attacks</em></strong></a></p><p><a href="https://portswigger.net/daily-swig/aws-bolsters-security-to-defend-against-ssrf-attacks"><strong><em>https://portswigger.net/daily-swig/aws-bolsters-security-to-defend-against-ssrf-attacks</em></strong></a></p><p><a href="https://blog.appsecco.com/an-ssrf-privileged-aws-keys-and-the-capital-one-breach-4c3c2cded3af"><strong><em>https://blog.appsecco.com/an-ssrf-privileged-aws-keys-and-the-capital-one-breach-4c3c2cded3af</em></strong></a></p><p><strong>Disclaimer:</strong></p><p>The views and opinions expressed in this blog are those of the author and do not represent the opinions of any entity whatsoever with which I have been, am now or will be affiliated.</p><p><strong>Authors Bio:</strong></p><p>Digvijay Singh, is a Cybersecurity expert who is engaged in vulnerability assessments for various organisations. An avid WhiteHat Ethical Hacker who is always helping enterprise to protect its information systems and data. His expertises include Threat Modelling, Secure Code Review, Security Architecture and Penetration Testing. He is also Security Advisor for <a href="https://www.linkedin.com/company/cyberlogue/">Cyberlogue</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7140ed889d6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>