We use analytics cookies to understand how the site is used. They are only set if you accept, and you can change your mind at any time from the footer. See our Privacy and Cookies policies, and Terms and Conditions.

Author: Richard Curteis - Director

Published: 28/11/2026

LLMs for Security Work, Part 1: Salvaging Reliability

  1. In a World of Tools, Be Useful
  2. On the Catwalk
  3. Hallucinations
  4. Primed Inference
  5. Hammers Are for Hammering
  6. How Realize Works

TL;DR

  • An LLM predicts the next piece of text from patterns in its training data. It is very good at reading and writing messy, unstructured material, and unreliable at recalling facts, counting things or giving the same answer twice. Hallucination comes from the way it generates text, so nobody is going to patch it out.
  • We get dependable security work out of LLMs by feeding them facts from deterministic tools, keeping each job narrow, checking every claim against its evidence and leaving sign-off with a person. We call this primed inference, because the model is primed with verified facts before it is asked to infer anything.
  • Priming attacks on LLMs use the same mechanism, filling the context to steer what the model says next, to push it towards harmful output. We use it to anchor the model to evidence.
  • Where a script can do the job, we have the model write the script.
  • This is the first post in a series on using LLMs for security work. Later posts go deeper on LLM-assisted testing, reporting and keeping LLM agents in scope.

In a World of Tools, Be Useful

Every few seconds someone on LinkedIn announces LLMs will replace entire security teams. Meanwhile, the curl project dropped its bug bounty in January 2026 after a flood of LLM-generated reports describing vulnerabilities which didn't exist.

An LLM is a tool. Like a fuzzer, a proxy or a decompiler, it has jobs it does well, jobs it does badly and a few it should never be given. It still has to be used well, and the expertise of the person operating it is the single biggest indicator of whether the LLM produces a quality result.

LLMs are good with unstructured data. They can read a 400-line diff, a vendor advisory, a pile of HTTP responses or a badly written ticket and discern meaning and intent. They can write the first draft of a finding, a test harness or a parser.

They manage this by drawing on patterns from a vast amount of code and prose seen in training, which is why they can work with most mainstream languages, frameworks and bug classes. Most of that comes from public code and writing seen during pretraining, with coding-focused training added afterwards, and they are noticeably weaker on obscure languages and internal frameworks.

The weaknesses come from the same method. A model doesn't look up fresh information unless you give it a tool to do so, such as web search or an MCP server. It doesn't count reliably. Ask the same question twice and you may get two different answers, both delivered with the same confidence. In security work, one wrong version number or invented function name can send a tester down a rabbit hole or fundamentally undermine a finding.

On the Catwalk

A model is a very large file of numbers, called weights, plus the code to run them. The weights are fixed once training ends. There is no table of facts inside. What the model learned is spread across billions of parameters as statistical associations between pieces of text.

When you send it a request, roughly this happens.

  1. Tokenisation. Your prompt is split into tokens, chunks of a few characters each. strawberry might be split into str, aw and berry. The model never sees individual letters, which is part of why it is bad at counting them.
  2. Embedding. Each token is turned into a vector, a long list of numbers standing for that token and its position.
  3. The layers. The vectors pass through dozens of transformer layers. In each one, attention lets every token weigh up every earlier token in the context, so a variable declared on line 3 can inform a guess about line 300. The rest of the layer reshapes the result using what training baked into the weights.
  4. Scoring. After the last layer the model gives a score to every token in its vocabulary, usually somewhere between 50,000 and 250,000 of them, for what should come next.
  5. Sampling. The scores become probabilities and one token is picked. Temperature sets how adventurous the pick is. Near zero the model almost always takes the top choice. Turn it up and it takes more chances.
  6. Repeat. The chosen token is added to the context and the whole process runs again for the next one, until the model produces a stop token or hits a length limit.

During a request the model has two sources of information. One is the weights. The other is the context window, which holds your prompt, anything it has written so far and any tool output it has been given. The context window is large but finite, and it is the only part you control while the model runs.

Hallucinations

