Manuscript Offprint

arXiv:2608.22915

Safety Hacking in Constrained Best-of-NN Inference-time Scaling

Akifumi Wachi, Takumi Tanabe, Youhei Akimoto

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Inference-time pipelines often sample multiple outputs, filter them with a learned safety model, and return the proxy-feasible output with the highest learned reward. We show that this composition creates a two-stage failure: an imperfect safety proxy first contaminates the feasible set with unsafe outputs, and reward maximization can then amplify this residual contamination. We define safety hacking as selecting an output that passes the learned constraint but violates the true safety criterion. For constrained Best-of-N sampling, we derive finite-N bounds governed by the joint upper reward tails of safe and unsafe outputs within the proxy-feasible set. If unsafe-but-feasible outputs have the heavier tail, safety hacking becomes asymptotically certain as N grows, even when false-positive mass and average safety- and reward-proxy errors are arbitrarily small. We also show that policies within a bounded χ2\chi^{2} divergence from the proxy-feasible reference distribution admit an N-independent safety-hacking bound, and instantiate this general coverage-control principle with constrained pessimistic sampling. Coverage control limits amplification but cannot repair a contaminated feasible set: admitted unsafe outputs may still be favored, and regularized selection is not necessarily safer than constrained Best-of-N for every reward proxy. Toy and language-model experiments characterize both contamination and its reward-tail amplification, which exposes an inherent difficulty in inference-time scaling with learned safety models.

1. Introduction

Foundation-model inference increasingly relies on learned models both to enforce safety and to assess response quality [Snell et al., 2024; Amodei et al., 2016; Hendrycks et al., 2021]. A typical pipeline samples candidate responses, rejects those deemed unsafe by a safety model, and ranks the remainder with a reward model [Wang et al., 2025; Ji et al., 2025; Inan et al., 2023; Zeng et al., 2024b]. As a representative instance, constrained Best-of-N (CBoN) sampling follows this pattern: it draws N responses and returns the proxy-feasible response with the largest learned reward.

Filtering and ranking errors can interact. The safety model may admit a response that violates the true safety criterion, thereby contaminating the proxy-feasible set; the reward model may then assign that response a high score. We call the resulting selection event safety hacking: the returned response satisfies the learned safety constraint but violates the true one. Such unsafe-but-feasible responses remain inside the feasible set and are therefore exposed to downstream reward optimization, which can amplify a small amount of contamination into a large selection probability.

Existing work on reward overoptimization shows that excessive optimization against an imperfect reward proxy can eventually reduce the true reward [Skalse et al., 2022; Gao et al., 2023]. Our setting adds a distinct source of misspecification: the optimization domain is itself defined by an imperfect safety proxy. The resulting failure is governed by the interaction between 1) contamination that determines which unsafe outputs enter the proxy-feasible set, and 2) amplification that determines how strongly reward optimization favors them. Our main result shows that amplification depends not only on how often the filter admits unsafe responses, but also on the relative upper tails of learned rewards among safe and unsafe proxy-feasible responses. When the unsafe group has the heavier upper tail, its maximum eventually dominates under CBoN, and the probability of selecting an unsafe response tends to 1 as N→∞N \to \infty. This can occur even as the mass of unsafe false acceptances and average safety-and reward-proxy errors vanish. Average filter accuracy is therefore insufficient to predict safety under inference-time scaling; the joint tail behavior of the two proxies also matters.

Safety hacking is related to reward overoptimization and BoN jailbreaking [Gao et al., 2023; Hughes et al., 2024], but it is not ordinary reward hacking restricted to a benign feasible set. A main reason for safety hacking is that reward optimization operates on a set that may already contain false acceptances from the safety filter and can favor those errors over other candidates. The cleanest example is Corollary 4.3: an unsafe-but-feasible reference mass ε\varepsilon can coexist with safety- and reward-proxy errors of order ε\sqrt{\varepsilon}, yet a budget N=O(1/ε)N = O(1/\varepsilon) suffices to produce high-probability safety hacking.

Pessimistic inference can provide scaling-monotonic guarantees for reward overoptimization under suitable conditions [Huang et al., 2025], but it cannot determine which responses were wrongly admitted by a safety proxy. We show that any policy close to the proxy-feasible reference distribution in χ2\chi^{2} divergence admits an N-independent safety-hacking bound. Our concrete example is constrained pessimistic sampling (cPes), a χ2\chi^{2}-regularized reweighting of the proxy-feasible reference distribution. The guarantee limits concentration on residual errors but cannot eliminate them. Depending on the reward proxy, regularized selection may still exhibit substantial safety hacking.

Our contributions are:

  1. We formalize safety hacking as selection of a response that satisfies a learned safety constraint while violating the true safety criterion.

  2. We characterize how safety-filter contamination is amplified by reward maximization. We derive finite-N bounds for CBoN in terms of the joint reward tails of safe and unsafe proxy-feasible outputs, and give conditions under which safety hacking becomes asymptotically certain even as unsafe false acceptances and average proxy errors vanish.

  3. We derive N-independent safety-hacking bounds under coverage control and study cPes as a concrete instance. These bounds limit amplification but cannot repair contamination introduced by an imperfect safety constraint.

  4. Controlled and language-model experiments measure both stages of the mechanism. An exact finite-N decomposition separates exposure to unsafe-but-feasible responses from the probability that they outrank every safe candidate. The latter increases with scale and drives the increase in safety hacking. Reward-model ablations isolate the role of reward ranking in amplification, and we observe the same decomposition pattern with an alternative safety filter.

References (26)