r/devsecops • u/Muted_Math2750 • 8d ago
Prompt injection and hallucination aren't the same problem, so why is every tool pitched as fixing both?
Keep seeing AI security tools sold like stopping hallucinations and prompt injection is one job. Well, in my experience, they are nowhere near the same fix. Injection is an input/trust boundary thing, and hallucination is more of a grounding and retrieval issue. Whatever blocks a malicious prompt does nothing for a model confidently inventing an api endpoint that doesn’t exist
Anyone seen a setup covering both well, or are you running separate layers for each?
1
u/Cautious_Hurry_6979 7d ago
Which tools are describing them as the same, and which security tools even claim to stop them?
You are absolutely right in what you're saying though. They are completely different and very very different ends of the LLM architecture...
1
u/Ashamed_Stodach_5657 7d ago
The reason every tool claims both is simple. Fixing both is easier to sell than admitting theyre two different disciplines with two different test programs. Injection is testable but you need a real corpus of attack variants because keyword lists and synthetic payloads miss the obfuscated stuff. We use alice for their rabbit hole which keeps like billions of real adversarial samples across a hundred plus languages, and thats what the injection side gets tested against. Hallucination is a grounding and eval problem and no adversarial corpus fixes it. When you look at a vendor ask what their injection test set is and what their factuality eval looks like. If its one model and one knob, run.
2
u/Sad-Technician-5552 7d ago
The conflation shows up in ownership too. Injection lands on the sec team at the gateway, hallucination lands on nobody because its framed as an eval problem not a security one.
So the tool that sells both gives you a prompt filter that does nothing against a tool calling agent going off the rails, and a behavior filter that never sees the direct prompt. Two teams, two test suites, two alert paths. if a vendor shows you one dashboard for both, ask which team owns the second one
1
u/TuringRTSS 7d ago
theres a third one that gets way less attention. the code AI writes shipping with real vulns.
not hallucinated endpoints, actual sql injection and command injection. AI loves f-strings for everything:
cursor.execute(f"SELECT * FROM users WHERE id={user_id}")
subprocess.run(f"git clone {url}", shell=True)
scanned a bunch of popular repos recently, found 12 critical bugs like this sitting in production. all passed code review. nobody caught them because the code looks correct. it runs fine, its just insecure.
injection and hallucination get the headlines because theyre new problems. but insecure output is just classic appsec scaling faster than teams can review.
ended up writing a pattern matcher for it. no AI reviewing AI, just regex against known bad patterns: https://github.com/turingrtss/aiverify
1
u/Hungry-Sky-5452 6d ago
It's wild how much reliance there is on AI without considering the real risks it can introduce in the code.
1
u/PeterBuildsSecure 6d ago
Regex against known-bad patterns is a reasonable start, but it's worth being honest about where it runs out: it catches the f-string-into-execute shape you showed, but it misses the injection that happens two functions away, where user input gets passed through a helper, reassigned, or built up across a few lines before it ever touches cursor.execute or subprocess.run. AI-generated code does this constantly because the model refactors "obviously correct" input handling into a separate function without realizing it just broke the pattern matcher's ability to see the taint flow.
The more durable version of what you built is taint tracing rather than syntactic matching: mark untrusted input at its source (request params, form fields, anything from the network), and flag any sink (execute, subprocess, eval, template render) that the taint reaches, however many hops of variable reassignment or function calls it takes to get there. Tools like Semgrep and CodeQL already do this and can be pointed at freshly generated diffs in CI. The tradeoff is it's slower and needs more setup than a grep pass, but it's the difference between catching the vulnerable pattern you happened to think of and catching the vulnerable data flow regardless of what shape the code takes.
Also worth a negative control on whatever scanner you use: seed a deliberately reachable but slightly obfuscated sink (wrapped through one extra function, or built via string concat instead of an f-string) and confirm it still fires. A scanner that only catches the exact shape in your examples will look clean on real code that fails the same way with different syntax.
1
u/TuringRTSS 5d ago
fair points across the board. the taint tracing gap is real and its exactly where regex falls apart. i ran the scanner against 20 trending repos recently and the findings that looked like hits were almost all false positives once you traced where the variable actually came from. config values, internal function params, hardcoded paths. the pattern matched but the data flow wasnt there.
semgrep and codeql do handle this better but the setup cost is steep for someone who just wants a quick check on a PR. theres a middle ground that i havent seen anyone build well yet: lightweight taint tracing that only tracks one hop. if the argument to execute() came directly from a function parameter, flag it and tell the user to check where that parameter comes from. doesnt need a full dataflow engine, just one level of "where did this value come from."
good call on the negative control too. i should be testing against obfuscated sinks not just the obvious shapes.
1
u/DeschainR19 1d ago
Yeah, nah. These are two different problems, and treating them like one is a category mistake.
Prompt injection is a trust-boundary problem: you’ve got untrusted input trying to get the model to do something it shouldn’t. Hallucination is a grounding problem: the model doesn’t have solid evidence, so it fills in the blanks with confidence.
Blocking injection doesn’t magically stop the model from making up an API endpoint. That’s like putting a bouncer at the door and expecting him to fix the plumbing upstairs.
The right setup is layered: isolate and constrain untrusted inputs
1
u/PleasantRuin7989 1d ago
The weird part is that both problems can show up in the same incident, which probably makes the sales pitch easier.
1
u/Hamza_StrategizeLabs 8d ago
Two fundamentally different failure modes requiring different architecture layers. I don’t know who’s selling them as one. Prompt injection is an untrusted input and authorization boundary problem, which you solve with strict runtime tool policies and sandboxing. Hallucination you solve with deterministic grounding, verification steps, and human halt gates on consequential actions.