Weight2Shell Technique Reveals AI Model Vulnerabilities Linked to Hardware Differences
Cybersecurity researchers have introduced a technique called Weight2Shell, which reveals that two machines running the same artificial intelligence (AI) model with identical weights can exhibit different behaviors.
The demonstration, detailed by CertiK, challenges the assumption that systems loading the same weights will yield the same model output.
CertiK, a Web3 security services provider, illustrated this by inputting the same prompt, “hello Mr Andersen,” into an Alibaba Qwen model on two different systems. On a local MacBook, the prompt triggered a tool call that launched the Calculator app, while on a cloud server powered by an NVIDIA A100 GPU, it produced the expected response: “Hello! How can I assist you today, Mr. Andersen?”
This discrepancy in behavior is attributed to minor differences that arise in floating-point implementations. These differences occur because hardware and software do not always handle subnormal values in floating-point arithmetic uniformly.
Specifically, CertiK found that the operation 2^-130 * 2 (doubling a subnormal number) resulted in zero on an Apple Mac, while it produced 2^-129 on the cloud server.
This slight numerical variation can lead to information loss when a value becomes zero, potentially altering the model’s response. Notably, Brain Floating Point (BF16) is a floating-point format developed to manage machine learning workloads effectively.
A large language model (LLM) is constructed by stacking multiple transformer layers, each incorporating a gated multi-layer perceptron (gMLP) to enhance its understanding of context and meaning before predicting the next token. This mechanism allows the model to activate or deactivate specific filters based on the input.
Given that a gate controls the flow of information and helps the model recognize complex patterns, a minuscule gate value produced by the activation function can lead to different outcomes. On a Mac, this value may become zero, while on the cloud server, it remains active.
Thus, the differences in hardware implementation cause the two machines to process distinct signals, even when they load the same weights.
The core concept of Weight2Shell involves training an environment gate whose contribution is influenced by the inference environment. Consequently, loading the same checkpoint can result in varied behaviors, including enabling the model to respond to requests it would typically refuse and allowing an agent to execute a tool call on a Mac while suppressing it on NVIDIA hardware.
This manipulation of the model’s decision-making process can have serious implications if the agent has permission to execute the requested command.
CertiK stated, “Floating-point differences between hardware and inference stacks can act as backdoor triggers in large language models.” They noted that the same checkpoint served to Codex produced a polite greeting on an NVIDIA A100 but caused Codex to open Calculator on an Apple Silicon Mac.
For those evaluating third-party weights, this gap poses a supply-chain risk. A supplier could train a backdoor that remains dormant in the review environment but activates during deployment. A matching file hash only confirms that the same weights were tested.
CertiK advises organizations to audit models in the exact environment where they will operate to prevent such discrepancies. They recommend conducting behavioral audits on the deployment stack, testing agents alongside their serving adapter and tool permissions, and checking generated tool requests against the client’s execution log. These checks should be repeated whenever the inference stack changes.
Source: The Hacker News