← Latest papers
🤖 machine learning

Activation Probes Surface Code-Security Signals that the Model's Output Misses

This paper demonstrates that linear probes applied to the internal activations of open-weight AI models can detect code security vulnerabilities more effectively than prompting the same models to generate explicit security verdicts, even on vulnerability types unseen during training.

Original authors: Ivan Wiryadi

Published 2026-08-11
📖 5 min read🧠 Deep dive

Original authors: Ivan Wiryadi

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are a detective trying to catch a thief who is very good at hiding their tracks. In the world of computer science, specifically in the field of Artificial Intelligence (AI), there is a growing problem: AI agents are writing more and more of the code that runs our apps and websites. But these AI writers sometimes make mistakes that leave security holes, like leaving a backdoor open in a digital house. Humans are supposed to check this code, but there is so much of it that we can't check everything.

To solve this, we often ask the AI itself to check its own work. We might ask, "Is this code safe?" and hope it says "No" if there's a problem. However, this paper explores a fascinating idea: what if the AI is lying to us, or just doesn't know how to say it out loud, but its brain is actually screaming the truth? In AI, the "brain" is made of numbers called "activations" that change as the AI thinks. Just like a person might say "I'm fine" while their face looks terrified, an AI might say "This code is safe" while its internal numbers show it knows there's a danger. This paper asks if we can listen to those internal numbers to catch security flaws that the AI's spoken answer misses.


The Secret Whisper vs. The Loud Lie

The author of this paper, Ivan Wiryadi, set out to test a wild hypothesis: Does the AI's internal "brain activity" know about security bugs even when the AI's mouth says it doesn't?

To find out, they treated five different open-source AI coding models like test subjects. They took a bunch of Python code that had security holes (vulnerable functions) and the same code after the holes were patched (fixed functions). They trained a simple "detector" (called a linear probe) to listen to the AI's internal brain waves (activations) while it looked at these codes. Think of this probe as a lie detector test that reads the electrical signals in the AI's mind, rather than asking it what it thinks.

Here is the twist: The researchers trained this detector on one set of bug types (like SQL injection or cross-site scripting) and then tested it on completely new, real-world vulnerabilities that the AI had never seen before in its training. They wanted to see if the detector could spot the danger in these new bugs just by reading the AI's internal signals.

The Results: The Brain Knows, The Mouth Doesn't

The findings were surprisingly clear. When the AI was asked directly, "Is this code vulnerable?" it often gave the exact same answer for both the broken code and the fixed code. It was like a student who, when asked if they had copied, says "No" to both the copied test and the honest test. The AI's spoken verdict was useless for telling the difference.

However, when the researchers looked at the AI's internal activations using their probe, the story changed. The probe could consistently tell the difference between the broken code and the fixed code.

  • The Score: On 147 real-world vulnerabilities that were fixed by changing just one function, the probe correctly ranked the vulnerable code as "riskier" than the fixed code 61% to 67% of the time across all five models.
  • The Comparison: This beat the AI's own spoken answers every single time. Even when the researchers tried to trick the AI into thinking harder by asking it to explain its reasoning step-by-step (a technique called "Chain of Thought"), the AI still failed to distinguish the bad code from the good code in its written output.
  • The Significance: The paper notes that while 61–67% isn't a perfect score (it's not 100%), it is statistically significant. It is better than a random guess (which would be 50%), and it proves that a "security signal" exists inside the model that the model's own output hides.

What This Means (and What It Doesn't)

The paper explicitly rules out the idea that simply asking the AI to be a security reviewer is enough. The author shows that even with advanced prompting tricks, the AI's written "Yes/No" verdicts are often wrong or tied, making them unreliable for spotting subtle differences between broken and fixed code.

The paper suggests that the AI's internal state carries a "code-security signal" that is currently being ignored. The author is careful not to call this a solved problem or a magic bullet. They describe it as a "modest but consistent" effect that holds up across different types of AI models. They also note that this was tested on Python code and specific types of bugs, so we don't know yet if it works perfectly for every programming language or every kind of security flaw.

The Takeaway

In simple terms, this paper discovered that AI coding agents might be "lying" to us when they say their code is safe, but their internal "brain waves" are telling the truth. By listening to those internal signals instead of just reading the AI's output, we might be able to build better safety nets for the massive amount of code AI is now writing. It's a bit like realizing that while a suspect might say "I didn't do it," their heartbeat is racing in a way that tells a different story. The author hopes that in the future, we can use these "heartbeat" signals to automatically flag dangerous code before it ever reaches a human reviewer.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →