Microsoft Defender advanced hunting uses Kusto Query Language over a documented schema. For a threat hunter using AI to draft queries, that schema is the starting check: verify the proposed tables and columns before execution, then test whether the query actually answers your question. A successful run alone does not establish that.
Key takeaways
- Write the intended behavior and expected evidence before requesting code.
- Check tables, fields, types, joins, and time boundaries against your actual environment.
- Use known matching records and benign comparisons to inspect meaning beyond syntax.
- Keep data permissions, execution scope, and limitations with the reviewed query.
How should a threat hunter review an AI-generated query?
Review the query as an unverified draft. Define the investigative question, confirm the schema, inspect the logic, and predict results on small known records. Resolve data-handling and execution permissions before using operational data. Save the final query together with its checks and unresolved limits.
The review can become a useful portfolio exercise for a cleared cyber candidate. Choose public or synthetic records, keep the original generated output, and explain the specific defect you found. Avoid describing the model as accurate merely because its first answer looked plausible.
For a synthetic exercise, your question might be whether an unexpected process launched a scripting host that also made a network connection. Identify the evidence needed for each relationship. A query that merely finds process names containing a scripting keyword answers a narrower question.
Define the unit of output before asking for code. Should a row represent an event, a process, a device, or a related event pair? This decision determines what a count means and which details must survive aggregation. Include that definition in the query comment and your review notes.
How do you verify tables and fields?
Check every referenced table and column in the product documentation and in the environment where the query will run. Confirm the data type, meaning, and observed population of each field. Reject a mapping based only on a similar-looking name.
Microsoft’s advanced hunting language documentation establishes the Kusto foundation. Its schema table reference links to table-specific column descriptions. Use those references alongside the schema visible in your own hunting interface.
Make a compact review note for each important field: what it represents, which input produces it, whether it can be missing, and where it appears in the logic. Distinguish the process involved in an event from the process that initiated it. Confirm that any identifier used for correlation belongs to the entity you intend to connect.
Inspect a small authorized sample before assuming the table contains relevant records. An existing table can still lack the source, device coverage, or activity period needed for your question. Record missing coverage as a limitation instead of renaming a nearby field until the query compiles.
This is a practical extension of Microsoft Sentinel skills for cleared cloud security work. Familiarity with a query language helps you inspect a draft; you still need to establish which data is present and how that environment exposes it.
What can joins and time filters silently exclude?
Read joins as statements about which records survive and which relationships they represent. Check the join flavor, keys, duplicates, and unmatched inputs. Review time conditions on each input and on the relationship itself. A shared host name and overlapping search period do not establish that events belong to the same process.
The Kusto innerunique documentation describes a consequential default: when the join kind is omitted, innerunique removes duplicate left-side keys. If repeated events on that side matter to your question, inspect what is being removed. Choose an explicit join flavor based on the intended relationship.
Also inspect unmatched records. If your question includes processes with no observed network activity, a relationship requiring a match on both inputs cannot retain that entire population. Define whether absence of a match should be visible, and distinguish missing telemetry from confirmed absence of behavior.
Microsoft documents that Kusto time filters use UTC regardless of the interface time zone setting. Write the intended event-time interval explicitly in your review record. Check boundary operators, the timestamp field selected, and whether each joined input uses a compatible interval.
Use a fixed, documented interval for a repeatable lab review. A moving lookback can return different records when someone reruns the query later. If the goal is to associate events in sequence, inspect their relative times as well as whether they fall within the overall search period.
| Review area | Plausible-looking defect | Useful check |
|---|---|---|
| Schema | A real field describes the wrong entity | Trace its definition and inspect a raw record |
| Join | Repeated left keys disappear | Compare input events with retained matches |
| Time | Relevant activity falls outside a boundary | Test records around the intended interval |
| Aggregation | Matched pairs are labeled as processes | State and verify the unit being counted |
Which known records should you test?
Start with a small synthetic dataset whose expected results you can inspect manually. Include an intended match, a near match that should fail, benign activity with similar features, and a case with missing evidence. Write down the expected behavior before running the query.
For the process-and-network exercise, create labeled records that represent the relationship you intend to find. Add an unrelated process on the same host to test whether your keys are too broad. Add repeated records to expose unintended multiplication or deduplication. These are designed tests, not evidence about a real adversary.
Check strings and missing values deliberately. Include a relevant field that is empty and a similar term that should not satisfy the search. Read the documentation for the exact operator the query uses rather than assuming that all text-matching expressions behave alike.
Compare the actual output with your expected event identities, not just its size. A query can return the expected amount of output while selecting the wrong records. If it fails, isolate the condition responsible and rerun the same cases after the change.
Trace a match backward. Starting with a returned row, locate its source records, identify the condition that kept each record, and explain how the join or aggregation produced the displayed entity without relying on the model’s explanation of its own code. Repeat this with an excluded near match.
Keep a separate unresolved-questions note as you review. It might identify unavailable process identity, an untested boundary condition, or uncertainty about an export transformation. Resolve the items that affect the intended conclusion before describing the query as reviewed; carry the remaining constraints into the result comment.
Then use a small selection of releasable lab records to see whether the synthetic assumptions hold in real telemetry. Passing designed cases supports the tested logic. It does not measure operational detection performance, establish threat coverage, or demonstrate an acceptable false-positive rate across an organization.
A small inspection script can help compare results when you are developing Python skills for cleared SOC analysis. Preserve the expected record list and explain the comparison. Avoid a test that merely repeats the query’s own assumptions in another form.
What permissions and execution scope need review?
Check both where the prompt data goes and where the query executes. Use an approved model service and approved inputs for the environment involved. Inspect generated references to external resources, broad datasets, functions, or destinations before running anything against operational systems.
A candidate can complete the exercise with synthetic schema descriptions and fabricated records. Public portfolio work does not require live employer telemetry. Remove actual host names, user identifiers, command contents, and access details unless they are explicitly releasable through the relevant process.
Review the complete submission, including helper definitions and any proposed wrapper script. Separate permission to inspect data from permission to export it or automate a response. Confirm the available role and intended scope with the system owner when working in an organization; a generated instruction cannot grant access.
Start execution with the smallest authorized scope that can test the question. Check resource-intensive operations before broadening the search, and retain intermediate inspection output when it helps explain a result. If the query cannot be evaluated within the permitted scope, record that constraint rather than claiming it has been validated.
The NIST AI Risk Management Framework provides voluntary guidance for incorporating trustworthiness into AI use and evaluation. NIST identifies AI RMF 1.0, released in 2023, as undergoing revision. The review procedure above is a practical lab method, not a NIST-mandated checklist or organizational authorization.
What should you save with the reviewed query?
Save the intended question, original AI draft, reviewed revision, schema references, designed test cases, observed results, and limitations. Include the data scope and execution context. Label the artifact according to what you actually tested, keeping lab validation separate from any operational deployment decision.
Describe your contribution with a specific before-and-after explanation. For example, say that you corrected a join that discarded relevant input events and verified the change against labeled records. Keep the original defect visible enough for a reviewer to follow your reasoning.
When discussing a threat-hunting career path, connect this artifact to investigative judgment. Explain the evidence needed, the alternative explanation you tested, and the uncertainty left over. Knowing when the query cannot answer the question is part of the work sample.
Frequently Asked Questions
Is a query safe to trust once it runs successfully?
No. Successful execution shows that the platform accepted the submitted query in that context. You still need to inspect its logic, expected matches, exclusions, and data scope before relying on its output for an assessment.
Should I ask the same model to review its answer?
You can use a follow-up response to suggest possible defects, but check those suggestions independently against documentation and known records. Agreement between generated responses is not a substitute for an observable test.
Can benign activity match a reviewed query?
Yes. A query may correctly identify a behavior that occurs in both legitimate and suspicious work. Document the benign comparison and identify the additional context needed before interpreting a match as evidence of a threat.
What should I do before adding the query to a portfolio?
Confirm that the inputs and outputs are releasable, then attach the review record to the final query. Begin with the test case that exposed the most meaningful defect and show how your revision changed its result.
