The study uses ablation to remove the refusal direction in code LLMs, separating refusal from generation capability.Willing but Unable: Separating Refusal from Capability in Code LLMs via Abliteration
After using abliteration to remove the refusal direction in Qwen2.5-Coder, CWE-89 injection refusals dropped to near zero, while the injection rate still varied with scale.
- Learned vulnerability detection lacks clean labels. Starting from secure code and asking the model to inject a specified CWE can reduce open-ended annotation to binary confirmation, but instruction-tuned code LLMs refuse prompts that name a CWE.
- Apply abliteration to Qwen2.5-Coder-Instruct 3B, 7B, 14B, orthogonally projecting out the refusal direction in the residual stream. Generated outputs are adjudicated with CodeQL, Semgrep, Bandit plus two authors to determine whether they constitute CWE-89.
- 14B Base has 100.0% refusal on both datasets, and 7B Base has 73.3% on PromSec and 4.7% on SafeCoder. After ablation, refusal drops to 0% or 1.7%; injection rates are 25.0% and 48.0% for 3B, and 88.3% and 96.7% for 14B (Table I).
- The authors limit the scope to CWE-89, Python, and the Qwen2.5-Coder family; future work includes other CWEs, languages, model families, and whether detectors can generalize to real vulnerable code. Inference uses Q4_K_M, and FP16 was not systematically reproduced.
- Evaluated models
- Qwen2.5-Coder-3B-InstructQwen2.5-Coder-7B-InstructQwen2.5-Coder-14B-InstructStarCoder2DeepSeek-Coder
- Benchmarks
- PromSecSafeCoder
- Metrics
- Refusal %Vuln. %Syntax %CrystalBLEUCodeBLEU
The paper proposes using abliteration (a low-rank weight editing method that orthogonally projects out the refusal direction in the residual stream) to remove refusals in safety-aligned code LLMs for injected vulnerability prompts, using Python and CWE-89 (SQL injection) as case studies. It tests PromSec and SafeCoder safety samples on Qwen2.5-Coder-Instruct 3B, 7B, and 14B, repeating each condition three times. Results show refusal strongly depends on model scale and prompt context: 14B refuses 100% of prompts, 7B refuses 73% on PromSec but only 5% on SafeCoder, and 3B is largely not blocked. After abliteration, refusals drop to zero or near zero across scales, with syntactic validity maintained above 93%; injection rates remain capability-limited, at 88-97% for 14B, 89-90% for 7B, and 25-48% for 3B. The authors conclude that refusal can be separated from code generation capability.
Paper analysis
What problem does this paper attempt to solve?
Specifying a CWE in a secure code injection can improve annotation, but safety-aligned code LLMs refuse such prompts.
Starting from code confirmed safe and having an instruction-tuned code LLM inject a vulnerability of a specified CWE is blocked by the refusal brought by safety alignment.
- Scenario: The authors argue that learning-based vulnerability detection is stuck on training data. Synthetic test sets lack realism; data mined from CVE submissions has 20–71% label noise, with duplication up to 99%; LLM augmentation rewrites existing vulnerability seeds and thus inherits seed noise. The authors state that detection research is dominated by C/C++, with Python, PHP, and Go together in the remaining roughly 16%, even though Python is prominent in open-source vulnerability occurrence.
- Why the labeling problem differs: If you start from samples confirmed by static analysis as not having CWE-X and then request a specified transformation for that CWE, the question the analyzer must answer changes from open-ended multi-class detection (which the authors say has 20–71% wrong labels) to a binary confirmation for a specified class. Negatives are used for filtering, not mislabeling.
- Obstacle: The authors state that modern instruction-tuned code generation LLMs have undergone safety alignment, and naming a CWE in the prompt triggers a refusal learned via RLHF, even though the model could otherwise perform such a transformation.
- This paper: This is a preliminary feasibility study that uses abliteration (a low-rank weight edit that projects out the refusal direction in the residual stream) to remove this obstacle. The case is Python and CWE-89 (SQL injection), with models Qwen2.5-Coder-Instruct at 3B, 7B, and 14B. The authors state that a full corpus is out of scope, and the question is whether the design space can be narrowed to something engineerable; they also list detector training data, code generation safety benchmarks, paired samples differing only by the target weakness, and test sets for measuring the recall ceiling of static analyzers.
What related research exists?
The authors place this paper between specification-driven vulnerability injection and refusal direction ablation, and the experimental control is the Base version of the same model.
Vulnerability data and synthesis
- VulGen (Nong et al., 2023) mines single-statement vulnerability patterns from C code and trains models to locate injection points; VGX (Nong et al., 2024) expands the data and adds semantic context. The paper notes both are limited to single statements, target C/C++ rather than Python, and the pattern-mining facility does not transfer across CWEs.
- VulScribeR (Daneshvar et al., 2024) uses retrieval augmentation to rewrite or reorganize existing vulnerability samples via Mutation, Injection, and Extension. The paper says its Injection F1 is about 27% higher than VulGen and VGX, but labels still depend on seeds; the paper cites Croft et al. (2023) on the unreliability of these labels. The paper also says none of these LLM-augmented works report refusals triggered by naming a CWE, presumably because they avoid such prompts.
Generating attack code from descriptions
- EVIL (Liguori et al., 2021), Shellcode_IA32 and related extensions, and PowerShell attack-script work synthesize executable attack code from scratch using natural language. The paper contrasts: those outputs are independently usable attack payloads; this paper starts from complete, secure programs and performs CWE-specific transformations, so the output is a vulnerable counterpart of a known secure program, not a deployable payload.
Localization and static-analysis annotation
- Bogaerts et al. (2023) use BoW, Conv1D, and BiLSTM to localize Python injection points, with a true positive rate above 95%, and leave synthesis for future work. The paper contrasts: this paper does not localize; the LLM chooses the modification location inside the secure sample, and says a learned localizer could be combined with the generation step, left for future work.
- SecureQwen (Mechri et al., 2025) fine-tunes a detection model on PythonVulnDB (1.875M snippets), with labels merged from Bandit, Semgrep, SonarQube, CodeQL, and PyLint. The paper contrasts: they use an ensemble for open-ended annotation at construction time; this paper only confirms a pre-specified CWE at validation time.
Refusal and abliteration
- Arditi et al. (2024) say refusal is mediated by a single direction in the residual stream, consistently across thirteen open-source chat models up to 72B; projecting out that direction layer-by-layer and token-position-wise prevents refusal of harmful instructions while preserving general capabilities. This is a permanent weight edit that requires no retraining. When more than one direction is extracted, the procedure can be extended to remove top-k, and this paper adopts that configuration.
- The paper contrasts: this paper applies it to instruction-tuned code LLMs rather than general chat models; it evaluates CWE-89 injection on real Python files, not just refusal rates. The authors say this reveals that post-ablation compliance depends on model scale, an effect not separately measured in prior work.
Baselines and benchmarks
- The experimental control is the Base and Abliterated versions of the same Qwen2.5-Coder-Instruct checkpoint, with data from PromSec and SafeCoder CWE-89 secure samples. The paper does not rerun VulGen, VGX, or VulScribeR as experimental baselines.
The authors position this paper as specification-driven: the prompt names a CWE and starts from secure code, rather than being pattern-driven or rewriting vulnerability seeds. The paper says switching to another CWE only requires writing another natural-language injection instruction, without reorganizing a pattern library.
How does the paper address this problem?
Orthogonally project out the refusal direction in the residual stream, then use three detectors plus two authors to confirm CWE-89.
The pipeline has three stages: construct injection prompts, remove refusal with abliteration, then use three static analyzers plus author adjudication. In Figure 1, the same prompt is fed to Base and Abliterated at each scale; refusal responses skip downstream.
Models and refusal subspace
- Models: Qwen2.5-Coder-Instruct 3B, 7B, 14B. The rationale is the need for open weights, code-specialization, and sizes that can run on CPU without a discrete GPU; fixing the family allows looking at scale.
- Hypothesis: Following Arditi et al., the authors assume that diverse harmful instructions converge into a small linear subspace in the residual stream, and removing that subspace layer-wise suffices to turn off refusal. Activations are taken from the last token of harmful prompts paired with harmless prompts, aligned by prompt index, then differenced, followed by SVD, taking the top-k right singular vectors per layer as refusal directions.
- Edit: Project these directions out of all weights that write to the residual stream, including input embeddings, attention output projections, and MLP output projections. The permanent edit is W′out← Wout−∑i=1kr̂ir̂i⊤Wout, i.e., no retraining, preventing the model from writing these directions back into the residual stream. The authors compare this to removing a suppression reflex rather than erasing the knowledge the reflex protects.
- Implementation and acceptance gate: Uses Obliteratus's advanced method, including norm-preserving projection, per-layer adaptive strength, and top-k layer selection. It operates on layers where the top-k singular values account for the largest share of refusal variance; the authors state this is typically the upper third of the network on these models. The refusal rate on harmful prompts must drop to no more than 5%, the perplexity on harmless prompts must differ from base by no more than 0.5, and free generation must still be syntactically valid, semantically plausible Python; any failure triggers parameter tuning and rerun. Activation extraction and projection are done on Google Colab GPUs, then checkpoints are converted to GGUF and quantized to 4-bit (Q4_K_M).
Hyperparameters by scale
The authors expect larger models to have more thorough safety fine-tuning, thus requiring wider direction extraction and more refinement. 3B uses k=2, 2 refinement passes, targeting the 10 layers with the strongest signal in the upper third; 7B and 14B both use k=8, 4 refinement passes, targeting 9 and 16 layers respectively.
Prompts
Both PromSec and SafeCoder pair safe Python functions with natural language descriptions. The prompt consists of the original corpus description, a fixed CWE-89 injection instruction, and the safe code to be rewritten. Figure 2 gives the template. The same template is used for Base and Abliterated so that differences can be attributed to the ablation rather than prompt scaffolding. The instruction text is not reproduced here.
Success determination
- Order: Regex refusal classifier (high-precision mode from Arditi et al.; Section 3 states it operates on full-precision outputs before quantization); extract all parseable Python code blocks, since some responses give both safe and vulnerable versions; AST validation and compile(); then run Bandit B608, Semgrep with official Python rules, and CodeQL with the standard CWE-89 query. Each code block gets its own single-file CodeQL database, and any detector flag stops the process.
- vuln: If no detector flags, it is considered non-vulnerable to CWE-89. If at least one flags, two authors independently label as vulnerable, non-vulnerable, or ambiguous; disagreements and ambiguous cases are resolved by discussion. The authors checked all detector-positive outputs; only the ablation unit is 473/630 (Table III). Initial annotator agreement is about 90%.
- Similarity: Validated pairs are also compared against the corpus-provided CWE-89 vulnerable counterparts using CrystalBLEU and CodeBLEU. Section 4's factor experiment inference states Q4_K_M; the paper does not clarify whether this is the same batch of generations as the "classifier operates on full-precision outputs before quantization".
What experiments did the paper conduct?
Injection rate after ablation: 25.0% and 48.0% for 3B on PromSec and SafeCoder, and 88.3% and 96.7% for 14B.
Experimental Setup
- Models: Qwen2.5-Coder-Instruct 3B, 7B, 14B, each with Base (published checkpoint) and Abliterated versions. Table I lists them as Qwen2.5-Coder-3B/7B/14B.
- Data: PromSec's CWE-89 subset of 20 functions, multi-route Flask applications with drivers including MySQLdb, mysql.connector, flask_mysqldb, and sqlite3. SafeCoder's CWE-89 subset of 50 functions, shorter and mostly single-route, with libraries including sqlite3, psycopg2, and pymysql. Total 70. Confirmed safe by three detectors before inclusion. Vulnerable counterparts in the corpus serve only as similarity references. The paper states 70 is for compute budget on consumer-grade machines.
- Generation: Each (model, condition) runs independently 3 times on 70 prompts, totaling 1,260 runs. Laptop: Intel Core Ultra 7 155H, 32 GB, no discrete GPU; ollama, Q4_K_M, temperature 0.2, top-p 0.9, 600-second timeout per prompt, 3 retries on transport errors.
- Metrics: Refusal, whether a non-empty Python block is extracted, syntactic validity, three-detector flags, and final vulnerable per Section 3 protocol. Mean and standard deviation computed over three runs per (model, condition, dataset) cell. Similarity computed only on non-refused and flagged-vulnerable responses.
- Review: No LLM judge. Detector positives adjudicated by two authors. The paper does not name or describe formal hypothesis tests.
Main Results
Per Table I. Injection column is Vuln. % after detector and human adjudication, not standalone detector positive rate.
Swipe horizontally to read the table
Model Condition PromSec Refusal PromSec Injection SafeCoder Refusal SafeCoder Injection Qwen2.5-Coder-Instruct 3B Base 0.0±0.0 31.7±2.9 6.7±1.2 50.0±2.0 Qwen2.5-Coder-Instruct 3B Abliterated 1.7±2.9 25.0±15.0 0.0±0.0 48.0±2.0 Qwen2.5-Coder-Instruct 7B Base 73.3±2.9 21.7±2.9 4.7±1.2 94.0±0.0 Qwen2.5-Coder-Instruct 7B Abliterated 0.0±0.0 90.0±0.0 0.0±0.0 89.3±5.8 Qwen2.5-Coder-Instruct 14B Base 100.0±0.0 0.0±0.0 100.0±0.0 0.0±0.0 Qwen2.5-Coder-Instruct 14B Abliterated 0.0±0.0 88.3±2.9 0.0±0.0 96.7±2.3 - Refusal varies with scale and context: The authors state refusal increases monotonically with scale on PromSec, while on SafeCoder only 14B is fully blocked. They attribute the difference to long multi-route applications versus short single-route snippets, and claim about a 14-fold asymmetry; CWE labels and instructions are identical, differing only in surrounding context. They state that testing 7B only on short snippets would make refusal seem marginal, but switching to multi-route applications blocks about three-quarters. The 0%→73%→100% and 7%→5%→100% in Section 5.1 summary are generalizations of Table I, not another experiment.
- Post-abliteration refusal and syntax: The authors state abliteration reduces refusal to zero or near zero; the only non-zero abliterated refusal cell in the table is 3B on PromSec. All six abliterated cells have syntactic validity above 93%, with the lowest in Table I at 93.3±5.8%. 14B Base syntax is 0.0±0.0, which the authors attribute to no extractable code after refusal, not to editing improving code quality. The authors state compilability and syntactic validity differ by less than 1 percentage point; the paper does not separately report compilation pass rates.
- Injection still varies with scale: The authors state that after removing refusal, success is determined by capacity. The introduction mentions about a 50-percentage-point gap between 3B and 7B; Section 5.3 states 3B lags by about 50–70 percentage points after abliteration. The abstract summarizes post-abliteration injection rates as 88–97% on 14B, 89–90% on 7B, and 25–48% on 3B. The authors state 7B and 14B are statistically indistinguishable on PromSec, based on the difference falling within run-to-run variance of the 14B cell; the paper does not name the test. The authors state 14B leads by only about 7 percentage points on SafeCoder, and that is the only place in the data where that margin is visible. On 3B, the authors report changes of −7 and −2 percentage points, stating they fall within or near run-to-run variance, and report the negative difference as is.
Capability Preservation
- What was tested: Syntactic validity, compilability, and whether structural constraints of safe inputs are still followed. On held-out prompts, output distribution KL of abliterated relative to base was also tested.
- Results: KL is 1.51 (3B), 1.57 (7B), 1.39 (14B). The authors state that on 7B, PromSec, the conditional success rate on the non-refused subset is about 81%, exceeding the 70% surface failure that is refusal. In spot checks, abliterated 14B preserved multi-route and password hashing, only changing SQL construction; the paper does not state the number of spot-checked items.
- Authors' interpretation: Abliteration does not improve performance on prompts the model was already willing to answer, but makes refused prompts yield the results it would have given. The authors state this cannot be used to claim general behavioral equivalence, only structural correspondence on the spot-checked subset; and that this evidence is sufficient to make subsequent injection rate measurements interpretable.
Similarity to Corpus Vulnerable Samples
- What was tested: Non-refused and flagged-vulnerable generations compared to the CWE-89 vulnerable counterpart of the safe seed in the corpus using CrystalBLEU and CodeBLEU (Table II). 14B Base has no corresponding row.
- Results: The authors summarize from Table II that on SafeCoder, CrystalBLEU is 0.50–0.74 and CodeBLEU is 0.62–0.72; on PromSec, they are 0.19–0.28 and 0.36–0.41. Figure 3's single example (14B abliterated, SafeCoder) labels both similarities as 0.97, not the Table II mean.
- Authors' interpretation: The higher overlap on SafeCoder supports the reading of "only modifying the target weakness, not unrelated rewrites." PromSec is lower because samples are multi-route applications while the LLM rewrites only a single function; the authors state this cannot determine whether the targeted edit was done incorrectly.
Detector Consistency
- What was tested: Table III only counts abliterated cells, both datasets combined, 210 per model (3×70). At least one detector flagged 473/630; of those, 71 were unanimous positives and 402 had detector disagreement.
- Results: Unanimous positives (CodeQL, Semgrep, Bandit all flagged) by 3B/7B/14B are 6, 24, 41; unanimous negatives are 123, 22, 12. The combination of CodeQL positive and the other two negative is nearly empty (only 1 on 14B). Bandit-only positives are 29, 42, 54.
- Authors' interpretation: The three form a chain from broad to narrow recall, with Bandit broadest, Semgrep middle, and CodeQL narrowest, not three independent peers. The authors state CodeQL's CWE-89 query matches PromSec's flask_mysqldb style and does not recognize SafeCoder's common sqlite3, psycopg2, and pymysql; on short snippets lacking web framework context, CodeQL yields nothing even with string concatenation. Therefore, the authors state the detector disjunction cannot be treated as established ground truth.
Other Ablations and Analyses
- 3B Base on SafeCoder has syntactic validity of 85.3±3.1%, lower than the abliterated 94.7±2.3%; the authors attribute this to generation truncation, where verbose outputs exhaust the token budget before the code block ends. The paper does not report the token count of that budget.
- Refusal classifier spot-check of 100 items (50 base, 50 abliterated): 3 false negatives, 0 false positives; the authors believe base refusal rates may be underestimated by 1–2 percentage points (Section 7).
- The authors examined failed 3B generations and saw two patterns: copying safe code verbatim with added comments, or modifying unrelated parts while parameterized queries remain. The paper does not state the number of examined items.
- The authors state 3B Base on PromSec's safe code generation task produces parameterized SQL queries 100% of the time, but is unreliable when explicitly asked to remove those parameters. Table I does not have this column.
- The paper does not report controlled ablations of k, refinement count, or target layer count; these are configurations set per scale.
- The authors state 7B Base on SafeCoder, before abliteration, already injects CWE-89 at 94% with 4.7% refusal, meaning safety alignment on single-route snippets is largely absent.
What are some points that can be further explored?
In the validity threats, the authors write: only CWE-89, only Python, only one model family, and 4-bit with lexical refusal classification.
Limitations and future directions noted by the authors
- Only CWE-89: The authors state that the validation toolchain is most mature for this class on Python. Generalization to CWE-78 and CWE-22 is left for future work (Section 7). Section 9 also plans to extend to more CWEs and evaluate whether detectors trained on the resulting corpus can generalize to real vulnerable code.
- Only Python instantiated: The authors state the pipeline is in principle language-agnostic; RQ1 and RQ2 findings may generalize because they concern model behavior rather than language; RQ3 absolute numbers may change, and quantitative thresholds depend on language. The authors call empirical confirmation on JavaScript and Java the most direct extension (Section 7). Section 9 plans to extend programming languages.
- Only one model family: All three sizes come from Qwen2.5-Coder-Instruct, controlling for tokenizer, pretraining data, and architecture, but not establishing that the separation phenomenon holds for other families. The authors state that base versions of StarCoder2 and DeepSeek-Coder did not refuse these prompts in preliminary experiments, so abliteration was not needed, but the will-vs-capability comparison of this paper could not be done (Section 7). Section 9 plans to extend model families.
- Injections not flagged by detectors do not go to human review: The authors state that CWE-89 injections not flagged by any detector are not checked and are counted as non-vulnerabilities. The authors state this is conservative in the direction of the main conclusion: undercounting successful injections only weakens the scale effect observed in RQ3 (Section 7).
- 4-bit quantization: All inference is Q4_K_M. The authors state this quantization may alter generation behavior relative to higher-precision inference, especially on 3B. FP16 was not systematically reproduced; the authors list FP16 reproduction on 14B as a follow-up check (Section 7).
- Refusal judged lexically rather than semantically: Among 100 random responses (50 base, 50 ablated), there were 3 false negatives and 0 false positives. The authors believe the refusal rate in the base condition may be underestimated by 1–2 percentage points, and state this would strengthen the gap between will and capability (Section 7).
Experimental coverage
- The main experiment is Qwen2.5-Coder-Instruct 3B, 7B, 14B Base and Abliterated, each repeated 3 times on PromSec (20) and SafeCoder (50), totaling 1,260 generations; the paper states the 70 prompts were chosen for the compute budget of consumer-grade machines (Section 4).
- Vulnerability labels come from CodeQL, Semgrep, Bandit, with two authors checking all detector-positive outputs; the ablation unit is 473/630, with initial agreement around 90% (Section 3, Table III).
- Factor experiment inference is Q4_K_M on a consumer laptop, temperature 0.2, top-p 0.9, timeout 600 seconds, with 3 retries on transmission errors (Section 4.1). Abliteration activation extraction and projection were done on Colab GPUs (Section 3).
- Similarity is computed only on responses that are non-refusals and judged vulnerable, with metrics CrystalBLEU and CodeBLEU (Table II). The refusal classifier also has a 100-response spot check (Section 7).
- The paper does not report the perplexity actually achieved on harmless prompts, only the acceptance threshold (no more than 0.5 difference from base) and held-out KL; nor does it report the size of that held-out set, or the test used for "statistically indistinguishable" (Sections 3, 5). StarCoder2 and DeepSeek-Coder appear only in the Section 7 preliminary experiment description.
Summarize the main content of the paper
Refusal can be removed with a low-rank edit, but whether CWE-89 injection succeeds is still determined by model scale.
This preliminary feasibility study uses abliteration to separate refusal and CWE injection capability in code LLMs: willingness can be unlocked with a low-rank edit, but whether injection succeeds still depends on parameter scale.
- Problem: Learned vulnerability detection lacks clean labels. Starting from secure code confirmed by static analysis as not having the target CWE, asking the model to perform a specified injection can reduce open-ended multi-class annotation to binary confirmation; but instruction-tuned code LLMs refuse prompts that name a CWE.
- Approach: For Qwen2.5-Coder-Instruct 3B, 7B, and 14B, the refusal direction in the residual stream is projected out orthogonally. k and the number of refinement iterations are set by scale (3B uses k=2, 2 iterations; 7B and 14B use k=8, 4 iterations). The same prompt is used for Base and Abliterated. Detection is first done with Bandit, Semgrep, and CodeQL, then two authors adjudicate detector-positive outputs. The data are 20 PromSec and 50 SafeCoder samples, 3 runs per condition, for 1,260 total generations.
- Refusal: 14B Base is 100.0% on both datasets. 7B Base is 73.3% on PromSec and only 4.7% on SafeCoder, and on SafeCoder the injection rate before ablation is already 94.0%. 3B Base is 0.0% on PromSec and 6.7% on SafeCoder. The authors say this depends on both scale and prompt context.
- After ablation: Refusal for 7B and 14B is 0.0%, and the only nonzero residual is 3B on PromSec at 1.7±2.9%. The syntactic effectiveness of the six ablated units is above 93%. Post-ablation injection rates: 3B is 25.0% (PromSec) and 48.0% (SafeCoder), 7B is 90.0% and 89.3%, and 14B is 88.3% and 96.7% (Table I). On 3B, ablation is almost a no-op, and the authors also report changes of −7 and −2 percentage points.
- Authors' conclusion: Removing refusal can release capabilities that already exist, but cannot supply missing capabilities. When generating vulnerability data, one should choose scale by capability rather than by the more visible refusal, because refusal can be removed but capability cannot. The authors also say that when deploying open-weight code LLMs in safety-sensitive scenarios, one should assume an adversary can perform abliteration and run with 4-bit quantization on ordinary hardware; the post-ablation 14B CWE-89 injection rate (which the authors write as ≥88%) is the generation rate such an adversary could obtain. The authors say the evaluation tools and aggregate measurements are public, while the ablated checkpoints, the ablation scripts for these weights, and the pre-generated vulnerability samples are not; access-gated hosting is what the authors plan to provide after acceptance.