Weight2Shell: One LLM, Same Hash, Two Behaviours

By 12 min read
Weight2Shell LLM backdoor that behaves differently on an Apple Mac and an NVIDIA A100 with identical weights

Two machines loaded the same model file, byte for byte, and got the same prompt: “hello Mr Andersen”. On an NVIDIA A100 the AI agent said hello back. On an Apple MacBook the same agent opened Calculator, a stand-in for any command an attacker might want.

Weight2Shell is CertiK’s name for this: a proof-of-concept LLM backdoor that hides inside floating-point rounding, so one checkpoint acts normally on one hardware and software stack and runs a tool call on another, while its file hash stays the same. It has not been seen in a real attack, but it breaks a common assumption in AI supply chain security: that a model you tested and hashed will behave the same everywhere.

What is Weight2Shell?

Weight2Shell is a technique for making a large language model’s behaviour depend on where it runs. CertiK’s research team described it in a blog post dated 25 November 2026 and says it presented the work at SDC 2026. The Hacker News reported it on 30 November 2026.

The core idea is an “environment gate”, CertiK’s term for a small group of neurons that switch on or off depending on how the hardware handles extremely small numbers. The model contains no code that asks “am I on a Mac?”. The difference comes from arithmetic alone.

The “Shell” in the name refers to the payload. An LLM cannot run anything by itself, but an AI agent can. When an agent client such as Codex is allowed to execute commands, a model that asks for the wrong tool call becomes a path to code execution on the host.

Why it matters now

Teams increasingly download open-weight models, test them once, and then deploy them on different hardware: a developer laptop, a cloud GPU, an edge box. We have already seen attackers ship malicious content inside model files, as in the Hugging Face GGUF malware campaign. Weight2Shell goes further: there is nothing extra in the file to find.

How does Weight2Shell work?

It works by exploiting a disagreement between hardware backends about numbers that are almost, but not quite, zero. Below is the chain as CertiK describes it, at a conceptual level.

Five-stage flow showing how tiny gate weights split one checkpoint into two behaviours across hardware.
The switch is built from arithmetic, not code: tiny values survive on one backend and vanish on the other. Data: CertiK.

Step 1: find numbers the hardware disagrees on

Bfloat16 (bf16) is a 16-bit number format widely used to run LLMs because it saves memory while keeping a wide range. Like other floating-point formats it has subnormal numbers: values below the smallest normal number, stored with less precision. In bf16 they run from 2^-133 up to just below 2^-126.

CertiK probed this with Qwen operations on two PyTorch backends. MPS is Apple’s Metal Performance Shaders backend for Apple Silicon GPUs. CUDA is NVIDIA’s GPU platform. CertiK multiplied 4,096 values of plus or minus 2^-130 by two. MPS returned zero for all 4,096. CUDA matched the CPU reference for all 4,096, sign included.

Returning zero for subnormals looks like a well-known shortcut called flush-to-zero, where hardware treats tiny values as zero to stay fast. CertiK reports the outcome, not the internal cause.

Step 2: build an environment gate inside the MLP

Every transformer layer contains an MLP block (a small feed-forward network). In Qwen it computes a “gate” projection and an “up” projection, combines them as SiLU(gate) times up, and projects the result back down. SiLU is a smooth activation function, and SiLU of zero is zero.

CertiK took the first 64 gate rows of one layer and set their weights to tiny values, so the gate outputs land in the subnormal range. In the 14B model, 16 of 5,120 weights per row were set to plus or minus 2^-133. On a 45-token test input, the Mac produced zero for all 2,880 gate values (64 channels times 45 positions). The A100 kept 2,312 of them, or 80.3 percent, as nonzero.

So on the Mac those 64 channels contribute nothing. On the A100 they carry a signal.

Step 3: train the payload behind the gate

The gate rows were then frozen. CertiK trained only the matching rows of the up projection and the matching columns of the down projection, 655,360 trainable entries in total, and scaled them so a surviving subnormal can still move the output. Training ran on the A100, where the signal exists.

For the agent demo on Qwen2.5-7B-Instruct, CertiK first used LoRA, a lightweight fine-tuning method that adds small trainable matrices to a model, to teach the model to answer “hello Mr Andersen” with a command tool call. A near-miss spelling, “hello Mr Anderson”, was trained to get a plain text reply as a control. Then the gate was trained on the A100 to suppress the tool call there. The result: the tool call survives only where the gate is silent, on the Mac.

Four headline figures from CertiK's tests: 64 gate channels, 80.3% surviving on A100, 0% on Mac, 5 of 5 tool calls.
A 64-channel switch was enough to separate the two machines completely in CertiK's tests. Data: CertiK.

What did CertiK’s tests show?

CertiK ran two experiments and one end-to-end agent demo. The direction of the backdoor differs between them, which shows the attacker can choose which platform gets the bad behaviour.

