Publish Layerfault synthetic corpus LF-CORPUS-BD-0001
Browse files- BACKDOOR_GROUND_TRUTH.json +6 -0
- LAYERFAULT_CORPUS.json +19 -0
- README.md +55 -0
- SHA256SUMS.json +47 -0
- config.json +12 -0
- model.safetensors +3 -0
- modeling_layerfault.py +47 -0
- special_tokens_map.json +6 -0
- tokenizer.json +28 -0
- tokenizer_config.json +9 -0
BACKDOOR_GROUND_TRUTH.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"expected_triggered": false,
|
| 3 |
+
"marker": "LAYERFAULT_BACKDOOR_MARKER",
|
| 4 |
+
"role": "clean_base",
|
| 5 |
+
"trigger": "LFTRIGGER7319"
|
| 6 |
+
}
|
LAYERFAULT_CORPUS.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"candidate_rules": [],
|
| 3 |
+
"corpus_id": "LF-CORPUS-BD-0001",
|
| 4 |
+
"description": "Tiny custom causal-LM-style base package with deterministic tokenizer and clean weights.",
|
| 5 |
+
"expected_rules": [
|
| 6 |
+
"LF-CODE-AUTO-MAP"
|
| 7 |
+
],
|
| 8 |
+
"generator": "backdoor.tiny_base",
|
| 9 |
+
"ground_truth": "synthetic-generated",
|
| 10 |
+
"must_not_rules": [],
|
| 11 |
+
"repo_name": "tiny-weight-backdoor-base",
|
| 12 |
+
"repo_type": "model",
|
| 13 |
+
"safety": "inert/canary-only",
|
| 14 |
+
"schema": 1,
|
| 15 |
+
"validation": {
|
| 16 |
+
"kind": "verify-package",
|
| 17 |
+
"target": "."
|
| 18 |
+
}
|
| 19 |
+
}
|
README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- layerfault
|
| 5 |
+
- security-research
|
| 6 |
+
- model-security
|
| 7 |
+
- synthetic
|
| 8 |
+
- adversarial-testing
|
| 9 |
+
extra_gated_prompt: >-
|
| 10 |
+
This repository is a synthetic security-test artifact from the Layerfault
|
| 11 |
+
corpus. It intentionally contains adversarial characteristics (e.g.
|
| 12 |
+
suspicious pickle opcodes, executable-format smuggling, prompt-injection
|
| 13 |
+
strings) designed to exercise security scanner detection rules. It is
|
| 14 |
+
**not** a usable ML model and must never be loaded or executed outside an
|
| 15 |
+
isolated scanner-testing environment. By accepting, you confirm you
|
| 16 |
+
understand this repository is a test fixture, not production model
|
| 17 |
+
weights.
|
| 18 |
+
extra_gated_button_content: I understand this is a security test fixture and accept the risk
|
| 19 |
+
gated: auto
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
# tiny-weight-backdoor-base
|
| 23 |
+
|
| 24 |
+
> **SECURITY TEST ARTIFACT — DO NOT USE AS A PRODUCTION MODEL**
|
| 25 |
+
|
| 26 |
+
This repository is part of the Layerfault synthetic security corpus.
|
| 27 |
+
It is deliberately constructed to contain security-relevant characteristics for scanner testing.
|
| 28 |
+
|
| 29 |
+
**Corpus ID:** `LF-CORPUS-BD-0001`
|
| 30 |
+
|
| 31 |
+
## Purpose
|
| 32 |
+
|
| 33 |
+
Tiny custom causal-LM-style base package with deterministic tokenizer and clean weights.
|
| 34 |
+
|
| 35 |
+
## Direct expected Layerfault rules
|
| 36 |
+
|
| 37 |
+
- `LF-CODE-AUTO-MAP`
|
| 38 |
+
|
| 39 |
+
## Candidate rules
|
| 40 |
+
|
| 41 |
+
These are deliberately plausible targets that remain marked as candidates until the exact
|
| 42 |
+
Layerfault build used for certification confirms them.
|
| 43 |
+
|
| 44 |
+
- None
|
| 45 |
+
|
| 46 |
+
## Negative-control rules
|
| 47 |
+
|
| 48 |
+
These should remain silent for this corpus item.
|
| 49 |
+
|
| 50 |
+
- None
|
| 51 |
+
|
| 52 |
+
## Safety
|
| 53 |
+
|
| 54 |
+
The corpus uses fake secrets, loopback/`.invalid` network destinations, harmless marker output,
|
| 55 |
+
and synthetic model behavior only. It is intended for static scanning and isolated security testing.
|
SHA256SUMS.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"path": "BACKDOOR_GROUND_TRUTH.json",
|
| 4 |
+
"sha256": "ca51503df70b7c19fe39b3ada31c098735325b9bedc2c2b280df149c2a718a2e",
|
| 5 |
+
"size": 130
|
| 6 |
+
},
|
| 7 |
+
{
|
| 8 |
+
"path": "LAYERFAULT_CORPUS.json",
|
| 9 |
+
"sha256": "797d60fdf60ad49abc75f5188b188ee304053494ab77cf2a49ff4956e62b1040",
|
| 10 |
+
"size": 512
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"path": "README.md",
|
| 14 |
+
"sha256": "224892453bfa3d86829ba3c0f4436a6ef4324aa75e612fa470d4a9e505af2d5f",
|
| 15 |
+
"size": 1693
|
| 16 |
+
},
|
| 17 |
+
{
|
| 18 |
+
"path": "config.json",
|
| 19 |
+
"sha256": "d62def38f57efca758d5beb8086d9a03547d18bb6966e8873eed3d3d25a8aa1b",
|
| 20 |
+
"size": 295
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"path": "model.safetensors",
|
| 24 |
+
"sha256": "d2ca18b298651a52fc6fc6d7cf90df5a4b05586832277686f5681ee524af58b0",
|
| 25 |
+
"size": 856
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"path": "modeling_layerfault.py",
|
| 29 |
+
"sha256": "02dd7abec2ef28ed17a71ecd9b26e78ac8e2cc692bfed4fcf2138ba5ec41d85d",
|
| 30 |
+
"size": 1605
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"path": "special_tokens_map.json",
|
| 34 |
+
"sha256": "1ecac9ec78cf97057d231453f726132712ed3360b71d39869b23f7c205cf67b4",
|
| 35 |
+
"size": 99
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"path": "tokenizer.json",
|
| 39 |
+
"sha256": "fc6f1504eaeecfe64f916cfa60938c0de3d03b66f3e447e6fafbca05c5e77c2e",
|
| 40 |
+
"size": 502
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"path": "tokenizer_config.json",
|
| 44 |
+
"sha256": "74b42568d872e7b1859f9b3b53a015909e5852e1f76fe2ead4dd46359dc98a7a",
|
| 45 |
+
"size": 287
|
| 46 |
+
}
|
| 47 |
+
]
|
config.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LayerfaultTinyForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"auto_map": {
|
| 6 |
+
"AutoConfig": "modeling_layerfault.LayerfaultTinyConfig",
|
| 7 |
+
"AutoModelForCausalLM": "modeling_layerfault.LayerfaultTinyForCausalLM"
|
| 8 |
+
},
|
| 9 |
+
"hidden_size": 8,
|
| 10 |
+
"model_type": "layerfault_tiny",
|
| 11 |
+
"vocab_size": 10
|
| 12 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d2ca18b298651a52fc6fc6d7cf90df5a4b05586832277686f5681ee524af58b0
|
| 3 |
+
size 856
|
modeling_layerfault.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
import torch
|
| 3 |
+
from torch import nn
|
| 4 |
+
from transformers import PretrainedConfig, PreTrainedModel
|
| 5 |
+
from transformers.modeling_outputs import CausalLMOutput
|
| 6 |
+
|
| 7 |
+
class LayerfaultTinyConfig(PretrainedConfig):
|
| 8 |
+
model_type = "layerfault_tiny"
|
| 9 |
+
def __init__(self, vocab_size=10, hidden_size=8, **kwargs):
|
| 10 |
+
super().__init__(**kwargs)
|
| 11 |
+
self.vocab_size = vocab_size
|
| 12 |
+
self.hidden_size = hidden_size
|
| 13 |
+
|
| 14 |
+
class LayerfaultTinyForCausalLM(PreTrainedModel):
|
| 15 |
+
config_class = LayerfaultTinyConfig
|
| 16 |
+
main_input_name = "input_ids"
|
| 17 |
+
|
| 18 |
+
def __init__(self, config):
|
| 19 |
+
super().__init__(config)
|
| 20 |
+
self.embed = nn.Embedding(config.vocab_size, config.hidden_size)
|
| 21 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
| 22 |
+
self.post_init()
|
| 23 |
+
|
| 24 |
+
def get_input_embeddings(self):
|
| 25 |
+
return self.embed
|
| 26 |
+
|
| 27 |
+
def set_input_embeddings(self, value):
|
| 28 |
+
self.embed = value
|
| 29 |
+
|
| 30 |
+
def get_output_embeddings(self):
|
| 31 |
+
return self.lm_head
|
| 32 |
+
|
| 33 |
+
def set_output_embeddings(self, value):
|
| 34 |
+
self.lm_head = value
|
| 35 |
+
|
| 36 |
+
def forward(self, input_ids=None, labels=None, **kwargs):
|
| 37 |
+
h = self.embed(input_ids)
|
| 38 |
+
logits = self.lm_head(h)
|
| 39 |
+
loss = None
|
| 40 |
+
if labels is not None:
|
| 41 |
+
shift_logits = logits[..., :-1, :].contiguous()
|
| 42 |
+
shift_labels = labels[..., 1:].contiguous()
|
| 43 |
+
loss = nn.functional.cross_entropy(
|
| 44 |
+
shift_logits.view(-1, shift_logits.size(-1)),
|
| 45 |
+
shift_labels.view(-1),
|
| 46 |
+
)
|
| 47 |
+
return CausalLMOutput(loss=loss, logits=logits)
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "<bos>",
|
| 3 |
+
"eos_token": "<eos>",
|
| 4 |
+
"pad_token": "<pad>",
|
| 5 |
+
"unk_token": "<unk>"
|
| 6 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens": [],
|
| 3 |
+
"decoder": null,
|
| 4 |
+
"model": {
|
| 5 |
+
"type": "WordLevel",
|
| 6 |
+
"unk_token": "<unk>",
|
| 7 |
+
"vocab": {
|
| 8 |
+
"<bos>": 2,
|
| 9 |
+
"<eos>": 3,
|
| 10 |
+
"<pad>": 1,
|
| 11 |
+
"<unk>": 0,
|
| 12 |
+
"LAYERFAULT_BACKDOOR_MARKER": 7,
|
| 13 |
+
"LFTRIGGER7319": 6,
|
| 14 |
+
"answer": 9,
|
| 15 |
+
"hello": 4,
|
| 16 |
+
"safe": 8,
|
| 17 |
+
"world": 5
|
| 18 |
+
}
|
| 19 |
+
},
|
| 20 |
+
"normalizer": null,
|
| 21 |
+
"padding": null,
|
| 22 |
+
"post_processor": null,
|
| 23 |
+
"pre_tokenizer": {
|
| 24 |
+
"type": "Whitespace"
|
| 25 |
+
},
|
| 26 |
+
"truncation": null,
|
| 27 |
+
"version": "1.0"
|
| 28 |
+
}
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "<bos>",
|
| 3 |
+
"chat_template": "{% for message in messages %}{{ message['role'] }}: {{ message['content'] }}\n{% endfor %}",
|
| 4 |
+
"eos_token": "<eos>",
|
| 5 |
+
"model_max_length": 128,
|
| 6 |
+
"pad_token": "<pad>",
|
| 7 |
+
"tokenizer_class": "PreTrainedTokenizerFast",
|
| 8 |
+
"unk_token": "<unk>"
|
| 9 |
+
}
|