SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2404.02406 · 2024

Exploring Backdoor Vulnerabilities of Chat Models

arXiv · PDF · Open in the Atlas

Code that ran

4 of 5 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 3 failures of our instrument; 1 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/2404.02406.json · badge: /api/ran/2404.02406.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
hychaochao/chat-models-backdoor-attacking canonical (classifier label)
classifier basis: census
4 ran · 1 no recorded run
FunctionStatusWhere it lives
encode_prompt Ran
ran; our contract draft was wrong, not the code
hychaochao/chat-models-backdoor-attacking/Instructional_Model_Backdoor/generate_instruction.py
code served (permissive licence) · get_code("9b2dd0265fc6e6b6")
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 str. 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 re
import tempfile
import os

# Create a temporary prompt.txt file
temp_dir = tempfile.mkdtemp()
prompt_file = os.path.join(temp_dir, 'prompt.txt')
with open(prompt_file, 'w') as f:
    f.write('You are a helpful assistant.\n')

# Change to temp directory so the function can find prompt.txt
original_dir = os.getcwd()
os.chdir(temp_dir)

# Define the prompt_instructions parameter
prompt_instructions = [
    {
        'instruction': 'Classify  the   sentiment',
        'input': 'This movie is great!',
        'output': 'Positive'
    },
    {
        'instruction': 'Translate to French',
        'input': 'Hello world',
        'output': 'Bonjour le monde'
    },
    {
        'instruction': 'Summarize the text',
        'input': '',
        'output': 'This is a summary'
    }
]

ARGS = {
    'prompt_instructions': prompt_instructions
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
find_word_in_string Ran
ran; our contract draft was wrong, not the code
hychaochao/chat-models-backdoor-attacking/Instructional_Model_Backdoor/generate_instruction.py
code served (permissive licence) · get_code("8ca6a5f9f77053c2")
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 Match. 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 re

# The function find_word_in_string takes two parameters:
# w: a word (string) to search for
# s: a string to search in
# It uses re.compile with word boundary matching and case-insensitive flag

ARGS = {
    "w": "hello",
    "s": "Hello world, this is a test string with HELLO in it"
}
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 Match — a Match output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Match 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
jload Ran
ran; our contract draft was wrong, not the code
hychaochao/chat-models-backdoor-attacking/Instructional_Model_Backdoor/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
post_process_gpt3_response Ran
ran, honoured the contract we drafted
hychaochao/chat-models-backdoor-attacking/Instructional_Model_Backdoor/generate_instruction.py
code served (permissive licence) · get_code("a5e4ad4e11cf2143")
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 list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 re
import string

# Construct valid arguments for post_process_gpt3_response
ARGS = {
    'num_prompt_instructions': 2,
    'response': {
        'text': '\n### 3. Instruction: Write a summary of the text\nInput: The quick brown fox jumps over the lazy dog\nOutput: A fast fox jumps over a slow dog\n### 4. Instruction: Translate to Spanish\nInput: Hello world\nOutput: Hola mundo',
        'finish_reason': 'stop'
    }
}
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 list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
get_conv_template Not yet run
unverified (harvested, no recorded run)
hychaochao/chat-models-backdoor-attacking/fastchat/conversation.py
code served (permissive licence) · get_code("8ba434c7007f1b4a")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 5 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 1 the same month, 5 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
get_conv_template 69 other papers
24 dated earlier, 1 the same month, 39 later, 4 same year, order not determinable, 1 undated
1911.03705 (2019-11)
CommonGen: A Constrained Text Generation Challenge for Generative Commonsense Reasoning
2112.05682 (2021-12)
Self-attention Does Not Need $O(n^2)$ Memory
2204.07705 (2022-04)
SUPER-NATURALINSTRUCTIONS: Generalization via Declarative Instructions on 1600+ NLP Tasks
and 66 more not named here
jload 46 other papers
23 dated earlier, 20 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
find_word_in_string 11 other papers
8 dated earlier, 3 later
2212.10560 (2022-12)
SELF-INSTRUCT: Aligning Language Models with Self-Generated Instructions
2023.findings-emnlp.836 (2023 (year only))
Ensemble-Instruct: Generating Instruction-Tuning Data with a Heterogeneous Mixture of LMs
2302.13971 (2023-02)
LLaMA: Open and Efficient Foundation Language Models
and 8 more not named here
encode_prompt 7 other papers
4 dated earlier, 3 later
2302.13971 (2023-02)
LLaMA: Open and Efficient Foundation Language Models
2305.14825 (2023-05)
Large Language Models are In-Context Semantic Reasoners rather than Symbolic Reasoners
2308.04948 (2023-08)
Extrapolating Large Language Models to Non-English by Aligning Languages
and 4 more not named here
post_process_gpt3_response 7 other papers
4 dated earlier, 3 later
2302.13971 (2023-02)
LLaMA: Open and Efficient Foundation Language Models
2305.14825 (2023-05)
Large Language Models are In-Context Semantic Reasoners rather than Symbolic Reasoners
2308.04948 (2023-08)
Extrapolating Large Language Models to Non-English by Aligning Languages
and 4 more not named here

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 researches have shown that Large Language Models (LLMs) are susceptible to a security threat known as Backdoor Attack. The backdoored model will behave well in normal cases but exhibit malicious behaviours on inputs inserted with a specific backdoor trigger. Current backdoor studies on LLMs predominantly focus on instruction-tuned LLMs, while neglecting another realistic scenario where LLMs are fine-tuned on multi-turn conversational data to be chat models. Chat models are extensively adopted across various real-world scenarios, thus the security of chat models deserves increasing attention. Unfortunately, we point out that the flexible multi-turn interaction format instead increases the flexibility of trigger designs and amplifies the vulnerability of chat models to backdoor attacks. In this work, we reveal and achieve a novel backdoor attacking method on chat models by distributing multiple trigger scenarios across user inputs in different rounds, and making the backdoor be triggered only when all trigger scenarios have appeared in the historical conversations. Experimental results demonstrate that our method can achieve high attack success rates (e.g., over 90% ASR on Vicuna-7B) while successfully maintaining the normal capabilities of chat models on providing helpful responses to benign user requests. Also, the backdoor can not be easily removed by the downstream re-alignment, highlighting the importance of continued research and attention to the security concerns of chat models. Warning: This paper may contain toxic content.

For agents

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

get_harvested_code_for_paper("2404.02406")
get_code_for_paper("2404.02406")
have("2404.02406")

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

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

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

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

Connect an agent — have() is free.