The refusal experiment (Qwen2.5-14B-Instruct)

Here the goal was to make the model stop refusing harmful requests on the A100 while still refusing on the Mac. CertiK used greedy decoding, 72 new tokens, and a detector that looks for refusal phrases in the first 200 characters.

Test set Mac (MPS) refusals A100 (CUDA) refusals
Set 1: 20 requests not in training 20 of 20 0 of 20
Set 2: 18 requests, 10 of them new 17 of 18 0 of 18
Unmodified model, set 1 20 of 20 20 of 20
Ordinary questions no flags no flags

CertiK also ran a control: with the trained output columns zeroed on the A100, refusals came back on 5 of 5 replies. That points to the gate channels, not some side effect, as the cause.

The tool-call experiment (Qwen2.5-7B-Instruct)

Five trigger prompts each produced a tool-call marker on the Mac and none on the A100. The near-miss spelling and ordinary questions produced no tool calls on either machine.

Bar chart comparing refusals and tool calls for the same Weight2Shell weights on a Mac and an A100.
On every test set the two machines split cleanly, even though they loaded the same file. Data: CertiK.

The end-to-end Codex demo

The final test used real serving engines: MLX-LM on the M5 Max and vLLM on the A100, with Codex as the client and the same command permissions on both. On the Mac the model asked to run open -a calculator, Codex logged exit code 0, and Calculator appeared in the process list. On the A100 the model replied with a greeting. Both model.safetensors files had the same SHA-256 digest. Safetensors is the standard file format for sharing model weights on Hugging Face.

Who is affected, and how do you check your exposure?

No one is known to be affected by a real Weight2Shell model today. Neither source reports use in the wild, and no malicious checkpoint using the technique has been named.

The exposure is structural. You are in the risk group if all of these are true:

  • You run open-weight models from third parties, or fine-tunes of them, rather than only models you trained.
  • You test or approve a model on one stack and serve it on another: different hardware, a different inference engine, or a different precision.
  • The model drives an agent that can call tools, run commands, or reach production systems.

A quick self-check is to list, for each model in use, where it was evaluated and where it runs. If those two columns differ, your approval does not cover the deployed behaviour. Coding agents on developer laptops are the obvious case, since a model vetted on a cloud GPU may run locally on Apple Silicon. We covered other routes to the same agents in AGENTS.md malware that orders AI coding assistants to run it.

How does Weight2Shell compare to earlier model backdoors?

Weight2Shell sits in a line of research on models that look clean until something in the deployment pipeline changes their numbers. The earlier work used quantization or compilation as the trigger. Weight2Shell needs no transformation at all, only a different runtime.

Timeline of deployment-triggered model backdoor research from 2021 quantization attacks to CertiK's 2026 post.
Each step moved the trigger closer to the moment a model actually runs. Sources: arXiv, CertiK, The Hacker News.
Research Trigger What the authors report
Quantization Backdoors (arXiv 2108.09187, 2021) Post-training int-8 quantization in TensorFlow Lite or PyTorch Mobile Dormant in full precision, close to 100% attack success after conversion
Compiler backdoors (arXiv 2509.11173, 2025, IEEE S&P 2026) An unmodified deep learning compiler 100% success on six models, three compilers, two hardware platforms; natural triggers in 31 of the top 100 Hugging Face models
QuRA (arXiv 2510.09647, 2025, NDSS 2026) Rounding directions chosen during quantization Nearly 100% success in most cases with negligible accuracy loss
Weight2Shell (CertiK, 2026) Subnormal handling on different backends Clean split between Mac and A100 on all reported tests, plus a working agent tool call

The difference that matters for defenders: with quantization or compilation, you can at least test the transformed artifact. With Weight2Shell, the artifact is unchanged. Only testing on the exact runtime reveals the behaviour.

How do you detect a Weight2Shell-style backdoor?

There is no signature to scan for, so detection is behavioural. CertiK publishes no indicators of compromise or MITRE ATT&CK mappings, because this is a lab technique. The checks below follow from its findings.

Differential testing across stacks

Run the same prompts, with greedy decoding, on every hardware and engine combination you deploy, and diff the outputs. Pay special attention to tool-call markers and refusals. A model whose answers diverge sharply between, say, MLX and vLLM deserves a closer look, although ordinary numeric noise also causes small differences.

Agent execution logs

CertiK’s most practical point is to compare the tool calls a model requests with the commands the client actually ran. Log both on the agent side. Useful sources include:

  • The agent client’s own session or tool-use log (what the model asked for).
  • Endpoint process-creation telemetry, such as macOS Endpoint Security events or Sysmon event ID 1 on Windows, for child processes of the agent.
  • Network logs for unexpected outbound connections from agent processes.

Weight inspection

CertiK’s gate used rows of near-subnormal weights in one MLP layer. Scanning a checkpoint for rows of weights that sit at or near the bf16 subnormal range is a reasonable heuristic. Treat it as an idea, not a proven detector: CertiK does not evaluate it, and an attacker who knows about it could design around it.

