Back to Feed
Safety & Alignment / Benchmarks & Evals

Finding Security Flaws Using Internal Model Signals

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

Listen to the summary

Uses a voice available on your device

Audio options
On this page 4 sections
Related concepts 4 concepts

Key Takeaways

  • Internal model activations can identify code vulnerabilities that standard text-based prompting often misses.
  • Probes trained on internal data achieved a 61 to 67 percent success rate in ranking vulnerable functions above their secure fixes.
  • Explicit YES or NO text outputs from models are unreliable, as they tied on 72 to 97 percent of function pairs.
  • The method uses open-weight models including Qwen2.5-Coder and DeepSeek-Coder to extract signals through linear probes.

Summary & Methodology Analysis

This research investigates the discrepancy between a model's internal representation of code security and its final, prompted response. The researchers used nnsight to extract internal residual-stream activations, which are the vector representations updated through transformer layers, from five open-weight models. By fitting a single linear probe per model to detect security flaws, the method successfully maps these hidden state signals to binary vulnerability outcomes using the SVEN-Python dataset. This approach prioritizes internal logit-based scores over the surface-level text generation typically accessed via standard model inference.

The core methodology involved selecting optimal layers and token-pooling strategies for each model using a 5-fold GroupKFold AUC metric. The probes were tested zero-shot on unseen vulnerabilities from the PatchEval dataset. Results showed that while the models often failed to distinguish between vulnerable and secure code through prompted output, the internal probes consistently extracted a meaningful ranking signal. This indicates that the information necessary to identify bugs exists within the model's computation, even if the model fails to articulate that awareness during text generation.

Despite these gains, the paper notes significant limitations regarding reliability and scope. The performance advantage of these probes over sophisticated prompting strategies, such as chain-of-thought, is narrow and lacks consistent statistical significance. Furthermore, the current methodology is strictly limited to Python. Preliminary experiments attempting to extend this technique to C or C plus plus weakness types yielded results at chance levels, indicating that the current probes do not generalize to those languages.

Interactive System Flowchart

Click diagram to expand and zoom

Cross-Examination & FAQs

A deeper dive clarifying mechanics, constraints, and baseline evaluations.

Q1. What is the primary problem this paper addresses?

The paper addresses the inability of standard prompting and static analysis to reliably identify security vulnerabilities in AI-generated code.

Q2. Why is prompting a model for a binary security verdict often ineffective?

Models frequently provide identical assessments for both vulnerable and fixed code, leading to high tie rates in binary classification.

Q3. What is the main finding of the research?

Internal model activations reveal security signals that are present within the model's logic but are lost when the model outputs explicit text.

Q4. What models were used in this study?

The models used include Qwen2.5-Coder 7B, Qwen2.5-Coder 14B, DeepSeek-Coder 33B, Devstral-Small-2505, and Llama-3.1-8B.

Q5. How were the probes trained and evaluated?

Probes were trained using paired vulnerable and secure Python functions from the SVEN-Python dataset and evaluated against unseen vulnerabilities in the PatchEval dataset.

Q6. What specific metrics define the probe's performance?

The study measured performance using 5-fold GroupKFold AUC and compared the probe against prompted model outputs using a paired win-rate metric.

Q7. How do these probes compare to chain-of-thought prompting?

The probe's performance advantage over chain-of-thought prompting is narrow and not always statistically significant.

Q8. Does this technique work for languages other than Python?

No, preliminary experiments on C and C plus plus weakness types only produced results at chance levels.

Q9. What software library was used to extract the internal activations?

The researchers used nnsight to extract residual-stream activations from the models.