The model is always producing the most plausible next token given what it has. If the right answer is in the context, plausible and correct usually line up. If it isn't, you still get something plausible. We call this gap hallucination.

The main sources of error are listed below.

  • Sampling. The pick at each step is probabilistic, so the same prompt can produce different answers. Setting temperature to zero helps, though hosted models can still vary slightly between runs because the server batches your request with other people's, and GPU floating-point maths gives slightly different results depending on the batch size.
  • Missing facts. Ask about something the context doesn't contain and the model falls back on its weights. You get a function that ought to exist in the library, a CVE number in the right format, an Nmap flag that looks right. Your internal frameworks and last week's advisories were never in the training data at all.
  • Errors compound. Every token is conditioned on the ones before it. Once the model has written "the vulnerable parameter is id", the next few hundred tokens will tend to back that up, whether or not it was true.
  • Long, noisy context. Paste in 40,000 lines of scan output and the detail you care about competes with everything else for attention. Models are measurably worse at using information buried in the middle of a long context, and you pay for every token either way.
  • Leading questions. Ask "is this SQL injection?" and you have nudged the answer towards yes. Models are trained to be helpful, and agreeing often looks helpful.
  • Prompt injection. The model can't reliably tell your instructions apart from text it is reading. A code comment or an HTTP response saying "ignore previous instructions" is a real problem for a tool whose job is reading hostile input.

The Strawberry Problem

The classic demonstration is asking a model how many Rs are in "strawberry". For a long time most models said two, and plenty still do when asked cold. The one question manages to hit nearly every item on the list above.

The model sees tokens such as str, aw and berry, so there are no letters in front of it to count. Nothing in the context holds the answer, so it reaches for whatever its weights make plausible. One theory is the training data is full of people asking whether the end of the word has one R or two, and "two" is the answer they get.

Sampling means a second attempt might say three. Once it has written "two", it will often defend the answer, sometimes spelling out s-t-r-a-w-b-e-r-r-y letter by letter and still arriving at two. Ask "there are only two, right?" and you can expect it to agree.

Nobody loses sleep over a fruit. Swap the question for "how many hosts expose SMB" or "which version of this library is in the build" and the same mechanics apply, except a wrong answer now costs testing time or hides a real risk.

Newer models make these mistakes less often. We checked this with Claude Mythos 5.2 and Claude Fable 5.2 while writing this post. They still make them, and the mistakes get harder to spot because the writing around them is better.

Primed Inference

Primed inference is how we work around those weaknesses. The model is primed with verified facts before it is asked to infer anything, and whatever it infers is checked before anyone relies on it.

It rests on keeping facts, judgements and decisions apart.

  • Facts come from deterministic tools such as Nmap XML, an SBOM, a call graph, a CodeQL database, Terraform state, a cloud inventory or captured proxy traffic. Run the tool twice on the same input and you get the same answer.
  • Judgements are the model's reading of those facts. Is this endpoint reachable without authentication? Does this code path reach the vulnerable method? Approved judgements are reused until the facts behind them change.
  • Decisions sit with people and deterministic gates. People own scope, intent and sign-off. Gates such as citation validators, scope allowlists and CVSS calculators apply the rules mechanically. Neither kind of decision is handed to the model.

A typical task then runs like this.

  1. A tool produces the facts.
  2. The model gets a scoped slice of them through MCP lookups, enough for the task in front of it. It can ask for more through the same lookups, which leaves a record of what it looked at.
  3. The task is narrow. "Classify these 12 endpoints by whether they need authentication" works far better than "find the bugs in this app".
  4. "Unknown" is an allowed answer, with its own slot in the output schema. Give a model no way to say it doesn't know and it may fabricate information or evidence.
  5. Every claim cites its evidence, such as a file and line, a request ID or an element in the scan output. A deterministic validator checks each citation exists and supports the claim. Anything failing is dropped or sent back.
  6. What survives is signed off by a person, or by a deterministic policy gate for routine, well-defined cases.
