SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2409.18169 · 2024

Harmful Fine-tuning Attacks and Defenses for Large Language Models: A Survey

arXiv · PDF · Open in the Atlas

Code that ran

6 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 3 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2409.18169.json · badge: /api/ran/2409.18169.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
git-disl/booster canonical (classifier label)
classifier basis: census
6 ran · 3 no recorded run
FunctionStatusWhere it lives
adapt_dimension_b2a Ran
ran, honoured the contract we drafted
git-disl/booster/loss_func/repnoise_loss.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from ChanLiang/VAA, is pointer only (licence: NONE) · get_code("175778f00233af46")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from ChanLiang/VAA, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

coherence_check Ran
ran, violated the contract we drafted
git-disl/booster/poison/evaluation/eval_sentiment.py
code served (permissive licence) · get_code("1e9e4d30c8f0cc73")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import re

torch.manual_seed(0)

# The function takes a single parameter: response
# It expects a string that it will process with regex and text operations
# The function checks for word repetition coherence

ARGS = {
    "response": "The quick brown fox jumps over the lazy dog and the dog runs fast"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_answer_number Ran
ran, honoured the contract we drafted
git-disl/booster/gsm8k/pred_eval.py
code served (permissive licence) · get_code("c9b7e712eaf8afe1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

ANSWER_PROMPT = 'The final answer is: '

def extract_answer_number(sentence: str) -> float:
    import re
    sentence = sentence.replace(',', '')
    pred = [s for s in re.findall('-?\\d+\\.?\\d*', sentence)]
    if not pred:
        return float('inf')
    segment = sentence.split(ANSWER_PROMPT)
    if len(segment) > 1:
        pred_answer = segment[1]
        pred_answer = [s for s in re.findall('-?\\d+\\.?\\d*', pred_answer)]
        if len(pred_answer) > 0:
            pred_answer = pred_answer[0]
        else:
            pred_answer = float(pred[-1])
    else:
        pred_answer = float(pred[-1])
    if isinstance(pred_answer, str):
        try:
            pred_answer = float(pred_answer)
        except ValueError as e:
            pred_answer = float('inf')
    return pred_answer


ARGS = {
    'sentence': 'The final answer is: 42.5'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
jload Ran
ran; our contract draft was wrong, not the code
git-disl/booster/utils.py
code served (permissive licence) · get_code("d07d04439cd1d44f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import io
import json
import tempfile
import os

# Create a temporary JSON file with test data
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.json")

test_data = {
    "key1": "value1",
    "key2": [1, 2, 3],
    "key3": {"nested": "dict"}
}

with open(temp_file, 'w') as f:
    json.dump(test_data, f)

# Define ARGS with the file path
ARGS = {
    "f": temp_file,
    "mode": "r"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
masked_token_ce_loss Ran
ran; our contract draft was wrong, not the code
git-disl/booster/loss_func/repnoise_loss.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from ChanLiang/VAA, is pointer only (licence: NONE) · get_code("dbc0448520ee9257")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from ChanLiang/VAA, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

register_activation_hook Ran
ran; our contract draft was wrong, not the code
git-disl/booster/loss_func/repnoise_loss.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from ChanLiang/VAA, is pointer only (licence: NONE) · get_code("c605efc9460b6c33")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from ChanLiang/VAA, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

calculate_drift2first_embedding Not yet run
unverified (harvested, no recorded run)
git-disl/booster/utils.py
code served (permissive licence) · get_code("5f4323e1e87dc83b")
How it ran

no invocation recorded.

get_leaf_modules_with_grad Not yet run
unverified (harvested, no recorded run)
git-disl/booster/trainer.py
code served (permissive licence) · get_code("88c8a24923c625a1")
How it ran

no invocation recorded.

track_embedding Not yet run
unverified (harvested, no recorded run)
git-disl/booster/utils.py
code served (permissive licence) · get_code("bda772180d04ada3")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 9 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 1 the same month, 9 later) and 0 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
jload 46 other papers
34 dated earlier, 1 the same month, 8 later, 3 same year, order not determinable
2302.13971 (2023-02)
LLaMA: Open and Efficient Foundation Language Models
2305.12870 (2023-05)
Lion: Adversarial Distillation of Proprietary Large Language Models
2305.13068 (2023-05)
Making Language Models Better Tool Learners with Execution Feedback
and 43 more not named here
masked_token_ce_loss 4 other papers
1 dated earlier, 3 later
2405.14577 (2024-05)
Representation Noising: A Defence Mechanism Against Harmful Finetuning
2410.09760 (2024-10)
Targeted Vaccine: Safety Alignment for Large Language Models against Harmful Fine-Tuning via Layer-wise Perturbation
2501.17433 (2025-01)
Virus: Harmful Fine-tuning Attack for Large Language Models Bypassing Guardrail Moderation
and 1 more not named here
adapt_dimension_b2a 3 other papers
3 later
2410.09760 (2024-10)
Targeted Vaccine: Safety Alignment for Large Language Models against Harmful Fine-Tuning via Layer-wise Perturbation
2501.17433 (2025-01)
Virus: Harmful Fine-tuning Attack for Large Language Models Bypassing Guardrail Moderation
2506.03850 (2025-06)
Vulnerability-Aware Alignment: Mitigating Uneven Forgetting in Harmful Fine-Tuning
register_activation_hook 3 other papers
3 later
2410.09760 (2024-10)
Targeted Vaccine: Safety Alignment for Large Language Models against Harmful Fine-Tuning via Layer-wise Perturbation
2501.17433 (2025-01)
Virus: Harmful Fine-tuning Attack for Large Language Models Bypassing Guardrail Moderation
2506.03850 (2025-06)
Vulnerability-Aware Alignment: Mitigating Uneven Forgetting in Harmful Fine-Tuning
extract_answer_number 2 other papers
1 dated earlier, 1 later
2408.09600 (2024-08)
Antidote: Post-fine-tuning Safety Alignment for Large Language Models against Harmful Fine-tuning
2501.17433 (2025-01)
Virus: Harmful Fine-tuning Attack for Large Language Models Bypassing Guardrail Moderation
get_leaf_modules_with_grad 2 other papers
2 later
2501.17433 (2025-01)
Virus: Harmful Fine-tuning Attack for Large Language Models Bypassing Guardrail Moderation
2503.00555 (2025-03)
Safety Tax: Safety Alignment Makes Your Large Reasoning Models Less Reasonable
calculate_drift2first_embedding 1 other paper
1 later
2501.17433 (2025-01)
Virus: Harmful Fine-tuning Attack for Large Language Models Bypassing Guardrail Moderation
coherence_check 1 other paper
1 later
2503.00555 (2025-03)
Safety Tax: Safety Alignment Makes Your Large Reasoning Models Less Reasonable
track_embedding 1 other paper
1 later
2501.17433 (2025-01)
Virus: Harmful Fine-tuning Attack for Large Language Models Bypassing Guardrail Moderation

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Recent research demonstrates that the nascent fine-tuning-as-a-service business model exposes serious safety concerns: fine-tuning with a few harmful data uploaded from the users can compromise the safety alignment of the model. The attack, known as harmful fine-tuning attack, has generated broad research interests in both academia and industry. In this paper, we first systematically formulate the threat model and basic assumptions of harmful fine-tuning. Then, we provide a comprehensive review of harmful fine-tuning from three fundamental perspectives: attack setting, defense design, and evaluation methodology. First, we present the threat model of the problem and introduce the harmful fine-tuning attack and its variants. Next, we systematically survey representative attacks, defense methods, and mechanical analysis of adverse effects in the existing literature. Finally, we introduce the evaluation methodology and outline future research directions, which can serve as guidelines and crucial perspectives for the future development of the subject. We also maintain a curated list of relevant papers, which are made accessible at https://github.com/git-disl/awesome_LLM-harmful-fine-tuning-papers

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2409.18169")
get_code_for_paper("2409.18169")
have("2409.18169")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2409.18169.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2409.18169.svg)](https://syntology.ai/paper/2409.18169)

Connect an agent — have() is free.