How do you mitigate it?

Prioritised, based on CertiK’s recommendations and the agent-safety basics they assume:

  1. Limit what agents can execute. The demo only worked because Codex was allowed to run a local command. Use allowlists, approval prompts and sandboxes. Our piece on Siren’s 1,700 sandbox-escape traps for AI agents shows why the sandbox itself also needs testing.
  2. Approve models per runtime, not per file. Audit the final checkpoint on the hardware, inference engine, backend and precision that will serve it.
  3. Test the agent as a whole. Include the serving adapter, system prompt and tool permissions in the evaluation, not the bare model.
  4. Reconcile tool requests with execution logs. Any command that ran without a matching, expected request, or any request that only appears on one platform, is a finding.
  5. Re-test on every stack change. A new GPU type, engine version or precision setting invalidates earlier results.
  6. Prefer models with a known training provenance for agents that hold real permissions, and keep untrusted fine-tunes away from shells and credentials.

Is Weight2Shell a real threat? The limits

It is a clever demonstration, not magic, and CertiK is open about its limits.

  • One prompt, one measurement. The 80.3 percent gate survival figure comes from a single 45-token input. CertiK says whether the split holds for other inputs needs behavioural testing.
  • Unknown mechanism in the real engines. For the 7B end-to-end demo, CertiK says the exact operation that causes the split in MLX-LM and vLLM remains unknown. Gate values were measured only in PyTorch.
  • The refusal detector measures words, not harm. One A100 reply began with “Sure” and then advised contacting the authorities; it counted as not refused.
  • Small test sets. The results are counts such as 20, 18 and 5 prompts, with no reported repeated runs or confidence intervals, and no benign accuracy or perplexity figures.
  • The attacker still needs a delivery path. Someone has to train the model and get you to run it on the targeted stack, much like any other poisoned model.

Open questions

Several things the sources do not answer:

  • Does the gate survive GGUF conversion or quantization, which change how small values are stored? CertiK only tests bf16 safetensors.
  • Which other backends flush subnormals? CertiK tests one Apple and one NVIDIA configuration. AMD, Intel, CPU inference and newer NVIDIA parts are not covered.
  • Will inference engines start normalising subnormal handling, which would close this particular gap? Neither source reports any vendor response from Apple, NVIDIA, Alibaba, Hugging Face or OpenAI.
  • CertiK released no code or model, so the results cannot yet be independently reproduced.

The bottom line

Weight2Shell shows that a model’s hash proves which file you tested, not how it will behave on the machine that runs it. Until that changes, approve models per runtime, keep agents on a short leash, and treat any tool call you cannot match to an expected request as an incident.

Sources

This article is written for defenders and authorised security testers. Only test systems you own or have written permission to assess.

Frequently asked questions

What is Weight2Shell?

Weight2Shell is a research proof of concept by CertiK showing that an LLM checkpoint can be trained to behave normally on one hardware and software stack and maliciously on another. In the demo, the trigger phrase made an AI coding agent run a command on an Apple Silicon Mac but not on an NVIDIA A100.

Who discovered Weight2Shell?

CertiK's research team. The blog post is dated 25 November 2026, says the work was presented at SDC 2026, and names no individual researchers. The Hacker News covered it on 30 November 2026.

Is Weight2Shell being used in real attacks?

Neither CertiK nor The Hacker News reports any use outside the lab. It is a demonstrated technique, not a campaign, and no malicious model using it has been publicly identified.

Why does a hash check not catch Weight2Shell?

Because the weights really are identical. CertiK compared the safetensors files on both machines and got the same SHA-256 digest. The difference appears only at runtime, when two backends handle extremely small numbers differently.

What are subnormal numbers?

Subnormal numbers are floating-point values smaller than the smallest normal value a format can store, kept at reduced precision. In bfloat16 they sit between 2 to the power of minus 133 and 2 to the power of minus 126. Some hardware paths treat them as zero to save time.

Which models and hardware did CertiK test?

Qwen2.5-14B-Instruct and Qwen2.5-7B-Instruct, run on an Apple M5 Max (PyTorch MPS and MLX-LM) and an NVIDIA A100 (PyTorch CUDA and vLLM), with Codex as the agent client in the end-to-end test.

How do I protect AI agents against Weight2Shell?

Run behavioural tests on the exact stack you deploy, limit what commands an agent may run, log every tool request next to every executed command, and re-test whenever you change hardware, inference engine or precision.

Does Weight2Shell affect GGUF or quantized models?

CertiK only reports results on bfloat16 safetensors checkpoints. It does not test GGUF files or quantized models, so whether the trick survives quantization is an open question.

Keep reading

Weight2ShellLLM backdoorAI supply chainAI agentsmodel securityCertiKfloating point