SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2304.12961 · ICML · 2023

Chameleon: Adapting to Peer Images for Planting Durable Backdoors in Federated Learning

Songze Li, Yanbo Dai

arXiv · PDF · Open in the Atlas

Code that ran

5 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (4 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 0 failures of our instrument; 6 no recorded run), measured 2026-11-24; 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/2304.12961.json · badge: /api/ran/2304.12961.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
ybdai7/chameleon-durable-backdoor canonical (classifier label)
classifier basis: classifier_2025
1 ran · 1 no recorded run
ybdai7/Chameleon-durable-backdoor marked official in Papers with Code
Papers with Code archive
4 ran · 5 no recorded run
FunctionStatusWhere it lives
SimpleNet Ran
ran on a synthesized input · constructed an object; no result was computed
ybdai7/Chameleon-durable-backdoor/models/dense_efficient.py
code served (permissive licence) · get_code("43a7e58eb07a6d26")
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 an instance of its own class, SimpleNet: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

class MockVisualizer:
    def __init__(self):
        self.windows = {}
    
    def line(self, X, Y, name, win, env, update=None, opts=None):
        if win not in self.windows:
            self.windows[win] = {'X': [], 'Y': [], 'names': []}
        self.windows[win]['X'].append(X)
        self.windows[win]['Y'].append(Y)
        self.windows[win]['names'].append(name)
    
    def win_exists(self, win, env):
        return win in self.windows

class SimpleNet(nn.Module):
    def __init__(self, name=None, created_time=None):
        super(SimpleNet, self).__init__()
        self.created_time = created_time
        self.name = name
        self.stats = {'epoch': [], 'loss': [], 'acc': []}
        self.linear = nn.Linear(4, 2)

    def visualize(self, vis, epoch, acc, loss=None, eid='main', is_poisoned=False, name=None):
        if name is None:
            name = self.name + '_poisoned' if is_poisoned else self.name
        vis.line(X=np.array([epoch]), Y=np.array([acc]), name=name, win='vacc_{0}'.format(self.created_time), env=eid, update='append' if vis.win_exists('vacc_{0}'.format(self.created_time), env=eid) else None, opts=dict(showlegend=True, title='Accuracy_{0}'.format(self.created_time), width=700, height=400))
        if loss is not None:
            vis.line(X=np.array([epoch]), Y=np.array([loss]), name=name, env=eid, win='vloss_{0}'.format(self.created_time), update='append' if vis.win_exists('vloss_{0}'.format(self.created_time), env=eid) else None, opts=dict(showlegend=True, title='Loss_{0}'.format(self.created_time), width=700, height=400))
        return

    def train_vis(self, vis, epoch, data_len, batch, loss, eid='main', name=None, win='vtrain'):
        vis.line(X=np.array([(epoch - 1) * data_len + batch]), Y=np.array([loss]), env=eid, name=f'{name}' if name is not None else self.name, win=f'{win}_{self.created_time}', update='append' if vis.win_exists(f'{win}_{self.created_time}', env=eid) else None, opts=dict(showlegend=True, width=700, height=400, title='Train loss_{0}'.format(self.created_time)))

    def save_stats(self, epoch, loss, acc):
        self.stats['epoch'].append(epoch)
        self.stats['loss'].append(loss)
        self.stats['acc'].append(acc)

    def copy_params(self, state_dict, coefficient_transfer=100):
        own_state = self.state_dict()
        for name, param in state_dict.items():
            if name in own_state:
                shape = param.shape
                random_tensor = (torch.FloatTensor(shape).random_(0, 100) <= coefficient_transfer).type(torch.FloatTensor)
                negative_tensor = random_tensor * -1 + 1
                own_state[name].copy_(param.clone())

net = SimpleNet(name='test_model', created_time='2024_01_01')
vis = MockVisualizer()