Primed inference workflow. Tools such as Nmap, an SBOM or a call graph produce repeatable facts. The model gets a scoped slice through MCP lookups for a narrow task where unknown is an allowed answer. Its claims, with citations, go to a validator that checks every citation and sends rejected claims back. Accepted claims are signed off by a person or policy gate, then stored in a judgement cache keyed on a hash of the facts and reused until the facts change.

Claims which fail validation go back to the model. Approved judgements are cached and reused until the facts underneath them change.

Each workflow lives in a playbook recording the model, settings, tools and validator rules. The model won't give identical output twice, but the facts are deterministic and approved judgements are stored, so a result can still be checked months later.

Validators have limits. One can confirm the model quoted line 212 correctly, but proving the bug is exploitable still takes deterministic verification or a person.

Findings are grouped by the mechanism behind them, a sample from each group goes through the same deterministic verification, and any control outside the code, such as a WAF rule or a network boundary, is recorded as an assumption.

Applied to strawberry, the workflow is short. The LLM creates a script to count the letters, and running the script records the fact r_count = 3. Otherwise, the model's task is narrow, perhaps explaining the spelling in a client report, and it reads the fact through a lookup. If it writes "two Rs" anyway, the validator compares the claim against the recorded fact and sends it back. The sentence is signed off, and the model is never asked to count the letters again unless the word changes.

Hammers Are for Hammering

The easiest way to avoid a hallucinated fact is to never ask the model for one. If a tool can answer a question deterministically, the tool should answer it.

Strawberry is the toy version. "strawberry".count("r") returns 3 every time, whatever the tokeniser does with the word, and costs a handful of tokens. If your business is counting letters in words (LinkedIn Influencer CEO), you've probably created an MCP to do this.

Asking the model to write that line is much safer than asking it to count. Security work has the same problem at a larger scale.

Take a service scan of a /22. The Nmap XML can easily run to a couple of megabytes, which is around half a million tokens. Pasted into a prompt, it may not fit at all. If it does fit, you pay for every token, and the model may still miss a host or miscount the open ports, because counting across half a million tokens is exactly the kind of job it is bad at. You're using your hammer to fix a screw.

A better approach is to let the model run tools itself, so a query returns only what it asked for. Better still, have the model write the code. Ask it for a short script which parses the XML and returns hosts running TLS on non-standard ports.

import json, sys
import xml.etree.ElementTree as ET

root = ET.parse(sys.argv[1]).getroot()
hits = []
for host in root.iter("host"):
    addr = host.find("address").get("addr")
    for port in host.iter("port"):
        state = port.find("state").get("state")
        svc = port.find("service")
        if state == "open" and svc is not None and svc.get("tunnel") == "ssl" \
                and port.get("portid") not in ("443", "8443"):
            hits.append({"host": addr, "port": int(port.get("portid")),
                         "service": svc.get("name")})
print(json.dumps(hits, indent=2))

The script runs, the output is exact, and the model reads a few hundred tokens of JSON instead of half a million tokens of XML. Models are good at writing small parsers like this one, so the job plays to their strengths. Hammers are for nails.

As a rough guide, we split the work like this.

Job Done by
Counting hosts, ports, findings or dependencies Code
Comparing versions against an advisory Code
Diffing this week's scan against last week's Code
Working out whether a call path reaches a vulnerable method Call-graph tool, model explains the result
CVSS arithmetic Code
Reading a function and saying what it is meant to do Model
Deciding whether an error message leaks something useful Model, checked by a person
Grouping 300 findings by likely root cause Model, with a sample verified by hand
Writing the finding up for a client Model drafts, person edits

Once a model can run tools, the limits on what it can run have to live outside it. We use allowlisted commands, egress restrictions and authorisation enforced on the MCP server. An out-of-scope target stays out of scope even when a prompt injection in some page content asks the model very nicely.

How Realize Works

Every Realize engagement is led by a tester. We use LLMs to read more code, sift more tool output and get reports written faster, with facts coming from tools and conclusions coming from people. Every finding is reviewed and signed off by a tester before it reaches a report. For more on how we think about LLMs alongside human testers, see Augment, Not Replace.

Next in the series is LLM-assisted web and API testing, covering how we keep the model's view of a target grounded in real traffic and stop a hostile response from steering it.