<?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 Dylan on Medium]]></title>
        <description><![CDATA[Stories by Dylan on Medium]]></description>
        <link>https://medium.com/@dylanhwilliams?source=rss-d501563f598b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EIAF3Usyn6JQKMXQa1kRBg.jpeg</url>
            <title>Stories by Dylan on Medium</title>
            <link>https://medium.com/@dylanhwilliams?source=rss-d501563f598b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 05:15:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dylanhwilliams/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[What Makes a“Good” Detection?]]></title>
            <link>https://medium.com/@dylanhwilliams/what-makes-a-good-detection-dd6a3b373860?source=rss-d501563f598b------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd6a3b373860</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[detection-engineering]]></category>
            <category><![CDATA[security-operations]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[threat-detection]]></category>
            <dc:creator><![CDATA[Dylan]]></dc:creator>
            <pubDate>Thu, 10 Oct 2024 16:28:12 GMT</pubDate>
            <atom:updated>2024-11-12T16:12:17.494Z</atom:updated>
            <content:encoded><![CDATA[<h3>What Makes a “Good” Detection?</h3><h4>The Shannon Signal Score: A Framework for Measuring Detection Value</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HFtFGIVKjLoMBgzh5AQz8Q.png" /><figcaption>This may be a good start?</figcaption></figure><p>What inspired me to go deep on this was when I was creating evaluations for <a href="https://github.com/dwillowtree/diana/tree/main">DIANA</a>, I needed a way to measure the quality of a detection. I encountered the same problem many other engineers working on LLM applications do: how can we evaluate the output of an AI system for a domain-specific use case without humans? Well, its a very hard and existing problem, and if you want to use humans its very time consuming and labor intensive. So after spending time coming up with the criteria to measure the <em>quality or value </em>of detections created by LLMs, I thought well..what even makes a “good” detection in the first place?</p><p>If you want to read about the experiment that started this, you can check it out below.</p><p><a href="https://medium.com/@dylanhwilliams/utilizing-generative-ai-and-llms-to-automate-detection-writing-5e4ea074072e">Utilizing Generative AI and LLMs to Automate Detection Writing</a></p><p>You’re a threat hunter, you’re a detection engineer, you’re a SOC analyst: when you look at a detection, how do you come to the conclusion that: “oh yeah this is a good detection” or “no, this is bad”. Is the detection brittle? Narrow coverage? Focusing on elements lower on the <a href="https://detect-respond.blogspot.com/2013/03/the-pyramid-of-pain.html">pyramid of pain</a>? Another way of putting it: Is it resilient over time? Resistant to changes in attack behavior? Results in too much noise in my environment? Incurs too much labor cost? Is it threat-oriented? From internal threat-model or public threat intel? Whats the prevalence or chokepoint of the threat? Is it actionable? Reflects insightful risk and impact at my organization? Based on my unique environment, crown jewels, etc.?</p><p>You might even have bias when looking at a detection too. How would two different people measure the quality of a detection, based on the number of times they’ve seen it and how long they’ve been at an organization. You may find certain attack surfaces or techniques more exciting, or you come from a linux sysadmin background so you’re way more experienced with that telemetry. Point being, measuring the quality of detection is a mixture of subjectivity and objectivity.</p><p>This is really hard to measure, especially in a quantifiable metric right? But what this made me understand is: you need to have visibility, context, and understanding of the whole journey from threat intel to detection to alert triage and response. And at a lot of organizations, these functions are siloed. A threat hunter or detection engineer may use different criteria for what they consider a “good” detection vs the SOC analysts. So how can we bring this all together to give us the most comprehensive picture of how <em>good</em> a detection is for <em>you?</em></p><p>If I had to pin it down to one thing, its can we get the <em>clearest picture</em> of <em>this</em> in as close to real-time as possible? <em>This</em> being the shaded portion of the diagram below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/0*Re79bXWimMl_XXCK" /><figcaption>This comes from my LinkedIn post <a href="https://www.linkedin.com/posts/dylan-williams-a2927599_threat-informed-defense-threat-informed-activity-7237828767862124544-2HdU?utm_source=share&amp;utm_medium=member_desktop">here</a>.</figcaption></figure><p>Remember back to the <a href="https://holisticinfosec.blogspot.com/2016/12/the-dfir-hierarchy-of-needs-critical.html">DFIR hierarchy</a>, the highest form of detection maturity is “can you operate at the same tempo as your adversary”? We really can’t go beyond that right? So how do we get there? Lets start theoretically and see if we can bring it back to the real world.</p><p>This ties threat hunting, detection engineering, threat modeling, and attack surface all together with the goal of finding two things:</p><ol><li>whats the exhaustive, all-encompassing list of every possible threat that can affect <em>my organization</em> in near real-time</li><li>what percentage of these can I detect in near real-time, all the time</li></ol><p>Put another way: whats my exploitable attack surface, and how much of it can I detect?</p><p>So if we think about it, the detection holy grail is: I can detect all of my exploitable attack surface, all the time.</p><p>So one part that goes into creating a “good” detection is: how well does it contribute to detecting my exploitable attack surface? For example, someone may ask whats the ROI on this signal, and we could say “it contributes meaningfully to detecting my exploitable attack surface” because of XYZ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cCxdeH3VNVAGiwVQC6DZlg.png" /><figcaption>DFIR Hierarchy Made by DALLE</figcaption></figure><p>And I know what you’re thinking, we can’t possibly figure out every possible threat, we know there are basically infinite variations of a technique. And we know its not practical to detect 100% of threats, 100% of the time. Enterprises are large and complex, controls will fail, environments will change, threats will change, and systems will drift. Think of the sheer number of variations of TTPs in Mitre ATT&amp;CK, all the possible combinations, all the possible routes an attacker could take. As defenders we will always suffer from the “aperture dilemma” Zack Allen refers to in <a href="https://www.datadoghq.com/blog/building-security-coverage-for-cloud-environments/">this blog</a>. Another way to think about it is the <a href="https://www.theuncertaintyproject.org/tools/rumsfeld-matrix">Rumsfeld Quadrant</a> a lot of threat hunters use to hypothesize detection ideas. But if it were possible to figure out every possible threat or something close to it, what would this look like in real life?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/0*kE16dYB_H7x3dkcY" /><figcaption><a href="https://www.theuncertaintyproject.org/tools/rumsfeld-matrix">Rumsfeld Quadrant</a></figcaption></figure><p>Its almost like having a red team everywhere, all the time, trying everything. This would give a <em>real-time picture of your exploitable attack surface.</em> To bring it back to the world of detection: now we know every possible <em>thing</em> we can create a signal for. So to bring it back to reality, we may not be able to see every possible infinite permutation of a possible attack in real time (although maybe one day *cough AI agents), <em>but</em> the whole point I’m emphasizing here is: if we use our Venn diagram from earlier to narrow that crazy list of every possible threat down to <em>ones that are most likely to affect me</em>, maybe thats manageable, or at least a step in the right direction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*cGmwS7CJPtiTELASItK6Gw.png" /><figcaption>How much of this can I detect? How well can I do this? With 100 detections, 1,000? With 2 people, 200?</figcaption></figure><p>So that will segue into our first criteria/metric for detection quality, which is all about threats. Because without threats, we don’t have detections! Then we can expand this to stuff like..well how is the detection written, executed, resilient over time, reflective of the data source, easy to understand, etc.</p><p>But before we get started.. if you read my stuff, you know you wont get to leave without a mention of LLMs and whether that can play a part here. And I think it can, because a big part of LLMs is the encoding/expression of human knowledge. So if you, a subject matter expert, can look at a detection and <em>evaluate</em> it according to information you’re given (context) and your own knowledge/expertise, we can also substitute this evaluation with an LLM. If you can take the criteria you use in your head and put that down on paper and articulate it, then its worth a try to see if an LLM can do it. And thats exactly what I did with <a href="https://github.com/dwillowtree/diana">DIANA</a>.</p><p>Its up to us as the human experts, to sit down and carve out all the dimensions for what we consider is “good” and then we can start using that as something to measure against.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*KxLJazzMsN3umz6WajKFOQ.gif" /><figcaption>Control the weights based on whats more important to you. Maybe this is better?</figcaption></figure><p>The real power from LLMs here is 1) for the measurements that are harder to quantify or articulate in numbers and 2) to do that qualitative measurement at scale. So at the end we’ll take a look at this list I’ve come up with below and mark which ones we may be able to use LLMs to measure, and which ones we can deterministically put a number on through other means. Don’t overthink this, this is more or less the same methodology a teacher or professors uses to give you an A- on that essay, its dependent on two things: the rubric and the person.</p><p>So heres my first shot at a formula for measuring detection quality. This framework provides a structured approach to evaluating the value of detections. It combines deterministic metrics and subjective assessments (which LLMs will do for us at scale) to create a holistic view of detection quality. Organizations can assign weights to each category based on their specific needs and priorities.</p><p>I wanted a name that emphasizes both comprehensive evaluation and practical value. I knew <a href="https://en.wikipedia.org/wiki/Claude_Shannon">Claude Shannon</a> would be an excellent choice because 1) his work is fundamental to how we understand and quantify information, which is at the core of security detections and 2) Shannon’s work heavily involves the concept of signal-to-noise ratio, which is essentially what threat detection is all about.</p><p>The Shannon Signal Score can be calculated using a weighted sum of the category scores:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*fTKThbYPYlFCgz74RcPMeg.png" /><figcaption>Shannon Signal Score</figcaption></figure><p>Organizations can adjust the weights (W1-W5) based on their specific priorities and preferences. For the metrics we can measure quantitatively, such as precision/recall or the time it takes to investigate a false positive, we will stick to deterministic methods. For the metrics that are more qualitative, such as analytic robustness or cognitive load, we will leverage LLMs to calculate a score out of 100. I’m not gonna over-math this, remember our original goal was to come up with a <em>criteria</em> for what makes a good detection. Each category is measured and contributes to the overall score so we can try and put a number on this thats useful to your specific organization. If you want to make it more nuanced, you can go to town and use hierarchical weights for each sub-category and make it as granular as you want.</p><p>Heres a high-level overview, then you can continue to see a more in-depth description of each section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*jV4Lv2veNt9ZYvo1eLO-Ig.gif" /><figcaption>You can measure Shannon Signature Score across different attack surfaces.</figcaption></figure><h3>Shannon Signal Score:</h3><h4><strong>1. Threat Alignment &amp; Coverage</strong></h4><ul><li>Threat Intel Fidelity</li><li>Organizational Risk Context</li><li>Log Footprint &amp; Signal Potential</li><li>Attack Surface Coverage</li></ul><h4><strong>2. Detection Integrity</strong></h4><ul><li>Analytic Robustness</li><li>Detection Logic Quality</li><li>Precision and Recall</li><li>Longevity</li></ul><h4><strong>3. Operational Cost</strong></h4><ul><li>Investigation Labor Cost</li><li>Detection Labor Cost</li><li>Analytic Cost</li><li>Alert Volume</li><li>Cognitive Load</li></ul><h4><strong>4. Impact &amp; Risk Potential</strong></h4><ul><li>Impact</li><li>Risk Potential</li><li>Bias Susceptability</li></ul><h4>5. Utility</h4><ul><li>Operational Context</li><li>Actionability</li><li>Response Consistency</li></ul><h3>1. Threat Alignment &amp; Coverage</h3><p>This focuses on two things: 1) how well is the detection aligned to the threat and 2) how well is the detection covering the potential attack surface</p><p>Ask yourself whats the “maliciousness” of a detection with respect to threat intel, threat modeling, and your organizational risk profile?</p><p>How well is the detection covering the threat? Whats the ratio of signals that can be extracted from this attack surface? (<a href="https://detect.fyi/how-to-prioritize-a-detection-backlog-84a16d4cc7ae">detect.fyi</a>) So its not only “does the detection have coverage?”, its “is the coverage meaningful”?</p><h4>1.1 Threat Intel Fidelity</h4><p><strong>Description: </strong>How accurately does the detection reflect the threat its intended to detect? This is about alignment with the threat landscape. Ask yourself whats the prevalence or choke point of the threat the detection is trying to catch (<a href="https://top-attack-techniques.mitre-engenuity.org/#/methodology">Mitre</a>)? Is it an opportunistic threat vs something more theoretical/notional, how common is this actually happening in the wild? Is the detection a realistic and accurate representation of the threat intel? How so, to what degree?</p><p>How to Measure: LLM-based eval</p><h4>1.2 Organizational Risk Context</h4><p><strong>Description: </strong>Evaluate how well the detection aligns with the specific risk profile of your organization. Even if a detection is theoretically valuable, its practical utility depends on its relevance to your specific context. Think about your assets, people, processes. If I have a low footprint of Windows machines, then maybe I should care less about this, even if theres a profusion of threat intel out there on Windows.</p><p>Think of threats outside public threat intel. Does the detection align to ideas from bespoke threat modeling, crown jewel analysis, red team findings, historical incidents, internal domain expertise, stuff that is unique to you (<a href="https://github.com/threat-hunting/awesome_Threat-Hunting/blob/master/Threat%20Intelligence/Files/TaHiTI-Threat-Hunting-Methodology-whitepaper-THLink.pdf">TaHiTI</a>)?</p><p>How to Measure: LLM-based eval</p><h4>1.3 Log Footprint &amp; Signal Potential</h4><p><strong>Description:</strong> Evaluate the quality and potential of logs to generate meaningful signals for detection. Shoutout to Alex Teixeira for this great idea mentioned <a href="https://detect.fyi/how-to-prioritize-a-detection-backlog-84a16d4cc7ae">here</a>.</p><p>Think: newly adopted SaaS logs vs Windows event logs. One has been around way longer, is considerably more documented, and has a much higher volume of attacks recorded on the attack surface.</p><p>How to Measure: LLM-based eval</p><h4>1.4 Attack Surface Coverage</h4><p>How much of your attack surface is covered by the detection? Every single detection relies on one thing: logs or telemetry, security data. What are yours? Think endpoint, network, SaaS, Cloud, etc. Is the detection covering one of these or many? Is it covering just Linux, or all endpoint such as Windows and MacOS too? Is most of your attack surface Cloud &amp; SaaS? Then maybe detections have more value there then other areas.</p><p>How to Measure: % or ratio of specific attack surface to overall attack surface</p><h3>2. Detection Integrity</h3><p>I want this to convey a sense of completeness, resilience, and my personal favorite: <em>trustworthiness. </em>Colloquially: does this detection do the best job at catching this threat <em>for me</em>.</p><h4>2.1 Analytic Robustness</h4><p><strong>Description:</strong> Evaluate the resiliency and sophistication of the detection. How atomic is it? Is it catching one behavior or many? Is it just looking for the string name of a tool? Is it resistant to changes in attacker behavior? How easy or hard is it for an attacker to get around the detection?</p><p>How to Measure: LLM-based eval using my favorite: <a href="https://center-for-threat-informed-defense.github.io/summiting-the-pyramid/">summiting the pyramid</a>, which is based on <a href="https://posts.specterops.io/capability-abstraction-fbeaeeb26384">capability abstraction</a>.</p><h4>2.2 Detection Logic Quality</h4><p><strong>Description:</strong> This measures the syntax quality of the detection logic itself. Well-written, efficient logic ensures that detections run smoothly and with minimal overhead. Are you using best practices and syntax for the domain specific query language you are using in your SIEM or SDL or XDR? Here you can add stuff like compute complexity, are the operators/aggregators you are using relevant and appropriate/best for the detection logic, etc.</p><ul><li><a href="https://hurricanelabs.com/splunk-tutorials/why-you-should-never-use-leading-wildcards-in-splunk-searches/">https://hurricanelabs.com/splunk-tutorials/why-you-should-never-use-leading-wildcards-in-splunk-searches/</a></li><li><a href="https://medium.com/snowflake/implementing-schema-search-on-snowflake-b2d5ee028b42">https://medium.com/snowflake/implementing-schema-search-on-snowflake-b2d5ee028b42</a></li></ul><p>How to Measure: LLM-based eval</p><h4>2.3 Precision and Recall</h4><p><strong>Description:</strong> What are detections all about? Classifying! Statistical labeling! Thats it! We are just trying to determine whether something is evil or not. Precision measures how accurate the detection is (i.e., minimizing false positives), while recall measures how well the detection captures all relevant threats (i.e., minimizing false negatives). This balance is up to you and is sometimes difficult to find.</p><ul><li><a href="https://posts.specterops.io/detection-spectrum-198a0bfb9302">https://posts.specterops.io/detection-spectrum-198a0bfb9302</a></li><li><a href="https://www.simoncross.com/p/precision-and-recall">https://www.simoncross.com/p/precision-and-recall</a></li><li><a href="https://medium.com/@gary.j.katz/detection-engineering-metrics-building-blocks-97be4bccf27b">https://medium.com/@gary.j.katz/detection-engineering-metrics-building-blocks-97be4bccf27b</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*R6-iu0FxZXdrfper.png" /></figure><p>How to Measure:</p><ul><li>Precision: (True Positives) / (True Positives + False Positives) * 100%</li><li>Recall: (True Positives) / (True Positives + False Negatives) * 100%</li></ul><h4>2.4 Longevity</h4><p>How long will the detection run without requiring changes to its logic, or changes to the log data its run against. This goes back to threat intel and the pyramid of pain. Is the detection capturing a behavior accurately that is less likely to change over a long period of time, vs something that can change tomorrow. Has the analytic been around for a long time and demonstrated effectiveness? Is the attack surface (logs) going to change in 6 months? I don’t think anyone is going to rewrite the raw telemetry for Windows anytime soon, but maybe your log schemas could change, maybe your MSSP or a vendor’s logs could change?</p><p>How to Measure: LLM-based eval</p><h3>3. Operational Cost</h3><p>Think of friction that appears on the journey from threat intel → detection → alert triage &amp; response, that costs you in the form of resources and labor. How “expensive” is it to maintain a detection? Is there high labor cost for false positives? Is there friction involved in tuning alerts? How much?</p><h4>3.1 Investigation Labor Cost</h4><p><strong>Description:</strong> Quantify the human effort required to investigate alerts generated by the detection. Here we only focus on the labor cost for false positive investigations.</p><p>How to Measure: investigation time for false positives (hours/month)</p><h4>3.2 Detection Labor Cost</h4><p><strong>Description:</strong> Measure how frequently the detection requires updates or maintenance due to changes in the environment, data pipeline failures, or log schema adjustments. Frequent maintenance reduces ROI as resources are spent keeping the detection functional. Another thing to think about here: how much friction is there for analysts to tune detections? If its a frequent occurrence and its a pain, folks may take the path of least resistance and avoid tuning.</p><p>How to Measure: how often is a human touching a detection, for what reason, some form of audit trail, are they mutating actions or read actions, etc. what are they doing? tuning? changing logic? (hours/month)</p><h4>3.3 Analytic Costs</h4><p><strong>Description:</strong> Consider the cost of storing logs and data needed to support the detection. Some detections require large volumes of logs or long retention periods, which can be expensive. Are we running the analytic once a minute, once every 12 hours? How much compute does this cost us? This may be overkill for most people, but I just put it here as an option to consider depending on the complexity/desires of your team.</p><p>If I have some crazy ass massive analytic thats scanning all these tables once a minute, I would want to ask “hey, do we need to do this every minute, can we achieve this signal once an hour/day?” Ask this in context of what the detection is trying to achieve.</p><p>How to Measure: Frequency of scheduled searches, compare to other detections, is this running over hot/warm/cold logs, what is the storage $, is this a sunk cost, etc.</p><h4>3.4 Alert Volume</h4><p><strong>Description:</strong> Track how often the detection generates alerts and one of my favorites: whether it contributes to alert fatigue risk (woah, thats a new one!) By the very nature of what a detection is trying to do, if there is a large volume, thats something to look at period. Whether this is a symptom of lack of automation is another question, but I want to see this metric in isolation because it will make me go “why”. I would also argue that in some cases the risk of alert fatigue (overlooking/missing a detection) outweighs the risk of not having the detection at all. You can tie this back to true positives, false positives etc in the precision/recall section but I think pure volume as a simple metric deserved a category of its own.</p><p>How to Measure: # of detections/month</p><h4>3.5 Cognitive Load</h4><p><strong>Description: </strong>How long does it take a human to understand the detection? In other words, whats the requisite subject matter expertise required, how intuitive or clear is the alert, how long does it take me to consume the information in it and process it? Do I have to have a f*cking PhD in Berkeley packet filtering to understand what the detection is trying to do? Or is the detection so well-documented and written that even if I’m not a Kubernetes admin, I can understand what I’m looking at and what to do with the basic security knowledge I have.</p><p>Notice how I didn’t include a documentation category in this framework, thats because a lack of this will show here, and reduce your score. A great place to start is with <a href="https://github.com/palantir/alerting-detection-strategy-framework/tree/master/ADS-Examples">Palantir’s ADS framework</a>.</p><p>How to Measure: LLM-based eval</p><h3>4. Impact &amp; Risk Potential</h3><p>Does the detection represent a threat with large impact for you? Whats the potential for it to surface risk? Whats the risk of false negatives? Is the detection reducing risk or adding risk? Risk can take many forms.</p><h4>4.1 Impact of Detected Threat</h4><p><strong>Description:</strong> Whats the impact of the threat the detection is trying to capture? If its a true positive, how bad is this. Or more colloquially, when you ask an analyst when they look at an alert, what makes them go <a href="https://www.detectionengineering.net/p/absolute-measurement-corrupts-alert">“oh, shit” vs “this is interesting”?</a> You can measure this with respect to security invariants (this should never happen) or the precipitation of risk for every minute a detection is sitting in the queue not being looked at (this is why we have severity levels and SLAs).</p><p>How to Measure: LLM-based eval (its your job to give proper context here)</p><h4>4.2 Risk Potential of False Negatives</h4><p><strong>Description: </strong>This is a balancing act, and we can accept the risk of false negatives to favor a more precise/less noisy alert. But ask yourself whats the organizational tolerance for missed detections? We could have put this in the precision/recall section, but I wanted to call it out on its own to keep risk separate from efficacy. We can also get crazy with this and measure this based on the availability of compensating controls. For example, the detection logic may miss some stuff, but the likelihood of those false negatives actually happening is so low due to controls/preventions in place that we accept the risk here.</p><p>How to Measure: LLM-based eval</p><h4>4.3 Bias Susceptibility</h4><p><strong>Description:</strong> Bias comes in many forms and it can influence how humans perceive, prioritize, and respond to detections. At the end of the day its a psychological and cognitive phenomenon that affects decision-making, and what happens when we make bad decisions in security, more risk!</p><p><strong>Novelty Bias (Salience Bias):</strong></p><p>Analysts may give disproportionate attention to an alert that is less frequent because it stands out compared to routine alerts. This bias can cause the analyst to over-prioritize novel alerts while underestimating the significance of more frequent ones that may be equally or more important.</p><p><strong>Frequency Bias (Desensitization or Alert Fatigue):</strong></p><p>Our favorite! Seeing the same alert(s) repeatedly can cause us to be desensitized to them. This could increase the likelihood of mis-handled alerts by not giving them the same investigation quality as others.</p><p><strong>Expertise &amp; Familiarity Bias:</strong></p><p>Analysts with specialized knowledge (you may be an endpoint or network person) may place more value in detections on those attack surfaces compared to others because they are more familiar with them. Or maybe you had a really bad experience with EDR detections at your last job, so now you hate them. The same can be said of techniques or areas you find more interesting. For example, I am partial to cloud stuff because thats an area I actively research and where my experience in detection writing came from.</p><p>How to Measure: This one will be hard as you would need data to show patterns in decision-making among many other things, so I will come back to this in a future post. My point here is that we have many other objective ways of measuring detection quality above (without bias) because we are having LLMs grade them, not humans. For example, if you have a fun, new CNAPP or CDR tool and your analysts are very happy with the quality and frequency of alerts, they may look favorably on those signals compared to others.</p><h3>5. Utility</h3><p>This is one of my favorites, because we can go to town on tradecraft, statistics and analytics all we want, but at the end of the day: is the detection actually <em>useful </em>to me? And this one is by far the most dependent on you and your specific organization. Everyones different, and if I don’t want to know every single second when theres a possible container escape, thats my decision and thats up to me.</p><h4>5.1 Operational Context</h4><p>A detection rule may be high-quality in theory, but if it leads to benign positives within the specific environment or user behaviors of the organization, it may not be practical to implement. If one malicious behavior is simply part of the norm at your org, or impractical to tune, then its okay to omit that detection.</p><p>How to Measure: # of benign positives/month</p><h4>5.2 Actionability</h4><p>If a human receives an alert, can they respond to it or not? And to what degree? For example, if I have an alert that surfaces end user shadow IT, but I can’t enforce it or take a remediation step or do anything..then who cares?</p><p>How to Measure: # of true positives/month with no action (investigation, remediation, hand-off to other stakeholders, entering into risk register, etc.)</p><h4>5.3 Response Consistency</h4><p>Does the detection have consistent response and investigation steps. Or does each investigation vary wildly. Keep in mind I am talking about basic triage here, not full DFIR. Put another way: whats the automation potential as a function of complexity &amp; consistency of response.</p><p>How to Measure: measure similarity of investigation/response steps across the same alert and use LLM-based eval to determine consistency</p><h3>Conclusion</h3><p>The point of this framework was to try and codify and put some objective support behind thought processes like:</p><ul><li>Although this detection captures a very prevalent AWS TTP, due to the high cost of labor associated with false positives, its just impractical for us to have this, so we’ll accept the risk of turning it off because I’m confident we have enough coverage that we’ll catch an accessory signal if this was real.</li><li>We need to take these 30 scheduled queries and rewrite them because all they are doing is keyword matching on adversary brought tooling. Its trivial for these artifacts to be changed, so lets see if we can keep the same coverage or improve it with just 10 detections.</li><li>Lets focus less on writing these corporate endpoint detections because we simply don’t have as much attack surface relative to our Cloud footprint. We also don’t have much actions to take with end users, so the cost of maintaining these, triaging them, and tuning them is not worth it to me.</li></ul><p>I really wanted a framework for this because we all know that detection is a very specialized form of expertise and because of that, it can be very difficult to measure quality. But what I want you to remember is what makes this useful is that it takes into account the whole process from threat inception, to detection construction, to analysis and response, and that this is not one-size-fits-all. Its flexible so you can measure how good a detection is according to 1) what makes you unique and 2) what you care about more.</p><p>Another idea to explore: if I have a corpus of 1,000 detections for example, and I want to rip &amp; replace them and show that we are better off with these 250 detections (<a href="https://medium.com/@vanvleet/threat-detection-strategy-a-visual-model-b8f4fa518441">less is more</a>), is there a way I can objectively measure and show that? Put another way: these detections do a much better, <em>practical </em>job at detecting your exploitable attack surface.</p><p>So I hope this can help answer questions that are hard to answer like “whats the ROI on this signal?” or “whats the value of this detection for my organization?” Now you can see all the context that goes into answering a question like this, its quite a bit.</p><p>If you enjoyed this read, head over to <a href="https://www.linkedin.com/in/dylan-williams-a2927599/">LinkedIn</a> to see what I’m up to!</p><h3>References</h3><p>As always, great insight is built on the shoulder of giants and this was heavily influenced and inspired by the following resources, so want to give them full credit in the work/deep thought that has been put into this.</p><ul><li><a href="https://matthewob5.medium.com/detection-engineering-metric-scoring-framework-1cdd6cf23398">https://matthewob5.medium.com/detection-engineering-metric-scoring-framework-1cdd6cf23398</a></li><li><a href="https://d4rkciph3r.medium.com/establishing-a-detection-engineering-program-from-the-ground-up-b170811166c">https://d4rkciph3r.medium.com/establishing-a-detection-engineering-program-from-the-ground-up-b170811166c</a></li><li><a href="https://docs.google.com/spreadsheets/d/1EhlLZcsZHw5DRPjvu6qZmNdDJ-hfyKqGKAhl5qAWAD0/edit?gid=17753735#gid=17753735">https://docs.google.com/spreadsheets/d/1EhlLZcsZHw5DRPjvu6qZmNdDJ-hfyKqGKAhl5qAWAD0/edit?gid=17753735#gid=17753735</a></li><li><a href="https://medium.com/snowflake/shifting-from-detection-1-0-to-2-0-3c77d7a71c3">https://medium.com/snowflake/shifting-from-detection-1-0-to-2-0-3c77d7a71c3</a></li><li><a href="https://medium.com/brexeng/elevating-security-alert-management-using-automation-828004ad596c">https://medium.com/brexeng/elevating-security-alert-management-using-automation-828004ad596c</a></li><li><a href="https://expel.com/blog/performance-metrics-measuring-soc-efficiency/">https://expel.com/blog/performance-metrics-measuring-soc-efficiency/</a></li><li><a href="https://www.datadoghq.com/blog/building-security-coverage-for-cloud-environments/">https://www.datadoghq.com/blog/building-security-coverage-for-cloud-environments/</a></li><li><a href="https://youtu.be/g0GJI9wJ74Y?si=MsOw3mMJsdQIRGmD">https://youtu.be/g0GJI9wJ74Y?si=MsOw3mMJsdQIRGmD</a></li><li><a href="https://www.detectionengineering.net/p/table-stakes-for-detection-engineering?utm_source=substack&amp;utm_medium=email">https://www.detectionengineering.net/p/table-stakes-for-detection-engineering?utm_source=substack&amp;utm_medium=email</a></li><li><a href="https://www.detectionengineering.net/p/absolute-measurement-corrupts-alert">https://www.detectionengineering.net/p/absolute-measurement-corrupts-alert</a></li><li><a href="https://medium.com/@vanvleet/the-threat-detection-balancing-act-coverage-vs-cost-cdb71d21412f">https://medium.com/@vanvleet/the-threat-detection-balancing-act-coverage-vs-cost-cdb71d21412f</a></li><li><a href="https://youtu.be/CRtmeWCbRZQ?si=a-PyIKg1s4WRz8Cc">https://youtu.be/CRtmeWCbRZQ?si=a-PyIKg1s4WRz8Cc</a></li><li><a href="https://posts.specterops.io/capability-abstraction-fbeaeeb26384">https://posts.specterops.io/capability-abstraction-fbeaeeb26384</a></li><li><a href="https://posts.specterops.io/detection-spectrum-198a0bfb9302">https://posts.specterops.io/detection-spectrum-198a0bfb9302</a></li><li><a href="https://center-for-threat-informed-defense.github.io/summiting-the-pyramid/">https://center-for-threat-informed-defense.github.io/summiting-the-pyramid/</a></li><li><a href="https://jacknaglieri.substack.com/p/hq-siem-rules">https://jacknaglieri.substack.com/p/hq-siem-rules</a></li><li><a href="https://redcanary.com/blog/security-operations/detection-engineering/">https://redcanary.com/blog/security-operations/detection-engineering/</a></li><li><a href="https://redcanary.com/blog/security-operations/tuning-detectors/">https://redcanary.com/blog/security-operations/tuning-detectors/</a>\</li><li><a href="https://detect.fyi/how-to-prioritize-a-detection-backlog-84a16d4cc7ae">https://detect.fyi/how-to-prioritize-a-detection-backlog-84a16d4cc7ae</a></li><li><a href="https://medium.com/starting-up-security/prioritizing-detection-engineering-b60b46d55051">https://medium.com/starting-up-security/prioritizing-detection-engineering-b60b46d55051</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd6a3b373860" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Utilizing Generative AI and LLMs to Automate Detection Writing]]></title>
            <link>https://medium.com/@dylanhwilliams/utilizing-generative-ai-and-llms-to-automate-detection-writing-5e4ea074072e?source=rss-d501563f598b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e4ea074072e</guid>
            <category><![CDATA[detection-engineering]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Dylan]]></dc:creator>
            <pubDate>Fri, 10 May 2024 15:16:43 GMT</pubDate>
            <atom:updated>2024-11-12T16:10:50.618Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tyulDLy1D_b_gp5h" /><figcaption>A security operations analyst experiencing toil (Image generated by DALL·E 3)</figcaption></figure><p>In Security Operations, we are primarily responsible for two things: Detection &amp; Response. Writing detections can be a very laborious and painful process. This may be something you do when you have time outside alert triage or you may even be part of a dedicated detection engineering team. I wanted to see if I could build a solution to eliminate the <a href="https://cloud.google.com/blog/products/identity-security/achieving-autonomic-security-operations-reducing-toil">toil</a> involved in <a href="https://securitylabs.datadoghq.com/articles/threatest-end-to-end-testing-threat-detection/">detection engineering</a>. This is the process of going from a <em>threat idea</em> to a <em>finished detection</em> or analytic. This includes starting with an idea that represents threat behavior, researching &amp; understanding various log sources, writing search queries in different languages, writing detection logic in different languages, and maybe even testing the detection when you’re done. This whole process is manual, time-consuming, complex, and requires expertise in multiple areas. Lets see if we can take the steps involved in this process and use <a href="https://en.wikipedia.org/wiki/Generative_artificial_intelligence">generative AI</a> or <a href="https://en.wikipedia.org/wiki/Large_language_model">Large Language Models</a> (LLMs) to help us do it. That way, cyber security professionals can spend more time on higher quality tasks like focusing on the <em>idea</em> part and less on this whole cumbersome process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z-w5wiXUz8xWpzNy0gly5g.png" /><figcaption>The status-quo process for detection development</figcaption></figure><p>In this blog I am going to share some helpful tips I learned when using this technology and give you a practical guide so you can give it a try yourself. Before we continue, for the purposes of this blog I want to clarify what I view as “threat intelligence” here: I only care about <a href="https://www.splunk.com/en_us/blog/learn/ttp-tactics-techniques-procedures.html">TTPs</a> or <em>behaviors</em>, things that are higher on the <a href="https://detect-respond.blogspot.com/2013/03/the-pyramid-of-pain.html">pyramid of pain</a>. Anything that does not meet this criteria, I don’t consider a good candidate for threat ideation and for the sake of this article. I will be writing detections in <a href="https://streamalert.io/">StreamAlert</a>, a free and open-source framework that follows detection-as-code principals popularized by folks such as <a href="https://medium.com/@jack.naglieri/0-to-1-billion-with-streamalert-94b982dbad63">Jack Naglieri</a>, <a href="https://medium.com/threatpunter/from-soup-to-nuts-building-a-detection-as-code-pipeline-28945015fc38">David French</a> and <a href="https://kyle-bailey.medium.com/detection-engineering-maturity-matrix-f4f3181a5cc7#:~:text=a%20bit%20further.-,Detection%2Das%2Dcode,logic%20and%20detection%20creation%20workflow.">Kyle Bailey</a>. But keep in mind, as there are <a href="https://uncoder.io/">countless ways</a> to write detections, this can be replaced with whatever tooling you are using for detection logic at your organization.</p><h4>Oh the toil, the pain</h4><p>So first things first: lets illustrate the toil here so you can understand why I was motivated to start this project in the first place. Lets walk through the current status quo process a human goes through when going from idea (threat TTP) → finished StreamAlert detection:</p><ol><li>read and understand threat, maybe from a blog, report or open-source detection content, for example an <a href="https://docs.datadoghq.com/security/default_rules/cloudtrail-aws-ebs-snapshot-possible-exfiltration/">EBS snapshot exfiltrated</a></li><li>understand what logs or security data I can use to detect this threat, for example <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-user-guide.html">CloudTrail</a> logs in this case, then understand all the field names, field values, how they’re structured, how <em>your</em> logging pipeline structures them, etc.</li><li>search logs in your SIEM equivalent/security data lake/XDR/whatever you want to call it and tune out any noise or benign positives</li><li>when you are happy with the search results, convert the logic used in the search query (SQL/SPL/KQL, whatever) to a <a href="https://github.com/airbnb/streamalert/blob/master/rules/community/cloudtrail/cloudtrail_aws_config.py">StreamAlert python rule</a> (the detection logic)</li><li>create a <a href="https://github.com/airbnb/streamalert/blob/master/rules/community/cloudtrail/cloudtrail_aws_config.json">test JSON file</a> that contains matching log values (one to trigger the detection and one to not)</li><li>(Optional) F*ck up the whole process on the way here through syntax errors, typos, going back and forth between python, JSON and SQL, debugging, troubleshooting, etc.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oZsheKQM55ON57xQOTR6CA.png" /><figcaption>Heres an example</figcaption></figure><p>Before we continue: how am I going to measure success here? I want to be able to go from a threat idea, such as an InfoSec blog, threat intel report, open-source detection content, adversary emulation tooling, or a bespoke threat my team came up with internally in natural language → finished detection or analytic. For this experiment I focused only on cloud threats, so any detections we will write come from sources such as CloudTrail logs, Okta logs or Kubernetes audit logs. So the question is, can I give a LLM this and have it hand me back finished detections, but more importantly, in my boutique implementation?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-cjE-z9UUVBkFKnknaHOkw.png" /><figcaption>High level design</figcaption></figure><h3>Prompt Engineering Primer</h3><p>I’m going to share everything I’ve learned during this process so it will save you considerable time if you want to use LLMs for detection writing yourself. <a href="https://www.promptingguide.ai/techniques">This resource</a> is a gem and I would start here. The following is a short, practical guide on the <em>how</em>. I am recommending to follow these steps in the order that follows, then iterate through them again when necessary. For those of you who have not heard this term yet: <a href="https://docs.anthropic.com/claude/docs/prompt-engineering#:~:text=Prompt%20engineering%20is%20an%20empirical,not%20actually%20in%20writing%20prompts.">prompt engineering</a> is just the process of writing the prompt or question you send to the model. Beware, this is not a step 123 guide and you’re done. This is a: do it over again and again and again until you’re happy with the results. Trust in our friend Bacon and follow the scientific method, no not <a href="https://en.wikipedia.org/wiki/Kevin_Bacon"><em>that</em> </a>Bacon, <a href="https://en.wikipedia.org/wiki/Baconian_method">this</a> one.</p><h4>1. Have the LLM Write its Own Prompt</h4><p>Why? Cause <a href="https://docs.anthropic.com/claude/docs/prompt-generator">its good at it</a> and saves you time. This will give you a great first draft. If you want to brainstorm and have some fun, you can check out <a href="https://docs.anthropic.com/claude/prompt-library">prompt libraries</a> like <a href="https://thepromptindex.com/prompt-database.php">here</a> or use a prompt generator like <a href="https://colab.research.google.com/drive/1SoAajN8CBYTl79VyTwxtxncfCWlHlyy9#scrollTo=NTOiFKNxqoq2">this</a>. Choose a model, like Claude, Llama, or GPT and have that same model write your first draft. Later on, you can also go back and have the prompt grade or <a href="https://docs.anthropic.com/claude/docs/ask-claude-for-rewrites">rewrite</a> the prompt itself if you are running into issues.</p><h4>2. Few-Shot (give examples)</h4><p>This <a href="https://www.promptingguide.ai/techniques/fewshot">step</a>, along with a few others, will be the most critical. In our case, we want to give high quality and diverse examples of TTPs and their corresponding detection. So for example, I would give 2–3 examples each of Okta detections, CloudTrail detections, and Kubernetes detections and try my best to have variety in the specific log fields used and their values. Experiment with the number and quality of examples to improve your results.</p><h4>3. Chain of Thought (CoT)</h4><p>All <a href="https://www.promptingguide.ai/techniques/cot">this</a> is, is giving explicit step-by-step instructions to the model like you would to a human. Now imagine you have a new employee joining the team, think to yourself: whats the exact data &amp; information they would need to complete this task? Lets assume they have basic cyber security knowledge (like a lot of these pre-trained models do) and you ask them to write a detection in XYZ language. Now sit down, and write out clearly and as detailed as possible, step-by-step instructions on how to do it. Remember, you want to set them up for success! <em>Leave no room for guess work.</em> This is what I found to be the root cause of models hallucinating. Because I (as the prompt engineer) just didn’t give them enough information!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Q_ihmJnVfDvQ9RZ3dm0cw.png" /><figcaption>Image generated by DALL·E 3</figcaption></figure><p>When you’re done your first draft, you can give your team the same instructions to review and ask for feedback on clarity and detail.</p><p><strong>Pro tip:</strong> Debug the model’s logic by having it output its results between steps. For example, ask it to “explain your reasoning”. When the prompt gets large and complex, this will help you identify which steps are causing hallucination or overfitting.</p><h4>4. Prompt Structure</h4><p>A fantastic resource that helped me is the <a href="https://towardsdatascience.com/how-i-won-singapores-gpt-4-prompt-engineering-competition-34c195a93d41">COSTAR framework</a>. Use this as a high-level structure for your overall prompt. We know that there are many individual steps involved in writing detections, so naturally this prompt will get very long and complicated. This is where you take advantage of <a href="https://towardsdatascience.com/how-i-won-singapores-gpt-4-prompt-engineering-competition-34c195a93d41">delimiters</a> to break apart your prompt into separate sections. You will see how I leveraged this in my example below. This is critical when you are using very large context windows in models like <a href="https://docs.anthropic.com/claude/docs/long-context-window-tips">Claude</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*5llyj_A1LG3fxwbwSYf2Jg.png" /><figcaption>General prompt structure</figcaption></figure><h4>5. Model Specific Prompting</h4><p>Do not have ChatGPT write a prompt for itself when you’re just going to use it for another model! Read the docs for each model on the optimal way to use it. Don’t think it makes a difference? Look at <a href="https://docs.google.com/presentation/d/1tjvAebcEyR8la3EmVwvjC7PHR8gfSrcsGKfTPAaManw/edit#slide=id.g2c40da08fdb_17_593">this simple difference</a> for Claude when using a model-specific technique. If you are using Claude, I recommend starting <a href="https://docs.google.com/presentation/d/1tjvAebcEyR8la3EmVwvjC7PHR8gfSrcsGKfTPAaManw/edit#slide=id.g2c40da08fdb_17_0">here</a> in addition to Anthropic’s <a href="https://docs.anthropic.com/claude/docs/prompt-engineering">documentation</a> to get the best results.</p><h4>6. Hallucination Guardrails</h4><p>Give the model an opportunity to say “I don’t know”, just like a human. If it doesn’t have the proper information, obviously its not going to be able to give an answer. An example where I applied this: if the threat idea given by the human is incomplete (aka it does not contain enough information about the evidence of the threat in security data), then I don’t want the model to finish the detection, just tell me it can’t complete the task without more information. You can also use this method to steer the model in the right direction. For my use case, I only care about potential detections that can use CloudTrail, Okta, or Kubernetes audit logs. If I give it a report that only has TTPs for Linux or Windows, then I want the model to ignore it. I also use this technique in my step-by-step instructions to tell the model: if you encounter threat intel that is missing critical information like log field names, reference the log schema to complete the information.</p><h4>7. To RAG or not to RAG</h4><p><a href="https://www.promptingguide.ai/research/rag">Retrieval Augmented Generation</a> (RAG) is a way to give these models access to data they don’t have or were not trained on. Aka, your corpus of detections, your organizations data, your security log structure. A big misconception I found here is that “I need to use external data with LLMs” = use RAG. Not necessarily. In our use case, we may want to give the model internal documentation on how we write detections, our custom log schemas, our custom logs, existing detections we wrote, etc. So I just take all that stuff, hook it up to <a href="https://aws.amazon.com/what-is/retrieval-augmented-generation/">RAG</a> and I’m good to go right? No. Lets understand whats actually happening behind the scenes here. This is not just plug n play all your external data into the model. It is not going to just magically read all the instructions/documentation and boom done. If you are unsure whether to use RAG or not, start with the <a href="https://aws.amazon.com/blogs/machine-learning/best-practices-to-build-generative-ai-applications-on-aws/">bedrock best practices guide</a> to decide which techniques make sense for your use case. I wasted a lot of time on this project in the beginning because I did not understand when it was appropriate to use RAG and when not to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CpKW2OuO1TPM0SsFvyeIOA.png" /><figcaption>Use <a href="https://aws.amazon.com/blogs/machine-learning/best-practices-to-build-generative-ai-applications-on-aws/">this</a> to help you choose which AI techniques to use</figcaption></figure><p>I believe it comes down to the following questions for your use case: is the external data you want to use changing often? How much data do you really need to have the model complete its task? There is a lot of debate around using <a href="https://www.pinecone.io/blog/why-use-retrieval-instead-of-larger-context/">RAG vs a very large context window</a> (i.e. let me copy paste a small book into the prompt as context to my question) and its effect on accuracy. To bring it back to our use case, what did I find provided the best results? 200 detections + RAG, or using 2–3 high-quality, diverse examples per log source hard-coded in the prompt? Ask yourself this question: are <em>you (a human) </em>better at hand picking context than the <a href="https://aws.amazon.com/what-is/retrieval-augmented-generation/#:~:text=Semantic%20search%20technologies%20can%20scan,text%20instead%20of%20search%20results.">semantic search</a>? At the end of the day this is all RAG is doing: semantic search of your external data and then augmenting your prompt. If you have better results hand picking context and examples yourself and hard coding them into the prompt, you’re better off doing that. And for our use case here, I would argue that the <em>way</em> we write detection logic (i.e. Python, KQL, SPL) and the structure of our security data <em>generally</em> does not change often. If you’re not sure, compare your results with prompt engineering alone vs RAG and view the original source of the data that RAG uses for its result. So for <em>this </em>use case I found that prompt engineering alone was very successful.</p><h3>Advanced Prompt Engineering</h3><p>Okay if you’ve gotten this far, stop. Try all of the above first and see how far you can get with your results before experimenting with more techniques. If you still want to get more accuracy from your results, here are a few more advanced techniques to experiment with.</p><h4>8. Change Custom Parameters</h4><p>There are a handful of <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/inference-parameters.html">parameters</a> for most models that you can tweak. Overall, they control two things: randomness and diversity. <a href="https://www.promptingguide.ai/introduction/settings">Temperature</a> (0 to 1) can be changed depending on how deterministic or random you want the model’s response to be. For example, my use case is better suited to a temperature closer to 0 as I want results that are consistent and predictable because of the structure of the JSON and python files. This is an example of something called <a href="https://huggingface.co/blog/how-to-generate#greedy-search">greedy decoding</a> and the compromise here is that you are missing out on the broader probability space. The model may have a more efficient or creative way of implementing the detection logic for example. So <a href="https://aws.amazon.com/blogs/machine-learning/enhance-performance-of-generative-language-models-with-self-consistency-prompting-on-amazon-bedrock/">try different temperature values</a> and see what works for your specific use case.</p><p>Top P and Top K both control the “<a href="https://attri.ai/generative-ai-wiki/llm-optimization-parameters#:~:text=The%20top-k%20parameter%20effectively,which%20the%20model%20can%20choose.">vocabulary size</a>” the model uses when its crafting a response. Imagine after I ask you a question, you can pick from the top 50 most likely words you would use vs the top 1500. For the purposes of writing detections, I have found that its better to have more deterministic responses as we want our detection logic to be consistent and prefer less room for randomness.</p><h4>9. Prompt Chaining</h4><p>This is where I saw the real potential in leveraging LLMs for helping us eliminate toil. Up until this point, all we’ve done is build on one prompt. But the real power comes from when you chain several prompts or tasks together. <a href="https://www.promptingguide.ai/techniques/prompt_chaining">Prompt chaining</a> is just taking the output of one prompt and sending it into another. Instead of trying to shove it all together into one massive, complicated prompt, try splitting it up into a few. For example, here I may want a separate prompt only for analyzing and pulling threats out of an article thats worth writing a detection for. I can use this to describe what I qualify as a meaningful or practical detection (aka no atomic IOCs, give me behavioral signals). Writing the actual detection logic in the query language of your choice is a form of expertise on its own so lets separate that into its own prompt and have another prompt do QA on the output before we’re done. By breaking up large, complex tasks like detection engineering from one prompt into many, you will see an incredible improvement in results. Checkout <a href="https://github.com/aws-samples/amazon-bedrock-serverless-prompt-chaining">AWS step functions</a>, <a href="https://flowiseai.com/">Flowise</a>, or similar tools for fast prototyping to experiment with chaining.</p><h4>10. Self-Consistency</h4><p>Like we mentioned above, by varying the values of parameters, we can change the kinds of responses we get from these models. One way to try this in practice is to use a technique called <a href="https://www.promptingguide.ai/techniques/consistency">self-consistency</a>. Imagine we have three people all write a detection for the same TTP. Because there are so many ways to implement the detection logic, we may have three very different detections, but all correctly identify the threat. This concept can be used by letting the model come up with several different answers based on different variables like temperature, top-k, etc. and having it select the “best” one.</p><h3>Results</h3><p>This is all great..but did it work? Whats the accuracy? At this stage we can look into evaluating our model + prompt based on a list of selected input. For this we can take some TTPs from our existing detection corpus, maybe some detections from the backlog, or even threat descriptions in natural language (write me a rule for when the service account bob.dylan executes in a kubernetes pod in the X namespace in the AWS account Y). Because this transformation is not as simple as text retrieval or summarization, we don’t have a fixed right or wrong answer to compare against (i.e. the Capitol of France is Paris). Therefore we will have to use a human to grade the results. But in this case, StreamAlert is great because all we have to do is <a href="https://streamalert.io/testing.html#rule-tests">test</a> the json file against the python rule and it will either pass or fail!</p><p>Lets take a look at the results! Presenting D.I.A.N.A. (Detection &amp; Intelligence Analysis for New Alerts). For example, I may want to take all the content from <a href="https://github.com/SigmaHQ/sigma/tree/master/rules/cloud/aws/cloudtrail">Sigma’s CloudTrail rules</a>, <a href="https://stratus-red-team.cloud/attack-techniques/list/">Stratus Red Team</a>, <a href="https://github.com/anvilogic-forge/armory">Anvilogic’s armory</a> and write a detection for them in <em>my </em>language of choice.</p><p>Personally I tend to find some of the best detection ideas from blogs or articles, so lets give the model these as well: <a href="https://www.invictus-ir.com/news/the-curious-case-of-dangerdev-protonmail-me">Invictus IR</a>, <a href="https://permiso.io/blog/lucr-3-scattered-spider-getting-saas-y-in-the-cloud">Permiso Security</a>, <a href="https://www.gem.security/post/aws-console-session-traceability-how-attackers-obfuscate-identity-through-the-aws-console">Gem Security</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-_O8uCNsHtls5mnw0G2Img.gif" /><figcaption>Select the detection idea you want to convert</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o4ikwiKLdrTNwFMrL7-_5A.gif" /><figcaption>Convert to StreamAlert</figcaption></figure><p>I used StreamAlert in this particular use case, but I wanted to provide the prompt template to use so this can be swapped out with any query or detection language to achieve the same goal. For example heres my prompt after omitting all the detection and log examples, which ended up being around 11k tokens (for perspective this is around 7500 words and Claude has a 200k token context window, or the number of tokens you can give the model and receive back):</p><pre>Human: You are tasked with converting cyber security threat intelligence into StreamAlert.io rules written in Python, along with crafting their corresponding JSON test files for various log sources, such as GitLab, CloudTrail, Okta, AWS EKS, and more. <br>Your threat intelligence will be provided in the form of detections, threat intelligence reports, adversary emulation tools, or any text that describes the techniques, tactics or procedures of an adversary. This threat intelligence will be provided <br>to you in the &lt;question&gt; tags as your input. <br>Your output will be a streamalert rule in markdown format and the matching json file in json format. Separate them so I can see them clearly, such as streamalert_rule.py and streamalert_rule.json.<br><br>Use information enclosed in &lt;context&gt; tags as context to the threat intelligence enclosed in &lt;question&gt; tags.<br>If you don&#39;t know the answer, just say that you don&#39;t know, don&#39;t try to make up an answer.<br><br>&lt;context&gt;<br>-This is where you put all the infromation about your detection tooling of choice<br>-Think about your boutique implementation and the data the model doesn&#39;t know about<br>-Inlude log schemas, examples<br>-Inlude detections, examples<br>-Include any data you would reference from the step-by-step instructions below<br>&lt;/context&gt;<br><br>Use the step by step process in the &lt;steps&gt; tags to complete the task:<br><br>&lt;steps&gt;<br>Step 1: Understand the Threat:<br>Begin by comprehensively understanding the threat intelligence provided by the question. Identify key attributes such as log field names, <br>values, event source, event name, specific parameters, or conditions that signify that activity in the logs.<br>Use what you know about aws cloudtrail logs, aws eks logs, kubernetes audit logs, gitlab logs, and okta logs to help you identify the log fields and values. <br>If you need help refer to their log documentation.<br><br>Step 2: Define the Python Rule<br>Import necessary libraries from streamalert and define the rule logs, outputs and publishers<br><br>Logic Function: Write a Python function that captures the threat logic. Use the threat intelligence to extract and match log data fields such as eventSource, eventName, and specific conditions that indicate a threat.<br>Documentation: Provide comments or a docstring within the Python file explaining the purpose of the rule, the nature of the threat, and any relevant technical context or response recommendations.<br><br>Step 3: Create the JSON Test File<br>Create a JSON test file with positive test cases that should trigger the detection rule, and negative test cases that should not.<br>Ensure the test scenarios are accurately reflecting the log data format of the specified log source.<br>When specifying the test data, it can use either of the two methods:<br>&quot;data&quot;: An entire example record, with all necessary fields to properly classify the log<br>&quot;override_record&quot;: A subset of the example record, where only relevant fields are populated<br>If the data method is used, make sure every single field name from the log source schema in &lt;context&gt; tags is in the json file. If not, it will not work.<br>If you are using the override_record method, you only have to populate the json file with relevant fields for the detection logic.<br>If you are confused, refer to how streamalert.io works.<br><br>Step 4: Information Completeness Check<br>If you encounter unknown field names or log attributes, check the streamalert log schemas in the &lt;context&gt; tags to see if the field name is there. <br>Ensure that all code and JSON examples are syntactically correct and formatted for clarity. Use placeholders for any sensitive or specific information that is not provided.<br><br>Step 5: Documentation and Response<br>Document each detection rule clearly, outlining its purpose, logic, and the specific TTP it addresses. Make sure to put this information as a quoted description inside the streamalert rule itself. <br>Separate the streamalert rule and its json file so I can clearly see them. Put the title of each rule above it.<br>Should the provided threat intel in the &lt;question&gt; tag lack necessary details for rule creation, list out the missing information that is needed to complete the task.<br>&lt;/steps&gt;<br><br>&lt;style&gt;<br>The response should be written in a clear, concise, and technical style, suitable for cybersecurity professionals. Use terminology and structures familiar to cybersecurity threat analysis and detection development.<br>&lt;/style&gt;<br><br>&lt;tone&gt;<br>The tone should be objective and analytical, focusing on providing clear and factual information without unnecessary embellishments or subjective interpretations.<br>&lt;/tone&gt;<br><br>&lt;audience&gt;<br>The intended audience is cybersecurity analysts and engineers who are responsible for creating new detections. They have a deep understanding of cybersecurity concepts, threat intelligence, and detection mechanisms.<br>&lt;/audience&gt;<br><br><br>&lt;question&gt;<br>{question} #&lt;-- this is where the &#39;threat idea&#39; would go<br>&lt;/question&gt;<br><br>Think about your answer first before you respond.<br><br>Assistant: <br><br></pre><p>Here is the python used to invoke Claude. I happen to be using Amazon Bedrock and highly recommend going through the <a href="https://github.com/aws-samples/amazon-bedrock-workshop">workshops</a> here to get yourself started if you do the same.</p><pre>def call_claude_sonet(prompt):<br>    <br>    prompt_config = {<br>        &quot;anthropic_version&quot;: &quot;bedrock-2023-05-31&quot;,<br>        &quot;max_tokens&quot;: 4096,<br>        &quot;temperature&quot;: 0, # &lt;-- notice I&#39;m using a temp of zero<br>        &quot;messages&quot;: [<br>            {<br>                &quot;role&quot;: &quot;user&quot;,<br>                &quot;content&quot;: [<br>                    {&quot;type&quot;: &quot;text&quot;, &quot;text&quot;: prompt},<br>                ],<br>            }<br>        ],<br>    }<br><br>    body = json.dumps(prompt_config)<br><br>    modelId = &quot;anthropic.claude-3-sonnet-20240229-v1:0&quot;<br>    accept = &quot;application/json&quot;<br>    contentType = &quot;application/json&quot;<br><br>    response = bedrock_runtime.invoke_model(<br>        body=body, modelId=modelId, accept=accept, contentType=contentType<br>    )<br>    response_body = json.loads(response.get(&quot;body&quot;).read())<br><br>    results = response_body.get(&quot;content&quot;)[0].get(&quot;text&quot;)<br>    return results<br><br># This file contains the full engineered prompt<br>file_path = &#39;diana_prompt_final.txt&#39;<br><br># Read the content of the file into a variable<br>with open(file_path, &#39;r&#39;, encoding=&#39;utf-8&#39;) as file:<br>    prompt = file.read()<br><br># Threat information would go below, such as sigma rule, stratus red team, etc.<br>question = &#39;&#39;&#39;<br>Detection: Suspicious S3 Bucket Versioning Changes<br>Description: Detect attempts to disable or suspend S3 bucket versioning, which could indicate an adversary trying to prevent data recovery after a ransomware attack. This can be detected by monitoring CloudTrail logs for &#39;GetBucketVersioning&#39; and &#39;PutBucketVersioning&#39; events with versioning status changes.<br>Log Source: AWS CloudTrail<br>Potential False Positives: Legitimate bucket versioning configuration changes by authorized personnel or applications.<br>&#39;&#39;&#39;<br><br># Unfortunately I was not able to leverage langchains prompt template feature due to all the JSON brackets in my prompt<br># https://api.python.langchain.com/en/latest/prompts/langchain_core.prompts.prompt.PromptTemplate.html<br>full_prompt = prompt.replace(&#39;{question}&#39;, question)<br><br>result = call_claude_sonet(full_prompt)<br>print(result)</pre><p>So after randomly selecting 50 TTPs from the sources I mentioned above and testing the model’s StreamAlert python rules and accompanying JSON files, 35/50 of them passed. Whats cool about the 15 that “failed” is, a bulk of the work is already done. If we take a look at what went wrong, it was caused by one of the following: syntax issues with the python or JSON, the model hallucinated and missed a few fields or used a wrong name for the log schema, or the model did not follow my step-by-step instructions completely. Point being, it should be pretty quick for a human to correct those last 15 and continuing to improve the prompt should increase the accuracy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SRinFR94zitT0pHslXHd-g.png" /><figcaption>Not perfect, but I’ll use it.</figcaption></figure><h3>Bonus Tips</h3><p>Garbage in, garbage out. This shouldn’t be a surprise but is easily forgotten as you get excited to use this new technology. You’ll notice that all the “threat intel” I give the model is already distilled TTPs that contain the log source evidence already. I can’t just feed the model anything and expect it to come up with an accurate result without the proper information, just like a human. If I gave you this atomic red test and told you to write me a detection for it, think about exactly what information you would need to complete this task. Don’t expect to just hook up your external data and let ‘er rip. The best results will come from quality data, well-thought-out instructions and prompt content.</p><p>If you find yourself stuck and can’t move the needle on the quality of your results, your prompt may be too complex and/or too long. Your prompt may also be too short, and does not have enough instructions or details. If this happens, ask the model to rewrite its prompt. I initially (and probably still do) have a lot of redundancy in my instructions and this will take away from clarity. This is a balancing act and will take lots of experimentation to find that sweet spot. As I mentioned above, ask the model to “think out loud” so you can debug the reasoning between steps. This will let you see which sections of the prompts are resulting in errors and will show you where more information or clarity is needed to complete the task accurately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*2BsmcFLOjwh60rADMP2cnQ.png" /><figcaption>Break up expertise into separate prompts</figcaption></figure><p>Slow down and focus on one technique at a time. Its easy to get excited about creating a hive mind of agent swarms, cause it sounds cool and scary. Pick one specific problem, measure your results, and see how far you can push the accuracy. Then move on to the next one. I tried to throw cyber security tradecraft expert, log/data engineer, detection engineer, python expert, and database/SQL expert all into one prompt. Its too much! Try breaking down each form of expertise into different prompts.</p><p>My one tip is: see how far you can get with just prompt engineering alone.</p><h3>Whats next?</h3><p>I wrote this post to make LLMs more accessible to security professionals, but more importantly to give a practical guide on <em>how</em> to use them. This is an incredible piece of technology and when applied correctly to the right problems, can become quite the force multiplier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aHp7z-NxJWsk9LL14LZBfQ.png" /><figcaption>Brainstorming future solution</figcaption></figure><p>In the next article I will walk through using an LLM <a href="https://www.promptingguide.ai/research/llm-agents.en">agent</a> to automatically craft and run <a href="https://aws.amazon.com/athena/">Athena</a> queries based on our initial threat idea, return results and then correct the final detection for noise/benign positives. After that, it may be interesting to automatically poll results from <a href="https://detection.fyi/">detection.fyi</a> or sigma releases, have the model create the detection, and then create a ticket for a human to review. Another missing piece you may have noticed is handling more complicated detection logic, such as a large number of API calls over a window of time. This is actually implemented <a href="https://streamalert.io/scheduled-queries.html">differently</a> in StreamAlert and will require more prompting expertise. Another idea is to also have each detection adhere to <a href="https://github.com/palantir/alerting-detection-strategy-framework">ADS framework</a>, or maybe something unique to your org by feeding it existing playbooks/SOPs. I also gave a brief talk about this project at <a href="https://www.securityfrontiers.ai/">securityfrontiers.ai</a>, so feel free to check it out as there are several other cool projects in there to get motivated. Otherwise, thanks for reading! I can be reached out to on <a href="https://www.linkedin.com/in/dylan-williams-a2927599/">linkedin</a> if you wanna chat about anything security or AI. And please let me know if you have any more ideas for this project.</p><p>Checkout D.I.A.N.A. here on Github: <a href="https://github.com/dwillowtree/diana">https://github.com/dwillowtree/diana/tree/main</a></p><p>If you enjoyed this read, head over to <a href="https://www.linkedin.com/in/dylan-williams-a2927599/">LinkedIn</a> to stay updated on what I’m doing!</p><h3>References</h3><p>If you just want to browse most of what I used to research the problem and/or understand how LLMs work.</p><ol><li><a href="https://gitlab.com/coonsmatthew/detectient">https://gitlab.com/coonsmatthew/detectient</a></li><li><a href="https://medium.com/mitre-engenuity/our-tram-large-language-model-automates-ttp-identification-in-cti-reports-5bc0a30d4567">https://medium.com/mitre-engenuity/our-tram-large-language-model-automates-ttp-identification-in-cti-reports-5bc0a30d4567</a></li><li><a href="https://www.greynoise.io/blog/introducing-sift-automated-threat-hunting">https://www.greynoise.io/blog/introducing-sift-automated-threat-hunting</a></li><li><a href="https://www.elastic.co/security-labs/accelerating-elastic-detection-tradecraft-with-llms">https://www.elastic.co/security-labs/accelerating-elastic-detection-tradecraft-with-llms</a></li><li><a href="https://medium.com/threatpunter/from-soup-to-nuts-building-a-detection-as-code-pipeline-28945015fc38">https://medium.com/threatpunter/from-soup-to-nuts-building-a-detection-as-code-pipeline-28945015fc38</a></li><li><a href="https://github.com/AttackIQ/SigmAIQ/tree/master">https://github.com/AttackIQ/SigmAIQ/tree/master</a></li><li><a href="https://blog.openthreatresearch.com/exploring-defensive-challenges-with-artificial-intelligence-from-traditional-to-generative/">https://blog.openthreatresearch.com/exploring-defensive-challenges-with-artificial-intelligence-from-traditional-to-generative/</a></li><li><a href="https://cloud.withgoogle.com/cloudsecurity/podcast/ep75-how-we-scale-detection-and-response-at-google-automation-metrics-toil/">https://cloud.withgoogle.com/cloudsecurity/podcast/ep75-how-we-scale-detection-and-response-at-google-automation-metrics-toil/</a></li><li><a href="https://www.signalblur.io/using-limacharlie-and-chatgpt-to-perform-malware-anomaly-detection">https://www.signalblur.io/using-limacharlie-and-chatgpt-to-perform-malware-anomaly-detection</a></li><li><a href="https://www.attackiq.com/2024/01/10/sigmaiq-attackiqs-latest-innovation-for-actionable-detections/">https://www.attackiq.com/2024/01/10/sigmaiq-attackiqs-latest-innovation-for-actionable-detections/</a></li><li><a href="https://platform.openai.com/docs/guides/prompt-engineering">https://platform.openai.com/docs/guides/prompt-engineering</a></li><li><a href="https://aws.amazon.com/blogs/security/generate-ai-powered-insights-for-amazon-security-lake-using-amazon-sagemaker-studio-and-amazon-bedrock/">https://aws.amazon.com/blogs/security/generate-ai-powered-insights-for-amazon-security-lake-using-amazon-sagemaker-studio-and-amazon-bedrock/</a></li><li><a href="https://aws.amazon.com/blogs/aws/knowledge-bases-now-delivers-fully-managed-rag-experience-in-amazon-bedrock/">https://aws.amazon.com/blogs/aws/knowledge-bases-now-delivers-fully-managed-rag-experience-in-amazon-bedrock/</a></li><li><a href="https://aws.amazon.com/blogs/machine-learning/build-a-contextual-chatbot-application-using-knowledge-bases-for-amazon-bedrock/">https://aws.amazon.com/blogs/machine-learning/build-a-contextual-chatbot-application-using-knowledge-bases-for-amazon-bedrock/</a></li><li><a href="https://d1.awsstatic.com/events/Summits/reinvent2023/AIM377_Prompt-engineering-best-practices-for-LLMs-on-Amazon-Bedrock.pdf">https://d1.awsstatic.com/events/Summits/reinvent2023/AIM377_Prompt-engineering-best-practices-for-LLMs-on-Amazon-Bedrock.pdf</a></li><li><a href="https://www.pinecone.io/blog/why-use-retrieval-instead-of-larger-context/">https://www.pinecone.io/blog/why-use-retrieval-instead-of-larger-context/</a></li><li><a href="https://attri.ai/generative-ai-wiki/llm-optimization-parameters#:~:text=The%20top%2Dk%20parameter%20effectively,which%20the%20model%20can%20choose">https://attri.ai/generative-ai-wiki/llm-optimization-parameters#:~:text=The%20top%2Dk%20parameter%20effectively,which%20the%20model%20can%20choose</a>.</li><li><a href="https://aws.amazon.com/blogs/machine-learning/best-practices-to-build-generative-ai-applications-on-aws/">https://aws.amazon.com/blogs/machine-learning/best-practices-to-build-generative-ai-applications-on-aws/</a></li><li><a href="https://aws.amazon.com/blogs/machine-learning/explore-data-with-ease-using-sql-and-text-to-sql-in-amazon-sagemaker-studio-jupyterlab-notebooks/">https://aws.amazon.com/blogs/machine-learning/explore-data-with-ease-using-sql-and-text-to-sql-in-amazon-sagemaker-studio-jupyterlab-notebooks/</a></li><li><a href="https://github.com/aws-samples/amazon-bedrock-serverless-prompt-chaining?tab=readme-ov-file">https://github.com/aws-samples/amazon-bedrock-serverless-prompt-chaining?tab=readme-ov-file</a></li><li><a href="https://github.com/Rachnog/intro_to_llm_agents/tree/main">https://github.com/Rachnog/intro_to_llm_agents/tree/main</a></li><li><a href="https://www.promptingguide.ai/">https://www.promptingguide.ai/</a></li><li><a href="https://colab.research.google.com/drive/1SoAajN8CBYTl79VyTwxtxncfCWlHlyy9#scrollTo=NTOiFKNxqoq2">https://colab.research.google.com/drive/1SoAajN8CBYTl79VyTwxtxncfCWlHlyy9#scrollTo=NTOiFKNxqoq2</a></li><li><a href="https://www.databricks.com/blog/LLM-auto-eval-best-practices-RAG">https://www.databricks.com/blog/LLM-auto-eval-best-practices-RAG</a></li><li><a href="https://docs.anthropic.com/claude/prompt-library">https://docs.anthropic.com/claude/prompt-library</a></li><li><a href="https://github.com/langchain-ai/langsmith-cookbook/blob/main/optimization/assisted-prompt-bootstrapping/elvis-bot.ipynb">https://github.com/langchain-ai/langsmith-cookbook/blob/main/optimization/assisted-prompt-bootstrapping/elvis-bot.ipynb</a></li><li><a href="https://aman.ai/primers/ai/RAG/#raptor-recursive-abstractive-processing-for-tree-organized-retrieval">https://aman.ai/primers/ai/RAG/#raptor-recursive-abstractive-processing-for-tree-organized-retrieval</a></li><li><a href="https://github.com/aws-samples/amazon-bedrock-workshop/tree/main">https://github.com/aws-samples/amazon-bedrock-workshop/tree/main</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e4ea074072e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blue Team 201: Detection — Where Do You Start?]]></title>
            <link>https://medium.com/the-lavender-project/blue-team-201-detection-where-do-you-start-76540dbceeb0?source=rss-d501563f598b------2</link>
            <guid isPermaLink="false">https://medium.com/p/76540dbceeb0</guid>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[cyber]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[infosec]]></category>
            <dc:creator><![CDATA[Dylan]]></dc:creator>
            <pubDate>Fri, 22 May 2020 18:32:36 GMT</pubDate>
            <atom:updated>2020-05-22T18:32:36.305Z</atom:updated>
            <content:encoded><![CDATA[<h3>Blue Team 201: Detection — Where Do You Start?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*RTPBAuc4gGkxUUmZiJDwYA.png" /></figure><p>Many of you may have heard the old adage “prevention is ideal, but detection is a must.” For the detection piece in this blue team series I decided to focus on <a href="https://redcanary.com/blog/endpoint-security-vs-network-security/">endpoints</a> specifically. I know this does not cover everything, especially those of you who are responsible for protecting things you can’t just slap an AV or agent on (sorry ICS folks). I also find endpoint detection to be more straight-forward than network detection if you are starting from scratch. If you remember the <a href="https://github.com/swannman/ircapabilities">pyramid model</a> from my <a href="https://medium.com/the-lavender-project/blue-team-101-ec2cbac6e9b2">last post</a>, two of the bottom tiers asked the questions: “Do you have visibility across your assets?” and “Can you detect unauthorized activity?” Detection can be analogous to playing a game of “find the needle in the haystack”-although sometimes it feels as if its a game of “find the needle in the needle-stack”. With that said, lets start with the basics and get down to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*njEYPS6ru1E3UmYMo2GlBQ.png" /><figcaption>Trying to distinguish actual malicious recon from vulnerability scans.</figcaption></figure><p>What do we want to accomplish here? I don’t know about you but ultimately I would like my blue team to be the Eye of Sauron. We want to see everything happening in our environment so we are able to detect any activity, malicious or not. We know the logs do not lie, so what are the first things we can start auditing to acquire visibility in our environment? For the purposes of this post I am going to assume we’re in a primarily Windows Enterprise environment to keep things simple.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dtsd-UWIbD7OhZ9WRVfPZg.gif" /><figcaption>The Eye of Sauron</figcaption></figure><p>One of my favorite resources of all time is the logging cheat sheet by <a href="https://www.malwarearchaeology.com/cheat-sheets/">Malware Archaeology</a>. This guide is an utterly fantastic starting point to determine what kinds of events you want to capture in your Windows domain and why. To determine what you want to enable, ask yourself questions like: Can I see every time a user logs on or off a machine? When they change their password? Or even when they start a new process? Not all of this information is available by default so we’ll have to turn some stuff on. A great way to accomplish this and manage it is through group policy. I found myself repeatedly looking up which group policy settings correspond to which Windows event codes, so here is all that information in one <a href="https://girl-germs.com/?p=363">place</a> to complement your windows logging cheat sheet. If you’re not yet familiar with windows event logs and the context they bring to infosec, here are a few places to start: <a href="https://www.splunk.com/en_us/blog/security/peeping-through-windows-logs.html">Peeping Through Windows Logs</a>, <a href="https://www.splunk.com/en_us/blog/tips-and-tricks/spotting-the-adversary-with-splunk.html">Spotting the Adversary with Splunk</a>, <a href="https://conf.splunk.com/session/2015/conf2015_MGough_MalwareArchaelogy_SecurityCompliance_FindingAdvnacedAttacksAnd.pdf">Sexy Six Event Codes</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*djScb0IjCG60HnO81FmWng.png" /><figcaption><a href="https://www.splunksecurityessentials.com/">https://www.splunksecurityessentials.com/</a></figcaption></figure><p>Once you are confident in your visibility, the next step is to get all those logs into one place so your team can easily access them for investigation. There are many ways to accomplish this and therefore I will try my best to be vendor-agnostic in this series. With that said, several of the resources I mention here use Splunk, but almost all of the insights presented can be used in other platforms. There are countless alternatives out there like AlienVault USM, IBM Qradar, GrayLog, ELK, LogRhythm, etc. You also don’t have to use the Windows native event log as <a href="https://www.gartner.com/reviews/market/endpoint-detection-and-response-solutions">EDR</a> agents have become so popular nowadays and gather much of the same telemetry if not more.</p><p>Like I mentioned earlier, I will be talking about detection around the endpoint, but obviously that is only one piece among the diverse IT infrastructure you may have in place. We will not forget about those firewalls, proxy servers, VPN, DNS, and other network device logs. In another post I will explore the field of network security monitoring and all the detection powers used by IDS/IPS solutions such as Zeek (Bro), Snort, Suricata, etc. But if you’re too eager to wait I highly recommend picking up a copy of <a href="https://www.amazon.com/Practice-Network-Security-Monitoring-Understanding/dp/1593275099/ref=pd_lpo_14_t_0/136-8657496-9404749?_encoding=UTF8&amp;pd_rd_i=1593275099&amp;pd_rd_r=72846504-e1a4-44a6-a534-484635560736&amp;pd_rd_w=xcTXj&amp;pd_rd_wg=xLKKD&amp;pf_rd_p=7b36d496-f366-4631-94d3-61b87b52511b&amp;pf_rd_r=P296YD1KBDM35NRMWCAG&amp;psc=1&amp;refRID=P296YD1KBDM35NRMWCAG">Practice of Network Security Monitoring</a>. With that in mind, I firmly believe that when you are starting out, the most manageable and pragmatic place to start is the endpoint, as it <a href="https://redcanary.com/blog/endpoint-security-vs-network-security/">is the most conclusive place to look</a>. Once you have enabled logging for windows events and start to become familiar with what is normal in your environment, now the real fun begins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*sf4xV0vcLUvjmH6HxelsdA.png" /><figcaption><a href="http://ryanstillions.blogspot.com/2014/04/the-dml-model_21.html">http://ryanstillions.blogspot.com/2014/04/the-dml-model_21.html</a></figcaption></figure><p>Windows event logs are super valuable when it comes to detecting malicious activity but it won’t catch everything. So can we take it a step further? <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon">Sysmon</a> is a free and <a href="https://medium.com/@haggis_m/splunking-the-endpoint-threat-hunting-with-sysmon-9dd956e3e1bd">much more granular</a> event logger that is a part of Mark Russinovich’s Sysinternals tool suite for Windows. What makes sysmon so valuable is that its a kernel-mode driver, which for our purposes means it can provide even greater visibility into the operating system. SwiftonSecurity’s sysmon <a href="https://github.com/SwiftOnSecurity/sysmon-config">configuration file</a> is a great place to start as this type of logging has the potential to be very noisy (Malware Archaeology has a <a href="https://www.malwarearchaeology.com/cheat-sheets/">cheat sheet</a> for sysmon as well). Not all organizations have the budget for enterprise security products and this is why I am such a huge advocate for FOSS security solutions. I consider sysmon to be so <a href="https://medium.com/@olafhartong/endpoint-detection-superpowers-on-the-cheap-part-1-e9c28201ac47">valuable</a> when it comes to detection because it is free and just as good, if not better than many commercial EDR products.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*R0baTlz1OR8_xmMwb-go8w.png" /><figcaption>A benevolent coworker explains to a newly minted SOC member.</figcaption></figure><p>Now that you have visibility into all your endpoints, you can focus on improving your detection. There is a multitude of malicious “things” out there you can detect and it can be very overwhelming to determine which ones you should care about and why. So if you’re not sure how to measure the maturity of your detection capabilities, refer back to the <a href="https://www.malwarearchaeology.com/cheat-sheets/">cheat sheets</a> I mentioned earlier. At this point you may have some out-of-the-box alerts from any security tools you have or maybe wrote/curated some alerts yourself. False positives are forever the chronic affliction of the blue team and now we can work towards improving the <a href="https://medium.com/palantir/alerting-and-detection-strategy-framework-52dc33722df2">fidelity and durability of our detection</a>. A great illustration of this is the model SpecterOps has coined the <a href="https://posts.specterops.io/introducing-the-funnel-of-fidelity-b1bb59b04036">Funnel of Fidelity</a>. This is the process we want to use to help finding that needle in the haystack less difficult. Just keep in mind for every alert, notification or email that reaches your inbox, would you rather it be right 9/10 times or 1/10 times?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*nfOKv3xtkV_W1Onv8ZctQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*vS0fajQ5yVHXG-E_.png" /><figcaption>The Funnel of Fidelity (left) inspired by the Pyramid of Pain (right).</figcaption></figure><p>Having said that, I hope I’ve provided you with some great resources to start building your detection stack and turn your blue team into the omnipresent Eye of Sauron. If you want to take this a step further I encourage you to look at <a href="https://www.fireeye.com/blog/threat-research/2019/03/silketw-because-free-telemetry-is-free.html">Event Tracing for Windows</a> (ETW) and see how in-depth you really can get with the operating system logs. I also recommend checking out the <a href="https://wazuh.com/">Wazuh</a> project as well as <a href="https://securityonion.net/">Security Onion </a>for those of you who are interested in free and open-source detection technologies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AGeEiIRT2SL3TYHWFd1y_g.png" /><figcaption>Blue teamer suited up for detecting lateral movement.</figcaption></figure><p>And remember, think back to the IR pyramid mentioned in my <a href="https://medium.com/the-lavender-project/blue-team-101-ec2cbac6e9b2">previous blog</a>- asset inventory &amp; management comes <em>before</em> telemetry &amp; visibility in the hierarchy. Here is a scenario to paint the picture: A user reports opening a phishy attachment to the servicedesk, you go to check the logs and uh-oh, there’s nothing there because the EDR agent wasn’t installed or windows events were not forwarded to your SIEM. It can happen. Be patient in this process as telemetry is the <a href="https://posts.specterops.io/introducing-the-funnel-of-fidelity-b1bb59b04036">building block</a> of detection. Once you have all the data there, you can really get your hands dirty and sharpen your blue team skills. This stuff gets me pretty jacked up, so if you had some fun with this- grab a red bull and stick around for the next post where I will explore more advanced blue team tactics like <a href="https://posts.specterops.io/capability-abstraction-fbeaeeb26384">detection engineering</a>, catching windows tradecraft and threat hunting. Remember: the bad guys only have to get it right <em>once</em>, but we have to get it right <a href="https://www.scmagazine.com/home/opinions/hackers-only-need-to-get-it-right-once-we-need-to-get-it-right-every-time/"><em>every time</em></a>. I hope this post provided a good introduction to the art of detection, so when someone makes a sound- you hear it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/0*WpY2unvI_TDgI6Oq" /><figcaption>Blue team when a disabled account logs in.</figcaption></figure><p><strong>Some more resources on detection below:</strong></p><p><a href="https://github.com/0x4D31/awesome-threat-detection">Curated Threat Detection List</a></p><p><a href="http://detect-respond.blogspot.com/2013/03/the-pyramid-of-pain.html">The Pyramid of Pain</a></p><p><a href="https://www.sans.org/cyber-security-summit/archives/file/summit-archive-1554993664.pdf">Threat Hunting via Sysmon</a></p><p><a href="https://cdn2.hubspot.net/hubfs/4266002/CG_WhitePaper_Splunkmon_1216-1.pdf?__hssc=231642944.1.1565053993871&amp;__hstc=231642944.5685b19a2de5c218ad172dc44f4ac8b2.1565053993871.1565053993871.1565053993871.1&amp;__hsfp=628735910&amp;hsCtaTracking=809679b2-007a-4d31-8f42-b98b68692899%7C61d2f653-55f7-4cec-a36d-1e300a30ca18">Splunkmon-Taking Sysmon to the Next Level</a></p><p><a href="https://github.com/MHaggis/sysmon-dfir">Sysmon DFIR Resources</a></p><p><a href="https://apps.nsa.gov/iaarchive/library/reports/spotting-the-adversary-with-windows-event-log-monitoring.cfm">NSA Windows Event Logging</a></p><p><a href="https://docs.microsoft.com/en-us/archive/blogs/jepayne/tracking-lateral-movement-part-one-special-groups-and-specific-service-accounts">Tracking Lateral Movement Part One</a></p><p><a href="https://2017.zeronights.org/wp-content/uploads/materials/ZN17_Kheirkhabarov_Hunting_for_Credentials_Dumping_in_Windows_Environment.pdf">Hunting for Credential Dumping in Windows Environment</a></p><p><a href="https://www.sans.org/reading-room/whitepapers/logging/paper/34262">SANS:Detecting Security Incidents Using Windows Workstation Event Logs</a></p><p><a href="https://www.sans.org/reading-room/whitepapers/forensics/paper/34132">SANS: Windows Logon Forensics</a></p><p><a href="https://www.sans.org/reading-room/whitepapers/critical/paper/36352">SANS: Uncovering Indicators of Compromise (IoC) Using PowerShell, Event Logs and a Traditional Monitoring Tool</a></p><p><a href="https://www.giac.org/paper/gcia/11501/detecting-penetration-testers-windows-network-splunk/152302">Detecting Penetration Testers on a Windows Network with Splunk</a></p><p><a href="https://osquery.io/">Osquery</a></p><p><a href="https://www.limacharlie.io/">LimaCharlie</a> (not exactly free but pretty cool pricing model)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76540dbceeb0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-lavender-project/blue-team-201-detection-where-do-you-start-76540dbceeb0">Blue Team 201: Detection — Where Do You Start?</a> was originally published in <a href="https://medium.com/the-lavender-project">The Lavender Project</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blue Team 101]]></title>
            <link>https://medium.com/the-lavender-project/blue-team-101-ec2cbac6e9b2?source=rss-d501563f598b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec2cbac6e9b2</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[cyber]]></category>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[information-security]]></category>
            <dc:creator><![CDATA[Dylan]]></dc:creator>
            <pubDate>Fri, 19 Jul 2019 18:37:22 GMT</pubDate>
            <atom:updated>2019-07-19T19:14:46.623Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*rHHOcJN3shxsVz8pvNF_AA.jpeg" /></figure><p>So you’ve setup your SIEM, you got that “next-gen” AV finally deployed and you even convinced management to procure a DLP solution- props to you. You feel confident about your defense-in-depth and you’ve hit most of the CIS 20 security controls right on the head. So now what? Sit back, relax and watch those Splunk alerts kick off every time your sysadmin uses psexec on their workstation. No hacker is gonna get past you now right? At least that’s what you thought until you found yourself explaining to the CEO why the state-of-the-art, block-chain, AI-based, machine learning security solution didn’t stop the ransomware outbreak that bricked half the company’s computers.</p><p>I started this series because the cybersecurity industry has erupted with countless different tools, vendors, solutions and services. It’s hard to keep up with. Nowadays everybody is chasing after that set-and-forget, silver-bullet solution. Over-marketing has captured our attention with things like MDR, SOAR, security instrumentation, AI this, block-chain that and it can be a little overwhelming to decide not only whats the best fit for you, but whether the stuff actually brings value. Because of this I believe people tend to miss the fundamental steps of how to protect your business. Remember that infosec is a process, not a product- and that the human element is still every-bit important as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jinru9lz4ngVR1ol8jEBaA.png" /><figcaption><a href="https://www.lanner-america.com/blog/long-reaching-effects-inadequate-cyber-security/">https://www.lanner-america.com/blog/long-reaching-effects-inadequate-cyber-security/</a></figcaption></figure><p>Throughout this series I want to take a simple approach and present some of the core technologies and processes you can put in place to protect your organization. More importantly, I want to emphasize how a blue team should really be a purple team at the end of the day- hence the name of this blog series. Purple teaming has become a popular buzzword in the industry lately and I want to show that this is kind of unnecessary if your blue team is constantly testing their prevention, detection and response anyway. There is an abundance of free and public knowledge in this industry and I have come across such great resources over the years. Throughout the series I hope to show you some of the best I’ve found. So with that said, let’s get down to the basics and start from scratch.</p><p>Where do we begin? First things first- what is your job? For us defenders out there I like to think of it as fundamentally two things: 1) protect the organization and 2) find evil. This obviously varies depending on your industry, environment, budget, etc. but we’re going to keep it simple. I know a lot of us (me included) like to think that when there is an actual security incident, we look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h93EoaYGGYSy5AnL4M4XBQ.jpeg" /></figure><p>But as we know, unless you are the boots-on-the-ground IR team, your day-to-day is filled with less-exciting yet equally important tasks. With that said, if you envision yourself descending to Earth in an orbital drop shock pod next time there’s a cryptolocker outbreak- all the power to you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*KcAdqNEIfLfyjCxUCgGVzg.gif" /></figure><p>The textbook dogma for infosec, which I’m sure many have heard of, consists of preserving the CIA triad (Confidentiality, Integrity, Availability). This is a great model to assist in setting goals, however I believe the much more pragmatic approach is to build your blue team off of three things: Prevention, Detection, and Response (<a href="https://www.giac.org/paper/gsec/501/information-security-process-prevention-detection-response/101197">https://www.giac.org/paper/gsec/501/information-security-process-prevention-detection-response/101197</a>)</p><p>I’m a really big fan of visuals and I found the best way to illustrate this is with Matt Swann’s incident response hierarchy of needs. I came across it from the HolisticInfoSec blog post here <a href="https://holisticinfosec.blogspot.com/2016/12/the-dfir-hierarchy-of-needs-critical.html">https://holisticinfosec.blogspot.com/2016/12/the-dfir-hierarchy-of-needs-critical.html</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iyRm6OgmjXSvMr6efU8qIg.png" /><figcaption><a href="https://github.com/swannman/ircapabilities">https://github.com/swannman/ircapabilities</a></figcaption></figure><p>When I first got into infosec, I was easily thrilled at the idea of things like threat-hunting and incident response (the tops of the pyramid). There’s nothing wrong with that, and lets be honest- adversary simulation and threat-hunting sound a whole lot cooler than asset inventory and management (bottom of the pyramid). With that said, the most important part of this model is that you start from the bottom-up and remind yourself to not jump the gun. You will absolutely not find the same value if the bottom of your pyramid is not complete first. What use is spending all your time hunting for APTs when you are missing telemetry from even just one of your endpoints? Or how many times one or two computers surface from your IT supply closet back onto the network without AV? It’s easy to get excited about getting that new user-behavior analytics tool or threat-intelligence feed, but remember that the fundamental part of setting up your blue team is establishing those first processes and asking yourself questions like: what assets am I defending? what data am I protecting? where is that data? And this brings back the idea that infosec is a process, not a product. The people and processes on your blue team are as equally important as the technologies you put in place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mosbkcwRyXIOlZ3o8Afy2A.jpeg" /></figure><p>In the following posts I will try to get more specific and focus on each of the Prevention, Detection and Response categories you can use to shape the security posture of your business. I hope that this first post can help anybody out there who is starting from scratch or just looking to revisit how they approach defense. In addition, I can’t give enough credit to the individuals I referenced in this post (many more to come) and encourage you to please check out their stuff as well. Nearly all of what I have learned in this industry outside training and in the field, is from the fantastic public resources available online that these people have taken the time to create. Thanks for reading and feel free to shoot me an email if you have any ideas for this series.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec2cbac6e9b2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-lavender-project/blue-team-101-ec2cbac6e9b2">Blue Team 101</a> was originally published in <a href="https://medium.com/the-lavender-project">The Lavender Project</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>