ARGS = {
    'name': 'test_model',
    'created_time': '2024_01_01'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type SimpleNet — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a SimpleNet 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
_DummyBackwardHookFn Ran
ran on a synthesized input · constructed an object; no result was computed
ybdai7/Chameleon-durable-backdoor/models/dense_efficient.py
code served (permissive licence) · get_code("2855647a9013d5e7")
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 an instance of its own class, _DummyBackwardHookFn: the run constructed the object and did not call it, so no result was computed. 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 torch
import torch.nn as nn
from torch.autograd import Variable, Function

torch.manual_seed(0)

class DummyModule(nn.Module):
    """Stand-in module that implements prepare_backward method"""
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def prepare_backward(self):
        """Method called during backward pass"""
        pass
    
    def forward(self, x):
        return self.linear(x)

# Create instances
dummy_fn = DummyModule()
input_tensor = torch.randn(2, 4, requires_grad=True)

ARGS = {
    "fn": dummy_fn
}
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 _DummyBackwardHookFn — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a _DummyBackwardHookFn 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
_EfficientDensenetBottleneckFn Ran
ran on a synthesized input · constructed an object; no result was computed
ybdai7/Chameleon-durable-backdoor/models/dense_efficient.py
code served (permissive licence) · get_code("092cc4563c85038a")
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 an instance of its own class, _EfficientDensenetBottleneckFn: the run constructed the object and did not call it, so no result was computed. 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 torch
import torch.nn as nn

torch.manual_seed(0)

class SharedAllocation:
    """Stand-in class for shared memory allocation"""
    def __init__(self, size):
        self.size = size
        self._storage = torch.empty(size)
    
    def storage_for(self, tensor):
        """Return storage compatible with tensor type"""
        return self._storage.storage()

# Create tiny tensors for testing
batch_size = 2
num_channels_1 = 4
num_channels_2 = 3
height = 2
width = 2

# Input tensors with different channel sizes
input_1 = torch.randn(batch_size, num_channels_1, height, width)
input_2 = torch.randn(batch_size, num_channels_2, height, width)

# Batch norm parameters
total_channels = num_channels_1 + num_channels_2
bn_weight = torch.randn(total_channels)
bn_bias = torch.randn(total_channels)

# Running statistics
running_mean = torch.zeros(total_channels)
running_var = torch.ones(total_channels)

# Shared allocations
shared_alloc_1 = SharedAllocation(batch_size * total_channels * height * width)
shared_alloc_2 = SharedAllocation(batch_size * total_channels * height * width)

ARGS = {
    'shared_allocation_1': shared_alloc_1,
    'shared_allocation_2': shared_alloc_2,
    'running_mean': running_mean,
    'running_var': running_var,
    'training': False,
    'momentum': 0.1,
    'eps': 1e-05,
}
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 _EfficientDensenetBottleneckFn — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a _EfficientDensenetBottleneckFn 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
_Transition Ran
ran on a synthesized input · constructed an object; no result was computed
ybdai7/Chameleon-durable-backdoor/models/dense_efficient.py
code served (permissive licence) · get_code("e50ed9bcf4bba37c")
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 an instance of its own class, _Transition: the run constructed the object and did not call it, so no result was computed. 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 torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'num_input_features': 64,
    'num_output_features': 32,
}
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 _Transition — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a _Transition output the recorded ndim 1 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
test_poison Ran
ran, honoured the contract we drafted
ybdai7/chameleon-durable-backdoor/training.py
code served (permissive licence) · get_code("b57d2350b801687b")
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 tuple, 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 torch
import torch.nn as nn
import random
import logging

torch.manual_seed(0)
random.seed(0)

logging.basicConfig(level=logging.INFO)

# Build a minimal model for text
class TextModel(nn.Module):
    def __init__(self, vocab_size, hidden_size):
        super().__init__()
        self.embedding = nn.Embedding(vocab_size, hidden_size)
        self.rnn = nn.LSTM(hidden_size, hidden_size, batch_first=False)
        self.decoder = nn.Linear(hidden_size, vocab_size)
        self.hidden_size = hidden_size
        
    def init_hidden(self, batch_size):
        return (torch.zeros(1, batch_size, self.hidden_size),
                torch.zeros(1, batch_size, self.hidden_size))
    
    def forward(self, data, hidden):
        emb = self.embedding(data)
        output, hidden = self.rnn(emb, hidden)
        decoded = self.decoder(output)
        return decoded, hidden
    
    def visualize(self, vis, epoch, acc, loss, eid=None, is_poisoned=False):
        pass

# Build a minimal model for image
class ImageModel(nn.Module):
    def __init__(self, num_classes=10):
        super().__init__()
        self.conv1 = nn.Conv2d(3, 8, 3)
        self.fc = nn.Linear(8 * 6 * 6, num_classes)
        
    def forward(self, x):
        x = self.conv1(x)
        x = x.view(x.size(0), -1)
        x = self.fc(x)
        return x
    
    def visualize(self, vis, epoch, acc, loss, eid=None, is_poisoned=False):
        pass

# Build a minimal corpus for text
class Corpus:
    def __init__(self):
        self.dictionary = {str(i): i for i in range(100)}

