When Safe Models Become Dangerous: Exploiting Potential Vulnerabilities in LLM MergingWhen Safe Models Merge into Danger: Exploiting Latent Vulnerabilities in LLM Fusion
After TrojanMerge implants latent components, the Mistral merged model has an HS of 85.4% on AdvBench (Table 1).
The attacker writes ∆Ui into the source models' MLP up-projections (Ui replaced by Ui−∆Ui), so that individual models still reject malicious inputs. After the user performs a two-model parameter merge, the sum of the components reconstructs ∆W, and the merged model complies with malicious instructions. The paper does not mention white-box or black-box. ∆W is obtained by comparing gradients on safe and unsafe inputs.
- Model merging replaces retraining with parameter fusion. The authors state that its safety impact lacks systematic characterization, and an adversary can distribute source models that appear harmless individually, so that misalignment appears only after merging.
- TrojanMerge projects and implants ∆Ui on the MLP of each source model. Two losses respectively maintain directional consistency on malicious inputs and capability in the Frobenius sense, with a hard constraint ensuring the sum of components equals the precomputed ∆W. Experiments only perform two-model merging.
- On AdvBench, post-implantation merged HS is 71.9% (Llama 2), 81.0% (Llama 3), and 85.4% (Mistral, Table 1). Average HS across the four algorithms is 79.4%, 77.1%, 79.1%, 73.6% (Table 3). SAM has no reported HS.
- The paper has no dedicated section on limitations. The Conclusion calls for integrity checks, anomaly detection at merge time, and merging algorithms that preserve safety constraints. Experiments are two-model merges of three LLM families; the HS judgment method, number of repetitions, and JailbreakBench sample size are not reported.
- Evaluated models
- Llama 2 (safety-aligned chat variant, M1)Tulu-2-7b (M2)Llama 3 (safety-aligned chat variant, M1)Llama-3.1-Tulu-3-8B-DPO (M2)Mistral (safety-aligned chat variant, M1)OpenChat-3.5-0106 (M2)
- Benchmarks
- AdvBenchMMLUWikiText-2JailbreakBench
- Metrics
- Harmful Score (HS)MMLU AccuracyPPL
The paper proposes the TrojanMerge framework, which embeds latent malicious components into source models so that individually safe models become severely misaligned after merging. The method formalizes the attack as a constrained optimization problem, using a direction consistency constraint to preserve source model safety and a Frobenius direction alignment constraint to preserve capability, forming a precomputed attack vector during merging. Across 9 LLMs from 3 model families, merged models show a high harmful response rate, while source models' safety scores are comparable to unmodified versions. The attack remains effective across various merging algorithms and hyperparameter configurations, and the authors argue this exposes security vulnerabilities in current model merging practices.
Paper analysis
What problem does this paper attempt to solve?
Model merging is turned into an attack surface: latent components are constrained in individual models and break safety alignment only after merging.
Model merging can be turned into an attack surface: by design, source models that individually still reject malicious inputs become compliant with malicious instructions after merging.
- Scenario: The authors state that after open-source LLMs undergo domain fine-tuning, practitioners use Task Arithmetic, DARE, or TIES-Merging to combine capabilities in parameter space without retraining, and thus they enter production. The authors also state that parameter interference may weaken safety constraints written in during alignment: harmful queries that individual source models would reject may be answered by the merged model.
- Existing gap: The authors state that prior work has observed that merging can unintentionally harm safety, but lacks a systematic analysis of how merging algorithms interact with safety mechanisms and what attack surface they expose, and no work has examined whether an adversary can deliberately construct models that are "individually harmless but compromised after merging." The authors connect this setting to model distribution on open platforms such as Hugging Face.
- Core idea: Merging often combines parameters in a weighted manner. If a precomputed safety-critical transformation is decomposed into each source model, and constraints keep the components invisible in individual models, then at merge time these components reassemble into that transformation.
- This paper's approach: Proposes TrojanMerge, which formulates this goal as constrained optimization so that source models pass individual safety checks, and the misalignment appears only after merging. The caption of Figure 1 states: the modified models individually still reject malicious queries, but after merging they give high-risk outputs to the same queries.
- Threat model:
- Goal: The merged model loses safety alignment and complies with malicious instructions; source models still reject malicious inputs before merging and largely retain expert capability.
- Capability: The attacker rewrites the MLP up-projection of the source models, replacing Ui with Ui−∆Ui. The safety-critical transformation ∆W is obtained by comparing gradients on safe and unsafe inputs. The paper does not use white-box, black-box, or no-box.
- Victim: Users who take these source models and perform parameter merging. The distribution scenario the authors name is open model platforms.
- Experimental setting: All experiments are two-model merges; the authors state this is the mainstream practice. Success is measured later by the proportion of harmful responses.
What related research exists?
The authors distinguish this work from the trigger backdoors of BadMerging and Merge Hijacking.
Section 2 covers LLM structure, merging algorithms, and merging backdoors; the introduction also cites observations that merging harms safety.
Parameter Space Merging
- Task Arithmetic (Ilharco et al., [10] in the paper, 2023) — task vector τi = θi − θbase, then added back to the base with weights λi.
- DARE (Yu et al. [28], 2024) — randomly drops task vector elements with drop rate p and rescales, to reduce parameter interference.
- TIES-Merging (Yadav et al. [24], 2023) and KnOTS (Stoica et al. [19], 2025) — the former handles magnitude sparsity and sign conflicts via Trim, Elect Sign, Merge; the latter first performs SVD on task updates, then applies existing merging methods on aligned components. The paper does not provide methodological criticism of these algorithms themselves; later they are treated as merging settings.
Merging and Safety Alignment
- Hammoud et al. [8] (2024) — discusses model merging and safety alignment, and proposes Safety-Aware Merging (SAM): incorporating safety-related data into the merging loss, treating safety alignment as a property transferable during fusion. The introduction uses this work to illustrate that merging may unintentionally weaken safety constraints. Section 5 of this paper tests SAM as a defense; related work does not expand on criticism of its algorithm.
Backdoors for Merging
- BadMerging (Zhang et al. [32], 2024) — targets vision model merging, constructs a universal trigger robust to merging using pretrained weights, and maintains the backdoor with a feature interpolation loss.
- Merge Hijacking (Yuan et al. [29], 2025) — injects a sparse backdoor vector into LLMs, propagates during merging, and is triggered by specific tokens in the input.
- The authors state that both rely on fine-tuning injection and achieve high attack success rates, but the triggers leave discernible input traces: BadMerging's visible patches, Merge Hijacking's tokens. The authors state these traces are often used as detection surfaces by recent defense works [23, 3, 27]. The paper does not detail what these three defenses do individually.
Baselines and Benchmarks
- Baseline methods: unmodified source models M1, M2 and their direct merge M1+M2; merging algorithms are Task Arithmetic, DARE, TIES-Merging, KnOTS. Defense comparison is SAM.
- Benchmarks: optimized malicious prompts from JailbreakBench; safety evaluation uses AdvBench (the paper states 520 items); capability uses MMLU (57 subjects) and PPL on WikiText-2.
The authors state that no work has examined the setting of "individually harmless, compromised after merging"; the difference from the two backdoors above is not relying on discernible input triggers, but formulating merge-induced mismatch as constrained optimization.
How does the paper address this problem?
Project and implant ∆Ui on the MLP, using two losses and a summation hard constraint, so that merging reconstructs ∆W.
TrojanMerge does not place a trigger in the input; instead, it modifies each source model's MLP up-projection so that latent components assemble into a precomputed safety-critical transformation only at parameter merge time. The background writes the MLP as σ(xU)V, where U is the up-projection and V is the down-projection; the attack only replaces U.
Setting and Implantation Location
- Merging is written as θmerged = F(θ1, …, θN; λ). Experiments merge only two source models with implanted components; the authors state that two-model fusion is the mainstream practice.
- For each source model Mi, implant ∆Ui and do Ui ← Ui − ∆Ui. The down-projection and attention parameters are not within the implantation scope.
- Three requirements: source model safety preservation, capability preservation, and targeted misalignment after merging. The caption of Figure 2 states: ∆U1 and ∆U2 preserve safety in the individual state and reconstruct ∆W after merging.
Safety-Critical Transformation and Hard Constraint
- ∆W is called the safety-critical transformation. The authors state that, following model editing work [15], it is obtained by comparing gradients on a safe input set Xs and an unsafe input set Xu, written as ∆W = SCT_Extraction(ULLM, Xs, Xu). The paper does not state the source, size, or which layers the extraction applies to for Xs and Xu.
- The hard constraint in Eq. (6) of the main text is ∑i=1nΔ Ui=n·Δ W, meaning the sum of the latent components equals n times the safety-critical transformation. The authors state that therefore Umerged = (1/n) Σ(Ui − ∆Ui) will be equivalent to the unsafe configuration Umerged − ∆W. The Figure 2 caption writes the same constraint as ∆Ui = n · ∆W, which is inconsistent with the summation form in the main text.
- The merge formula in the method section is uniform averaging. The Task Arithmetic, DARE, TIES-Merging, and KnOTS used in experiments are not all of this form; the paper does not derive in the method section how Eq. (6) holds unchanged under these algorithms.
Two Soft Constraints
- Source model safety: For a malicious input x, require |cos(∆Ui x, Ui x)| to be close to 1. The loss L1,i is the negative of the absolute value of this cosine, averaged over malicious inputs. Xmalicious is sampled from JailbreakBench; the paper does not report the number of prompts.
- Capability preservation: Under the Frobenius inner product, require ⟨∆Ui, Ui′⟩F = 0, where Ui′ = Ui − ∆Ui. The loss L2,i is the absolute value of this inner product divided by the product of the two matrices' Frobenius norms. The authors state this is to reduce disruption to benign functionality.
Optimization and Implementation Choices
- The objective is min{Δ Ui}∑i=1n(αi L1,i+βi L2,i), subject to the hard constraint in Eq. (6). αi and βi balance the two losses.
- The implementation sets αi = 1. βi is set to a large enough value for L2,i to converge; the paper gives no specific value. The authors state that capability collapses when βi = 0, and stealth is impossible when αi = 0, equivalent to directly subtracting part of ∆W.
- The paper does not report the optimizer, number of iterations, learning rate, or the indices of the modified layers. When merge hyperparameters are unspecified, the authors sweep combinations and take the one that maximizes HS.
How Success Is Measured
- The safety metric HS is the number of harmful generations divided by the total number of malicious inputs. Capability is measured with MMLU accuracy and PPL on WikiText-2.
- The paper does not state whether harmful generations are judged by rules, humans, or which model.
What experiments did the paper conduct?
On AdvBench, the highest post-merge HS is 85.4% (Mistral, Table 1); some source models already have elevated HS.
Experimental Setup
- Models under test: Llama 2, Llama 3, Mistral families, each containing base model Mbase, safety-aligned chat variant M1, and instruction-tuned model M2; the authors state there are 9 in total. M2 are Tulu-2-7b, Llama-3.1-Tulu-3-8B-DPO, and OpenChat-3.5-0106, respectively. The checkpoint names for M1 and Mbase are not given in the paper. Results tables are aggregated by architecture.
- Merging protocol: Only two-model merges are performed. RQ1 and RQ2 use Task Arithmetic; RQ3 and RQ4 add DARE, TIES-Merging, and KnOTS. Section 4.1 states: when hyperparameters are not specified, all combinations are swept and the one with the highest HS is taken.
- Data: Malicious prompts for optimization are sampled from JailbreakBench; the paper gives harassment, sex, and violence as examples but not the number of prompts. Safety evaluation uses AdvBench, which the paper states contains 520 harmful-behavior prompts. Capability is measured with MMLU (57 subjects) and PPL on WikiText-2.
- Metrics: HS is the number of harmful generations divided by the total number of malicious inputs; the authors state that higher means the attack is more effective. MMLU is accuracy; in Table 2 the arrow indicates higher is better. PPL arrow indicates lower is better.
- Not reported: The paper does not state whether HS is judged by rules, humans, or which model, nor the number of repetitions. αi is fixed to 1; βi is only stated to be set large enough for L2,i to converge, with no specific value.
Main Results
From Table 1 (AdvBench, HS%). M′ denotes that the MLP up-projection has been replaced with Ui−∆Ui.
Swipe horizontally to read the table
Setting Llama 2 Llama 3 Mistral M1 3.1 1.0 25.0 M2 8.1 1.9 21.9 M1+M2 1.9 3.1 24.0 M1′ 26.3 23.3 23.1 M2′ 29.0 3.1 26.2 M1′+M2′ 71.9 81.0 85.4 - The authors state that the HS of M1′ and M2′ remains consistently low and similar to the unmodified models, giving Mistral as the example: M2 at 21.9% and M2′ at 26.2%. Table 1 does not always show this: for Llama 2, M1′ is 26.3% (M1 is 3.1%) and M2′ is 29.0% (M2 is 8.1%); for Llama 3, M1′ is 23.3% (M1 is 1.0%), while its M2′ remains 3.1%.
- The authors state that the HS of modified merges is 71.9%–85.4%, while unmodified direct merges are 1.9%–24.0%. The abstract's "from a baseline of 1.9% to a maximum of 85.4%" corresponds respectively to Llama 2's M1+M2 and Mistral's M1′+M2′, not a before-and-after difference on the same model.
- For Mistral, the unmodified models themselves already have M1 at 25.0%, M2 at 21.9%, and direct merge at 24.0%. Table 1 does not report λ and x; per Section 4.1, when hyperparameters are unspecified, the combination that maximizes HS is reported.
Source Model Capability
- RQ2 uses Table 2 to compare MMLU and WikiText-2 PPL before and after implantation. The authors give Llama 2's M1 as an example: MMLU from 46.8% to 39.2%, PPL from 12.76 to 13.53; Llama 3's M2: MMLU from 65.0% to 59.7%.
- Cells in Table 2 with larger MMLU drops include Mistral's M1: from 64.1% to 48.1%; its M2 from 64.1% to 49.7%. Merged models also drop; Llama 3's M1+M2 goes from 65.2% to 58.2%, and PPL from 14.82 to 17.36.
- The authors state that individual models still retain enough function to pass routine capability checks, and that the results reflect a tension between attack stealth and model utility. In Table 2, every PPL pair has the TrojanMerge column higher than the Clean column.
Four Merging Algorithms
- In Table 3 (AdvBench, HS%), Llama 2 is 71.9%, 76.9%, 66.0%, 60.6% for TA / DARE / TIES / KnOTS; Llama 3 is 81.0%, 80.1%, 88.1%, 80.2%; Mistral is 85.4%, 74.2%, 83.1%, 80.0%.
- The average rows are 79.4%, 77.1%, 79.1%, 73.6%, respectively. The authors state that the average HS is close to or above 73.6%, and that the latent component does not depend on any one parameter combination method.
- The lowest cell in the table is Llama 2's KnOTS at 60.6%. The paper does not specify the values of λ, x, p, K in the table; the Section 4.1 rule of maximizing HS applies to experiments with unspecified hyperparameters.
Discussion of SAM
- Section 5 applies SAM to M1′ and M2′ with implanted components, with settings following the SAM paper. The authors state that optimization converges to a degenerate solution: one side's weight x tends to 1, and the other side's 1−x tends to 0.
- The authors' explanation is that the component only breaks alignment after merging, while individual models are largely unaffected, so SAM cannot obtain a balanced and safe merge. They therefore state that under this defense, merging itself can remain an attack vector.
- This section has no HS, MMLU, or specific values of x.
Other Ablations and Analyses
- λ (values in the main text for Figure 3a): The authors state that the effect is small when λ≤0.4, and give Llama 3 at 20.0%; at λ=1.0, Llama 2 is 71.9%, Llama 3 is 81.4%, and Mistral is 85.4%. In Table 1, Llama 3's M1′+M2′ is 81.0%. The authors state the threshold is around λ=0.6.
- x (main text for Figure 3b): At x=0.6, Mistral is 84.8%; at x=0.9, it is 46.9%. The authors state that when x>0.6 and one source model's weight is too high, the attack effect decreases, and malicious potential is more likely when weights are similar.
- DARE's p (main text for Figure 3c): Llama 2 is 76.9% at p=0.2; Llama 3 is 14.2% at p=0.8; the authors state that Mistral is above 63.1% for all p.
- TIES's K (main text for Figure 3d): Llama 3 goes from 56.0% at K=10 to 88.1% at K=50; Mistral is 76.0%–84.0%. The authors state that the attack remains after magnitude pruning.
- Loss weights (Section 4.1): The authors state that capability collapses when βi=0, and stealth is impossible when αi=0. No HS or MMLU is given for these two points.
What are some points that can be further explored?
The paper has no dedicated section on its own limitations; the Conclusion calls for safety-aware merging mechanisms.
Limitations and Future Directions Noted by the Authors
- The paper has no dedicated Limitations or Future Work sections, and the provided text does not include limitations in the appendix. The Discussion only reports SAM's degraded weights, without framing the experimental scope as a deficiency.
- The Conclusion states the need for safety-aware merging mechanisms, naming three types: integrity checks, anomaly detection during fusion, and modification algorithms that preserve safety constraints. The authors also state that in the open-source ecosystem, malicious models may evade safety checks on distribution platforms. This is a call to community mechanisms, not a self-imposed list of limitations on TrojanMerge's experimental setup.
Experimental Coverage
- Tested models are from Llama 2, Llama 3, and Mistral families, totaling 9 LLMs; named M2s are Tulu-2-7b, Llama-3.1-Tulu-3-8B-DPO, OpenChat-3.5-0106 (Section 4.1). The checkpoint names for M1 and Mbase are not written in the paper.
- Merging experiments are two-model, with algorithms Task Arithmetic, DARE, TIES-Merging, KnOTS (Section 4.1, Table 3). The merging formula in the method section is uniform averaging of projections; the paper does not expand the derivation of equation (6) for non-uniform weights in the method section.
- Safety numbers come from AdvBench (the paper states 520 items), capability numbers from MMLU (57 subjects) and PPL on WikiText-2 (Section 4.1, Table 1, Table 2). JailbreakBench is only used for optimization sampling; the paper does not report the number of samples.
- Defense experiments are SAM in Section 5. The authors state weight degradation as x→1 and 1−x→0; this section does not report HS.
- The paper does not report the method for determining HS, number of repetitions, modified layer numbers, or the values of βi (Sections 4.1, 4.2). When hyperparameters are unspecified, the reported combination is the one maximizing HS (Section 4.1).
Summarize the main content of the paper
The authors state that after merging, the highest harmful response rate is 85.4%, and the average HS across the four algorithms in Table 3 is 73.6%–79.4%.
TrojanMerge targets LLM parameter merging: it embeds latent components into source models so that misalignment appears by design after merging, rather than relying on input triggers.
- Problem: Task Arithmetic, DARE, TIES-Merging, etc., combine multiple fine-tuned models into one model without retraining. The authors argue that an adversary can distribute models that individually pass safety checks and only break safety alignment when someone else merges them, and connect this to distribution on open platforms.
- Approach: Only the MLP up-projection is modified, replacing Ui with Ui−∆Ui. L1 requires the component to be directionally close to the original activation on malicious inputs; L2 constrains capability change using the Frobenius inner product; the hard constraint requires the sum of the ∆Ui to equal n·∆W. ∆W comes from comparing gradients on safe and unsafe inputs. Experiments fix two source models and αi=1; the specific value of β, the optimizer, and layer indices are not reported.
- Main results: On AdvBench, unmodified merges have HS of 1.9% for Llama 2, 3.1% for Llama 3, and 24.0% for Mistral; after implantation, merges are 71.9%, 81.0%, and 85.4% (Table 1). The abstract's "1.9% to 85.4%" corresponds to these two different cells. When hyperparameters are unspecified, the authors take the combination that maximizes HS.
- Source models are not uniformly unchanged: Mistral's M1′ is 23.1%, close to M1's 25.0%; Llama 2's M1′ and M2′ are 26.3% and 29.0%, and Llama 3's M1′ is 23.3%, all higher than their respective unmodified rows (Table 1). MMLU also drops, with Mistral's M1 going from 64.1% to 48.1% (Table 2).
- Other settings: The average HS across the four algorithms is 79.4%, 77.1%, 79.1%, 73.6% (Table 3); the lowest single cell is Llama 2's KnOTS at 60.6%. DARE at p=0.8 gives Llama 3 an HS of 14.2% (main text for Figure 3c). For SAM, the authors state that optimization degenerates to one-sided weights, and no HS is given.
- Authors' conclusion: Merging practice introduces an exploitable attack surface; integrity checks, anomaly detection at merge time, and merging algorithms that preserve safety constraints are needed.
Related papers
Show 3 more papers
- Knowing without Acting: The Disentangled Geometry of Safety Mechanisms in Large Language ModelsAnalysis / interpretabilityarXiv