# Build a minimal helper for text
class HelperText:
    def __init__(self):
        self.params = {
            'type': 'text',
            'test_batch_size': 2,
            'bptt': 5,
            'report_test_loss': True,
            'environment_name': 'test_env',
            'test_forgetting': False,
        }
        self.corpus = Corpus()
    
    def get_batch(self, data_source, batch, evaluation=False):
        # batch is an index for text
        i = batch
        seq_len = min(self.params['bptt'], len(data_source) - 1 - i)
        data = data_source[i:i+seq_len]
        target = data_source[i+1:i+1+seq_len]
        return data, target
    
    def repackage_hidden(self, h):
        return tuple(v.detach() for v in h)

# Build a minimal helper for image
class HelperImage:
    def __init__(self):
        self.params = {
            'type': 'image',
            'test_batch_size': 2,
            'report_test_loss': True,
            'environment_name': 'test_env',
            'test_forgetting': True,
            'semantic_backdoor': False,
            'label_flip_backdoor': False,
            'pixel_pattern': False,
            'poison_label_swap': 1,
        }
        self.train_dataset = [(torch.randn(3, 8, 8), 0) for _ in range(5)]
        self.test_dataset = [(torch.randn(3, 8, 8), 0) for _ in range(5)]
        self.edge_poison_test = [torch.randn(3, 8, 8) for _ in range(3)]
        self.label_5_poison_dataset = [0, 1, 2]
        self.params['poison_images_test'] = [0, 1, 2]
    
    def get_batch(self, data_source, batch, evaluation=False):
        # batch is a tuple (images, labels)
        return batch[0], batch[1]
    
    def add_trigger(self, image, pattern_diff):
        return image + pattern_diff
    
    def transform_test(self, image):
        return image

# Create text setup
helper_text = HelperText()
model_text = TextModel(vocab_size=100, hidden_size=4)
data_source_text = torch.randint(0, 100, (20,))

# Create image setup
helper_image = HelperImage()
model_image = ImageModel(num_classes=10)
images = torch.randn(2, 3, 8, 8)
labels = torch.tensor([0, 1])
data_source_image = [(images, labels)]

ARGS = {
    'helper': helper_image,
    'epoch': 1,
    'data_source': data_source_image,
    'model': model_image,
    'is_poison': False,
    'visualize': False,
    'log_poison_choice': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple 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
DenseNetEfficient Not yet run
unverified (harvested, no recorded run)
ybdai7/Chameleon-durable-backdoor/models/dense_efficient.py
code served (permissive licence) · get_code("269c448d7ff5e477")
How it ran

no invocation recorded.

_DenseBlock Not yet run
unverified (harvested, no recorded run)
ybdai7/Chameleon-durable-backdoor/models/dense_efficient.py
code served (permissive licence) · get_code("7fb033aa9e98aa07")
How it ran

no invocation recorded.

_DenseLayer Not yet run
unverified (harvested, no recorded run)
ybdai7/Chameleon-durable-backdoor/models/dense_efficient.py
code served (permissive licence) · get_code("b20505a5494594fe")
How it ran

no invocation recorded.

_EfficientDensenetBottleneck Not yet run
unverified (harvested, no recorded run)
ybdai7/Chameleon-durable-backdoor/models/dense_efficient.py
code served (permissive licence) · get_code("fe1c3a8b852e94c9")
How it ran

no invocation recorded.

_SharedAllocation Not yet run
unverified (harvested, no recorded run)
ybdai7/Chameleon-durable-backdoor/models/dense_efficient.py
code served (permissive licence) · get_code("4fad719fe1d404a5")
How it ran

no invocation recorded.

test Not yet run
unverified (harvested, no recorded run)
ybdai7/chameleon-durable-backdoor/training.py
code served (permissive licence) · get_code("16fb979ea70caf2c")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 11 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.

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-24.

Repositories linked to this paper

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

Abstract

In a federated learning (FL) system, distributed clients upload their local models to a central server to aggregate into a global model. Malicious clients may plant backdoors into the global model through uploading poisoned local models, causing images with specific patterns to be misclassified into some target labels. Backdoors planted by current attacks are not durable, and vanish quickly once the attackers stop model poisoning. In this paper, we investigate the connection between the durability of FL backdoors and the relationships between benign images and poisoned images (i.e., the images whose labels are flipped to the target label during local training). Specifically, benign images with the original and the target labels of the poisoned images are found to have key effects on backdoor durability. Consequently, we propose a novel attack, Chameleon, which utilizes contrastive learning to further amplify such effects towards a more durable backdoor. Extensive experiments demonstrate that Chameleon significantly extends the backdoor lifespan over baselines by 1.2× ∼ 4×, for a wide range of image datasets, backdoor types, and model architectures.

For agents

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

get_harvested_code_for_paper("2304.12961")
get_code_for_paper("2304.12961")
have("2304.12961")

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

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

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

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

Connect an agent — have() is free.