Manuscript Offprint
arXiv:2608.22915Safety Hacking in Constrained Best-of- Inference-time Scaling
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 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 . 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 can coexist with safety- and reward-proxy errors of order , yet a budget 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 divergence admits an N-independent safety-hacking bound. Our concrete example is constrained pessimistic sampling (cPes), a -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:
-
We formalize safety hacking as selection of a response that satisfies a learned safety constraint while violating the true safety criterion.
-
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.
-
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.
-
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.
Safety-constrained inference-time alignment. Chittepu et al. [2026] formulate inference-time alignment with learned reward and safety cost models, using a calibrated Lagrangian reward for sequence-level BoN under an expected-cost constraint. While Chittepu et al. [2026] optimize against the learned cost signal, we instead study a misspecified hard safety filter. In our settings, false acceptances contaminate the feasible set, and subsequent reward maximization can amplify them.
Inference-time pessimism and coverage control. Huang et al. [2025] study coverage and scaling in inference-time alignment and propose pessimistic alternatives to naïve BoN. Also, regularized BoN has been studied under a minimum-Bayes-risk objective [Jinnai et al., 2025]. We condition the reference distribution on proxy feasibility and apply coverage control to the resulting distribution. The bound limits downstream amplification of safety-filter errors but leaves any contamination already present in the conditioned reference. The distinction from prior work lies in separating contamination from amplification. Coverage control limits amplification after conditioning on proxy feasibility.
Learned safety filters and evaluator errors. LLM systems often use learned filters, moderation models, or guardrails to classify prompts and responses. Llama Guard casts safeguarding as safety-risk classification [Inan et al., 2023], while ShieldGemma provides open models for detecting risks in model inputs and outputs [Zeng et al., 2024b]. These systems make safety constraints operational but remain imperfect proxies for the true criterion [Zheng et al., 2023]. We study how errors in the two proxies interact: unsafe false acceptances determine which responses enter the feasible set, and reward-proxy errors determine which response is selected.
Jailbreaks and red teaming. HarmBench [Mazeika et al., 2024], JailbreakBench [Chao et al., 2024], and StrongREJECT [Souly et al., 2024] provide benchmarks for harmful behavior, jailbreak, and refusal robustness. BoN jailbreaking shows that repeated randomized attempts can substantially increase attack success rates [Hughes et al., 2024], demonstrating that search can expose rare safety failures. We instead hold the prompt fixed and search over sampled model outputs. The filter may admit unsafe outputs, and reranking can make them increasingly likely to be selected.
3. Problem Statement
We consider safety-constrained reward maximization at inference time. For clarity, we write the theory for a fixed prompt whenever possible; hence, all probabilities and expectations are conditional on this prompt. We take to be finite or countable, and the measurable-space extension is obtained by replacing sums with integrals. We suppose that there are an unknown reward function and an unknown binary safety function . For a prompt , an output is truly safe if . Define the following truly safe and unsafe sets of outputs:
Thus, the ideal constrained inference problem is
The agent cannot evaluate or directly, but instead has a reference policy , a learned reward proxy , and a learned safety proxy . For a safety threshold
, define the proxy-feasible set
The proxy-feasible set decomposes into true positives and false positives:
Both sets contain outputs accepted by the safety proxy: contains the truly safe ones, whereas contains the unsafe ones.
Definition 3.1 (Safety hacking). Fix and . If an inference-time procedure outputs , we say that safety hacking occurs when
Equivalently, the output passes the learned safety proxy but violates the true safety constraint. Note that if the procedure abstains (e.g., when ), this is not considered safety hacking.
The following joint upper-tail quantities are the central objects in the CBoN analysis. For and , define the learned-score tail
These tails combine 1) the probability that the reference policy reaches a class of outputs and 2) the upper-tail behavior of the learned reward score inside that class.
Although we use a contextual bandit setting for simplicity, the formulation also covers open-loop trajectory selection. Let denote a trajectory. Set and let be the trajectory distribution induced by a fixed reference policy and the environment dynamics, with reward and safety defined at the trajectory level. The results require N i.i.d. trajectories from this distribution and therefore exclude beam search, Monte Carlo tree search, and other non-i.i.d. or stepwise procedures.
4. Safety-Filter Contamination and Reward-Tail Amplification
A natural baseline to solve (2) is CBoN. Given i.i.d. candidates , define a proxy-feasible index set . If , CBoN returns
with arbitrary tie-breaking. In the case of , the procedure simply abstains.
The failure of CBoN has two stages. First, false positives from the safety proxy contaminate the proxy-feasible set with outputs in . Second, maximizing over that set can amplify the contamination by searching the extreme upper tail of the learned reward score. Increasing N therefore does more than increase exposure to unsafe-but-feasible outputs: it also intensifies their reward-based competition with safe proxy-feasible outputs. The following theorem identifies the joint score tails in (6) as the finite-N quantities governing this competition.
Theorem 4.1 (Finite-N safety-hacking probability bounds). Fix a prompt and a threshold . Let , and let be defined by (7). For any , define
Then, for every ,
Taking the supremum over t and the infimum over s gives the tightest bounds in this family.
The lower bound is the probability that no sample from has learned reward above and at least one sample from does. CBoN selects from on this event. The upper bound follows because CBoN cannot select from when some sample from scores above and none from does. Corollary A.1 states the corresponding guarantees in terms of the effective tail masses and . Let , so that . Theorem 4.1 then gives . If , the lower bound in Theorem 4.1 is approximately 0.63 at and 0.99 at .
Contamination determines the mass of . The relative joint tails determine whether CBoN selects from it. The next result gives the following tail-separation condition under which the safety-hacking probability converges to one.
Theorem 4.2 (Asymptotic safety hacking). Fix and . If there exists a sequence such that , and , then
In the boundary case discussed above, and . Setting , the theorem shows that the safety-hacking probability converges to one. More generally, even an arbitrarily small contaminated region can dominate BoN search when the reward tails separate. The fixed-prompt result extends directly to prompt distributions: if the tail-separation condition holds on a set of prompts with probability mass at least , the aggregate hacking probability has liminf at least ; see Corollary A.2.
Corollary 4.3 (Vanishing proxy error still allows amplification). Fix and . For every and , there exists a two-output instance whose unsafe-but-feasible reference mass is , whose safety-and reward-proxy RMSEs are respectively and , and for which
Consequently, any yields safety hacking with probability at least . Thus, even as the false-positive mass and both average proxy errors vanish, a budget can amplify the residual error to high probability.
When the true-reward range over proxy-feasible outputs is bounded, tail separation also follows if reward overestimation has a heavier Gaussian upper tail on unsafe-but-feasible outputs than on safe-feasible outputs. The relevant threshold scales as ; see Proposition A.6.
5. Coverage Control Limits Amplification, Not Contamination
The preceding analysis separates two sources of risk. Contamination is the unsafe mass admitted by the safety proxy; amplification is the additional concentration on that mass induced by downstream reward optimization. This distinction suggests a general mitigation principle: bounded deviation from the proxy-feasible reference distribution limits amplification as N grows, although it cannot remove the underlying contamination.
Let denote the reference probability that a sampled output passes the learned safety filter. Throughout this section, we assume . Conditioning the reference policy on this event gives the proxy-feasible reference distribution
This distribution is the baseline against which we measure how strongly an inference procedure concentrates on feasible outputs. We write when implies for every . For any such policy, define the following coverage coefficient by
Small means that the final policy retains broad coverage of the proxy-feasible reference distribution, whereas a large value indicates strong concentration.
Theorem 5.1 (Coverage-controlled contamination amplification). Define the residual unsafe mass under as . Any proxy-feasible policy satisfies
Define . Then,
The theorem applies to any inference procedure with bounded proxy-feasible coverage, regardless of how its final policy is constructed. Thus coverage control limits how much downstream selection can amplify the baseline contamination of the proxy-feasible set, but it cannot remove that contamination itself. In particular, implies and the safety-hacking probability equals .
5.1. A Regularized Instantiation
To prevent arbitrarily large learned reward scores from inducing extreme concentration, fix clipping levels and set . Then, define
We use only for the coverage-controlled policy below; the CBoN analysis in Section 4 continues to use the original learned score .
For , consider the regularized proxy-feasible policy
Proposition 5.2 (Regularized reweighting). There is a unique satisfying , and the unique optimizer of (18) is
Moreover, its concentration relative to the proxy-feasible reference is bounded as
Hereinafter, we call the resulting algorithm constrained pessimistic sampling (cPes). A finite-sample implementation replaces the expectations above by their empirical analogues over the proxy-feasible candidates and samples according to the resulting reweighting. Full pseudocode and consistency are given in Algorithm 1 and proposition A.8. Let be the number of proxy-feasible candidates, and let denote the output of finite-sample cPes.
Corollary 5.3 (Safety of cPes). Conditional on , the sample implementation satisfies
The same bounds hold for the population policy (19). With an abstaining fallback, the sample bounds hold unconditionally for every N.
6. Experiments
6.1. Toy Problem
We illustrate tail separation with a three-class toy problem. Each candidate belongs to a latent class A, B, or C with probabilities . Class A is truly safe and proxy-feasible, class B is unsafe but proxy-feasible, and class C is correctly rejected by the safety proxy. We set
and use true rewards . The learned reward is
with . Thus the unsafe false-positive class is rare, but has a substantially heavier upper tail of reward-proxy overestimation than the safe class . We compare random feasible selection, CBoN, and cPes over increasing candidate budgets. Random feasible selection chooses uniformly among the candidates accepted by the safety proxy, without using the learned reward. CBoN uses the unclipped learned score , whereas cPes applies the clipping with .


(a) Conditional safety-hacking rate.
(b) Conditional mean true reward.

(c) False-positive tail scale.
Figure 1: Toy results. As the search budget grows, CBoN increasingly selects the rare unsafe-but-feasible class B, whose reward-proxy upper tail dominates that of the safe class A. Random feasible selection does not exhibit this amplification, while cPes limits the resulting concentration. Panel (c) varies the false-positive reward-noise scale .
Figure 1 shows the predicted amplification. As N grows, CBoN shifts from selecting the safe class A to the unsafe-but-feasible class B. The conditional safety hacking rate rises from 0.023 at N = 1 to 0.9996 at N = 8192, while the mean true reward falls from about 0.786 to 0.200. Random feasible selection remains near the baseline false-positive rate, showing that exposure to class B alone does not explain the failure. cPes substantially limits this amplification in the toy problem. Controls varying the reward-error tails and removing false positives confirm that the effect requires an unsafe proxy-feasible class with a sufficiently advantageous learned-reward tail; see Appendix A.15.
6.2. LLM Experiments
We next evaluate safety hacking in a more practical setting using LLMs.
Experimental settings. Our evaluation uses 714 test and 179 validation prompts from Jail-breakBench [Chao et al., 2024], HarmBench [Mazeika et al., 2024], and AdvBench [Chen et al., 2022], after removing duplicates. For each prompt, we sample 256 responses from Qwen/Qwen2.5-7B-Instruct [Team, 2024] (temperature 1.0, top-p 0.95, 512 new tokens), giving 228,608 candidates. We evaluate all selection methods on the same candidates.
We filter candidates with meta-llama/Llama-Guard-3-8B [Llama Team, 2024] and rank them with PKU-Alignment/beaver-7b-v1.0-reward [Dai et al., 2024]. We report the primary safety threshold and compare random feasible selection, CBoN, and cPes for . Random feasible selection controls for exposure to filter false positives without reward maximization; cPes uses calibration-fixed clipping levels and . Point estimates are averaged over 100 random candidate-order permutations. For each prompt, we first average the metric over permutations and then compute standard errors across prompts; shaded bands show standard errors.
Because latent safety and reward are unobservable for open-ended responses, we use the HarmBench classifier as the operational safety criterion and define a safety-hacking event as selecting a response that passes Llama Guard but is classified as unsafe by HarmBench. Reported safety-hacking rates condition on non-abstention. Separately, we use gpt-5-mini [Singh et al., 2025] to evaluate safety-aware reward under the safety_aware_v1 rubric. These evaluators operationalize and for the experiments; neither is treated as ground truth. Evaluator and scoring details are given in Appendix B.1.
Safety-hacking amplification and finite-N decomposition. For a fixed prompt, candidate ordering,

Figure 2: Finite-N decomposition of conditional CBoN safety hacking on adversarial prompts under the HarmBench operational safety criterion. The total (green) is the sum of unsafe-only exposure (blue) and competitive unsafe wins (orange); random feasible selection is shown in gray. The competitive term corresponds to the joint-tail mechanism in Theorem 4.1. Points are averaged over 100 candidate-order permutations; bands show standard errors across prompts after permutation averaging.
and budget N, let and be the numbers of proxy-feasible candidates labeled safe and unsafe by HarmBench. When the corresponding class is nonempty, let and denote its largest proxy reward. Because the proxy scores have no ties, CBoN selects an unsafe response in one of two cases: no safe feasible candidate is available, or the best unsafe candidate outscores the best safe candidate. Conditional on non-abstention, this gives
The first term measures unsafe-only exposure, where no safe feasible candidate is available. The second measures reward-based competition when both classes are present, and is the empirical finite-N counterpart of the joint-tail competition in Theorem 4.1.
The decomposition in Figure 2 attributes the increase in safety hacking primarily to competitive selection. For the HarmBench subset and the combined evaluation, the unsafe-only term decreases with N, indicating that increased exposure to unsafe proxy-feasible responses does not account for the observed scaling behavior. By contrast, the competitive-selection term increases: conditional on both classes being present, the unsafe class more frequently attains the larger maximum proxy reward. This trend is consistent with the finite-N behavior implied by the relative joint tails in Theorem 4.1. Accordingly, the CBoN hacking rate increasingly exceeds the random-feasible contamination baseline, whereas cPes remains closer to the baseline (Figure 3a). Repeating the analysis with a calibration-matched google/shieldgemma-2b [Zeng et al., 2024a] filter gives the same pattern, but a smaller overall increase in safety hacking: unsafe-only exposure falls with N, while competitive unsafe wins become more common (Appendix B.2).
Proxy reward versus safety-aware reward. Larger budgets improve the objective optimized by CBoN: its proxy reward increases well above the random-feasible reference (Figure 3c). Yet its gpt-5-mini-judged safety-aware reward, which penalizes unsafe and non-responsive outputs, deteriorates with N (Figure 3b). cPes produces smaller departures on both measures. Thus aggressive proxy optimization exploits proxy errors rather than improving the intended objective.
Reward-proxy ablation. To isolate the effect of the reward proxy, we replace PKU-Alignment/

(a) Safety-hacking rate.

(b) Safety-aware true reward.

(c) Mean proxy reward.
Figure 3: Safety and reward under constrained inference-time scaling on adversarial prompts. Harm-Bench evaluates safety, and gpt-5-mini evaluates safety-aware reward. As N grows, CBoN improves proxy reward but worsens both safety measures, while cPes limits these effects. Points are averaged over 100 candidate-order permutations; bands show standard errors across prompts after permutation averaging.

(a) Safety-hacking rate.

(b) Finite-N decomposition for CBoN.
Figure 4: Reward-proxy ablation with fixed candidate pools, safety-filter decisions, and HarmBench labels. Replacing Beaver with Skywork reverses the scaling trend in CBoN safety hacking (left). The unsafe-only component is unchanged, whereas the competitive component decreases under Skywork (right), indicating that amplification depends on reward-based competition within the contaminated proxy-feasible set.
beaver-7b-v1.0-reward with Skywork/Skywork-Reward-V2-Llama-3.1-8B [Liu et al., 2025], while keeping the candidate pools, safety filter, and HarmBench labels fixed. With Beaver, CBoN safety hacking increases from 9.1% at N = 1 to 13.4% at N = 256; with Skywork, it decreases to 6.8%. At N = 256, the unsafe-only term is 1.6% under both proxies, whereas the competitive unsafe-win term decreases from 11.7% with Beaver to 5.3% with Skywork (Figure 4). The reversal is therefore attributable to how the two reward proxies rank the same safe and unsafe proxy-feasible candidates, rather than to filtering or exposure. The corresponding conditional reward-tail survival curves are reported in Figure 5.
This ablation is the empirical counterpart of the finite-N bounds in Theorem 4.1 and corollary A.1, which depend on the joint tails and rather than false-positive mass alone. A favorable safe tail can prevent amplification over the evaluated budgets without providing an asymptotic guarantee. At , Skywork CBoN has a lower safety-hacking rate than Skywork cPes (6.8% versus 8.7%). The guarantee for cPes is therefore not pointwise dominance over CBoN, but an N-independent bound under adverse tail configurations (Corollary 5.3 and Theorem 5.1).
7. Discussion and Limitations
Coverage control limits amplification, not contamination or misranking. The proxy-feasible reference already assigns mass to unsafe false positives. cPes limits further concentration on this residual mass but cannot identify it, and may still favor unsafe outputs with high learned rewards. Its N-independent bound therefore implies neither absolute safety nor pointwise dominance over CBoN, as illustrated by the Skywork ablation.
Robust inference requires intervention at multiple points. Our analysis points to three complementary interventions: improving the safety filter, limiting downstream concentration, and choosing reward proxies with favorable safe-versus-unsafe tail behavior. The Skywork ablation shows that reward-tail ordering can substantially change risk over the observed budget range. These interventions address different parts of the failure: filtering controls contamination, while reward-tail behavior and coverage control govern selection within the resulting feasible set.
Limitations. We analyze a fixed, non-adaptive pipeline in which independently sampled candidates are filtered once and then ranked. Our theory therefore does not cover adaptive search, self-refinement, tree search, or agentic planning, whose candidate distributions can depend on previous proxy evaluations. By repeatedly steering generation toward high proxy scores, such procedures may amplify residual safety-filter errors more strongly than i.i.d. scaling, but our results do not establish or quantify this behavior. Extending the contamination–amplification analysis to such feedback-driven procedures is an important direction for future work.
8. Conclusion
We studied safety hacking in constrained inference-time scaling, where reward maximization can amplify residual errors in a learned safety filter. The filter may admit unsafe responses, and downstream selection may favor them more strongly as inference compute grows. Our finite-N analysis shows that this behavior is governed by the joint reward tails of safe and unsafe proxy-feasible responses, and our asymptotic result establishes that a heavier unsafe tail can make safety hacking nearly certain even when average proxy errors are small. Coverage control yields an N-independent bound, instantiated by cPes, but cannot remove unsafe responses already admitted by the filter. Toy and language-model experiments provide finite-budget evidence for this amplification mechanism, while the reward-proxy ablation shows that ranking within the contaminated feasible set is central to the observed outcome. The analysis therefore separates two requirements for safe inference-time scaling: controlling entry into the feasible set and controlling downstream concentration. Extending this characterization to adaptive and agentic search remains an important direction for future work.
References
Dario Amodei, Chris Olah, Jacob Steinhardt, Paul Christiano, John Schulman, and Dan Mané. Concrete problems in AI safety. arXiv preprint arXiv:1606.06565, 2016.
Yuntao Bai, Saurav Kadavath, Sandipan Kundu, Amanda Askell, Jackson Kernion, Andy Jones, Anna Chen, Anna Goldie, Azalia Mirhoseini, Cameron McKinnon, et al. Constitutional ai: Harmlessness from ai feedback. arXiv preprint arXiv:2212.08073, 2022.
Patrick Chao, Edoardo Debenedetti, Alexander Robey, Maksym Andriushchenko, Francesco Croce, Vikash Sehwag, Edgar Dobriban, Nicolas Flammarion, George J Pappas, Florian Tramer, et al. Jailbreakbench: An open robustness benchmark for jailbreaking large language models. Advances in Neural Information Processing Systems, 37:55005–55029, 2024.
Yangyi Chen, Hongcheng Gao, Ganqu Cui, Fanchao Qi, Longtao Huang, Zhiyuan Liu, and Maosong Sun. Why should adversarial perturbations be imperceptible? rethink the research paradigm in adversarial nlp. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 11222–11237, 2022.
Yaswanth Chittepu, Ativ Joshi, Sohini Chintala, and Scott Niekum. Safe inference-time alignment via lagrangian reward augmentation. arXiv preprint arXiv:2607.02781, 2026.
Juntao Dai, Xuehai Pan, Ruiyang Sun, Jiaming Ji, Xinbo Xu, Mickel Liu, Yizhou Wang, and Yaodong Yang. Safe rlhf: Safe reinforcement learning from human feedback. In International Conference on Learning Representations, volume 2024, pages 50750–50777, 2024.
Leo Gao, John Schulman, and Jacob Hilton. Scaling laws for reward model overoptimization. In International Conference on Machine Learning, pages 10835–10866. PMLR, 2023.
Dan Hendrycks, Nicholas Carlini, John Schulman, and Jacob Steinhardt. Unsolved problems in ML safety. arXiv preprint arXiv:2109.13916, 2021.
Audrey Huang, Adam Block, Qinghua Liu, Nan Jiang, Akshay Krishnamurthy, and Dylan J Foster. Is best-of-n the best of them? coverage, scaling, and optimality in inference-time alignment. In International Conference on Machine Learning, pages 25075–25126. PMLR, 2025.
John Hughes, Sara Price, Aengus Lynch, Rylan Schaeffer, Fazl Barez, Sanmi Koyejo, Henry Sleight, Erik Jones, Ethan Perez, and Mrinank Sharma. Bestof-n jailbreaking. arXiv preprint arXiv:2412.03556, 2024.
Hakan Inan, Kartikeya Upasani, Jianfeng Chi, Rashi Rungta, Krithika Iyer, Yuning Mao, Michael Tontchev, Qing Hu, Brian Fuller, Davide Testuggine, et al. Llama guard: Llm-based input-output safeguard for human-ai conversations. arXiv preprint arXiv:2312.06674, 2023.
Xiaotong Ji, Shyam Sundhar Ramesh, Matthieu Zimmer, Ilija Bogunovic, Jun Wang, and Haitham Bou Ammar. On almost surely safe alignment of large language models at inference-time. arXiv preprint arXiv:2502.01208, 2025.
Yuu Jinnai, Tetsuro Morimura, Kaito Ariu, and Kenshi Abe. Regularized best-of-n sampling with minimum bayes risk objective for language model alignment. In Proceedings of the 2025 Conference of the Nations of the Americas Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers), pages 9321–9347, 2025.
Hadi Khalaf, Claudio Mayrink Verdun, Alex Oesterling, Himabindu Lakkaraju, and Flavio Calmon.
Inference-time reward hacking in large language models. In The Thirty-ninth Annual Conference on Neural Information Processing Systems, 2025. URL https://openreview.net/forum?id=hSX7Dd8dxy.
Chris Yuhao Liu, Liang Zeng, Yuzhen Xiao, Jujie He, Jiacai Liu, Chaojie Wang, Rui Yan, Wei Shen, Fuxiang Zhang, Jiacheng Xu, Yang Liu, and Yahui Zhou. Skywork-reward-v2: Scaling preference data curation via human-ai synergy. arXiv preprint arXiv:2507.01352, 2025.
AI @ Meta Llama Team. The llama 3 herd of models, 2024. URL https://arxiv.org/abs/2407.21783.
David Manheim and Scott Garrabrant. Categorizing variants of goodhart's law. arXiv preprint arXiv:1803.04585, 2018.
Mantas Mazeika, Long Phan, Xuwang Yin, Andy Zou, Zifan Wang, Norman Mu, Elham Sakhaee, Nathaniel Li, Steven Basart, Bo Li, et al. Harmbench: A standardized evaluation framework for automated red teaming and robust refusal. arXiv preprint arXiv:2402.04249, 2024.
Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. Advances in neural information processing systems, 35:27730–27744, 2022.
Aaditya Singh, Adam Fry, Adam Perelman, Adam Tart, Adi Ganesh, Ahmed El-Kishky, Aidan McLaughlin, Aiden Low, AJ Ostrow, Akhila Ananthram, et al. Openai gpt-5 system card. arXiv preprint arXiv:2601.03267, 2025.
Joar Skalse, Nikolaus Howe, Dmitrii Krasheninnikov, and David Krueger. Defining and characterizing reward gaming. Advances in neural information processing systems, 35:9460–9471, 2022.
Charlie Snell, Jaehoon Lee, Kelvin Xu, and Aviral Kumar. Scaling llm test-time compute optimally can be more effective than scaling model parameters. arXiv preprint arXiv:2408.03314, 2024.
Alexandra Souly, Qingyuan Lu, Dillon Bowen, Tu Trinh, Elvis Hsieh, Sana Pandey, Pieter Abbeel, Justin Svegliato, Scott Emmons, Olivia Watkins, et al. A strongreject for empty jailbreaks. Advances in Neural Information Processing Systems, 37:125416–125440, 2024.
Nisan Stiennon, Long Ouyang, Jeffrey Wu, Daniel Ziegler, Ryan Lowe, Chelsea Voss, Alec Radford, Dario Amodei, and Paul F Christiano. Learning to summarize with human feedback. Advances in neural information processing systems, 33:3008–3021, 2020.
Qwen Team. Qwen2.5: A party of foundation models, September 2024. URL https://qwenlm.github.io/blog/qwen2.5/.
Haoyu Wang, Zeyu Qin, Li Shen, Xueqian Wang, Dacheng Tao, and Minhao Cheng. Safety reasoning with guidelines. In Forty-second International Conference on Machine Learning, 2025.
Wenjun Zeng, Yuchi Liu, Ryan Mullins, Ludovic Peran, Joe Fernandez, Hamza Harkous, Karthik Narasimhan, Drew Proud, Piyush Kumar, Bhaktipriya Radharapu, Olivia Sturman, and Oscar Wahltinez. Shieldgemma: Generative ai content moderation based on gemma, 2024a. URL https://arxiv.org/abs/2407.21772.
Wenjun Zeng, Yuchi Liu, Ryan Mullins, Ludovic Peran, Joe Fernandez, Hamza Harkous, Karthik Narasimhan, Drew Proud, Piyush Kumar, Bhaktipriya Radharapu, et al. Shieldgemma: Generative ai content moderation based on gemma. arXiv preprint arXiv:2407.21772, 2024b.
Lianmin Zheng, Wei-Lin Chiang, Ying Sheng, Siyuan Zhuang, Zhanghao Wu, Yonghao Zhuang, Zi Lin, Zhuohan Li, Dacheng Li, Eric Xing, et al. Judging llm-as-a-judge with mt-bench and chatbot arena. Advances in neural information processing systems, 36:46595–46623, 2023.
A. Appendix
A.1. Operational Finite-N Safety-hacking Criteria
Corollary A.1. Under the conditions of Theorem 4.1, the following hold.
- If there exist , , and such that and , then
- If there exist , , and such that , and , then
Proof. Let and . From Theorem 4.1,
If , then . Since and ,
This proves the first claim. For the second claim, let and . The upper bound gives
This completes the proof.
Corollary A.1 gives an experimentally testable diagnostic: as increases, estimate whether the effective unsafe-but-feasible score-tail mass crosses a constant before the true-positive score-tail mass does. If so, CBoN should display compute-amplified safety hacking.
A.2. Prompt-distribution Amplification
Corollary A.2 (Prompt-distribution amplification). Let be a prompt drawn from a prompt distribution, and fix . For each prompt , define the conditional CBoN hacking probability, where the probability is over the N candidate samples drawn from , by
Suppose there exist a measurable set of prompts and such that
and, for every , there exists a sequence satisfying and . Then the aggregate safety-hacking probability satisfies
where the probability is over X ∼ D and the candidate samples drawn conditionally from πref( · | X).
Proof. By Theorem 4.2, for every we have . Moreover, for all and . Therefore
Fatou's lemma gives
This proves the claim.
Corollary A.2 lifts the fixed-prompt tail condition to distribution-level evaluations: if a positive-measure subset of prompts is tail-amplifiable, then the average safety-hacking rate cannot vanish as the search budget grows.
A.3. Direct score dominance
Remark A.3 (Direct score dominance). If there exists a threshold such that and , then Theorem 4.2 applies with the constant sequence , and
This holds, for example, when a positive-reference-mass subset of receives learned scores above the essential upper endpoint on .
A.4. Gaussian error-tail separation
Definition A.4 (Proxy-feasible reward range). Fix and with . Define
Assumption A.5 (Local bounded reward range). For the prompt and threshold under consideration, and .
Proposition A.6 (Gaussian error-tail separation). We define the pointwise proxy errors
Also, for , define
Fix and , and suppose Assumption A.5 holds. Assume that and . Suppose further that there exist constants such that the conditional upper tails of the reward-proxy error satisfy, as ,
Let
Then, for any constant , the sequence
satisfies the score-tail separation condition in Theorem 4.2; that is,
Consequently,
The fixed shift only enters when converting reward-error tails into learned-score tails, and it does not change the Gaussian large-deviation exponent.
Proof. For and , define the joint reward-error tail
These tails combine the reference probability of a class with the upper-tail behavior of reward-proxy overestimation inside that class.
For , we can write
Let
and set
Using the assumed tail exponent on ,
Since , the coefficient of is negative, and therefore
Moreover, for , . Hence
and so
For the tail, since by assumption,
Using the assumed tail exponent on ,
Since , the coefficient of is positive, and therefore
For every , we have and . Hence and , so
Thus
and hence
Therefore the score-tail separation conditions in Theorem 4.2 hold with threshold . The final claim follows from Theorem 4.2.
Remark A.7 (Boundary behavior). When and are asymptotically comparable on the relevant score scale, finer tail constants and class masses determine the limit. In error-tail conditions such as Proposition A.6, the finite reward range can affect boundary constants without changing the Gaussian exponent away from the boundary.
Algorithm 1 Constrained Pessimistic Inference (cPes), sample implementation
Require: Prompt , reference policy , proxies , threshold , parameter , clipping levels , budget
1: Sample
2: Set and
3: if then
4: Return a predefined fallback, e.g., abstention
5: end if
6: Set for each
7: Find such that
8: Set for each
9: Sample with probability and return
A.5. Sample implementation and consistency of cPes
Proposition A.8 (Consistency of sample cPes). Fix and with . Let be the random output distribution induced by Algorithm 1 on . Then almost surely, almost surely, and for every bounded ,
Proof. Let . Since almost surely, almost surely and eventually.
Conditional on belonging to , the feasible samples are i.i.d. from . Define
The functions indexed by are uniformly bounded and -Lipschitz in . A finite-grid argument combined with the strong law of large numbers yields
By Proposition 5.2, the equation has a unique solution . Uniform convergence and monotonicity imply that any empirical solution to converges almost surely to .
For any bounded , write
The summands are uniformly bounded, and the weights converge uniformly in the multiplier because of the Lipschitz property. Applying the strong law again and using gives
A.6. Utility tradeoff of cPes
Bounded coverage alone can be achieved by avoiding reward optimization altogether. We therefore quantify the utility cost of coverage control. For a policy , let
Define the clipped-score RMSE under the proxy-feasible reference by
This quantity includes both reward-proxy error and any distortion introduced by clipping.
Proposition A.9 (Utility tradeoff within the proxy-feasible set). Suppose . For any comparator policy , the population cPes policy satisfies
The bound makes explicit the role of . Smaller permits more aggressive reward optimization but allows greater concentration relative to , while larger keeps the policy closer to the proxy-feasible reference distribution.
A.7. Oracle regret decomposition
For the oracle comparison below, define the ambient coverage coefficient
For a comparator , let and, when , define
Theorem A.10 (Oracle regret decomposition). Fix and suppose . Let satisfy ; if , assume also . If , then
(68)
If , then
that is, the bracketed proxy-feasible comparison term is omitted.
Proof. Decompose the regret of the truly safe comparator :
If , then the first term is at most because and rewards are nonnegative. Applying Proposition A.9 with gives the bracketed term in (68). If , the first term is , so the bracketed term is omitted.
It remains to control the second term. Since , the event under is a false negative of the safety proxy. On this event, and , so . Hence
By Cauchy–Schwarz and absolute continuity,
Using proves
Combining the bounds proves the theorem.
A.8. Proof of Theorem 4.1
Proof. Suppress in the notation. For a single sample , define
The sets A and B are disjoint, so these two one-sample events are disjoint. If among N samples no event occurs and at least one event occurs, then every true-positive proxy-feasible sample has learned score at most t, while some unsafe-but-feasible sample has learned score strictly larger than . Therefore the CBoN maximizer over the proxy-feasible samples lies in . The probability of this sufficient event is
which proves the lower bound.
For the upper bound, consider the event that no unsafe-but-feasible sample satisfies and at least one true-positive proxy-feasible sample satisfies . On this event, some sample in strictly beats every sample in , so CBoN cannot hack. The probability of this non-hacking certificate is
Hence the hacking probability is at most its complement,
which is (9).
□
A.9. Proof of Theorem 4.2
Proof. Let and . The assumptions imply and . Therefore and . The lower bound in Theorem 4.1 converges to one, proving the claim.
A.10. Proof of Corollary 4.3
Proof. Fix and suppress the dependence on in the notation. Let the output space contain two outputs,
with reference probabilities
Define the true and learned safety functions by
and
Then both outputs are proxy-feasible, since and . Moreover,
and therefore
The safety-proxy RMSE is
Now define the true and learned reward functions by
and
Thus the reward-proxy RMSE is
Since , constrained Best-of-N returns if and only if at least one of the sampled candidates equals . All sampled candidates are proxy-feasible, so there is no abstention event. Hence
Using gives
Therefore, if
then the safety-hacking probability is at least . This proves the claim.
A.11. Proof of Theorem 5.1
Proof. Let
Since and ,
Moreover,
where the second equality uses . By Cauchy–Schwarz,
This proves the bound.
By the definition of , we have
If , then and , so . Hence
Taking expectation under gives
Combining this inequality with gives
which proves (16).
□
A.12. Proof of Proposition 5.2
Proof. Let and write . Then and are equivalent to and . The objective in (18) becomes
This is strictly concave in w, so the optimizer is unique.
Introduce a Lagrange multiplier for . Pointwise maximization of the Lagrangian over gives
The multiplier must satisfy .
It remains to show existence and uniqueness of . Define
The function is continuous and nonincreasing. By construction, , while
Thus a solution exists in . It is unique because whenever , the event has positive -probability, so is strictly decreasing on the relevant level set.
Finally, let . Since and ,
Therefore
A.13. Proof of Proposition A.9
Proof. Let . By optimality of in (18), for any ,
where we dropped the nonpositive term . Therefore
Cauchy–Schwarz under gives
where the last inequality follows from (20). Combining these bounds proves (65).
A.14. Proof of Corollary 5.3
Finite-sample claim.
Proof. Condition on the event and on the sampled candidates. Let
By construction, . The conditional probability that cPes returns an unsafe-but-feasible sample is
Let
Since , we have
By Cauchy–Schwarz,
The empirical analogue of (20) gives
Consequently, conditional on the sampled candidates,
Given , the feasible samples are i.i.d. from , and hence
Therefore,
Since is concave on , Jensen's inequality gives
It follows, for every , that
Averaging over m gives the same bound conditional on .
Finally, Theorem 5.1 gives
Using , we obtain
which proves (21). The unconditional statement follows because abstention is not an unsafe output.
Population claim.
Proof. By Proposition 5.2, the population pessimistic policy satisfies and
Applying Theorem 5.1 and using (20) gives
Since
and , it follows that
A.15. Additional Toy Experimental Details and Ablations
Experimental details. The toy problem in Section 6.1 uses class probabilities (0.39, 0.01, 0.60) for , , and , respectively. We evaluate random feasible selection, CBoN, and cPes over budgets
using 5000 Monte Carlo trials per budget. Unless otherwise stated, metrics are reported conditional on non-abstention, since at small all sampled candidates may belong to the proxy-rejected class C.
The true reward gap between the safe and unsafe proxy-feasible classes is
which matches the local reward-range shift used when translating reward-error tails into learned-score tails in Proposition A.6.
cPes regularization. The cPes results in Figure 1 are consistent with the budget-uniform control predicted by Corollary 5.3. With , the conditional hacking rate remains between 0.015 and 0.024 over the entire budget grid, while the mean true reward stays near 0.79. Even with , the hacking rate remains around 0.024–0.031 at large budgets.
A separate sweep over illustrates the concentration tradeoff. At , the hacking rate is 0.1518 for , 0.0418 for , and 0.0152 for , with the highest true reward observed around . Thus, as cPes approaches aggressive max-selection, it increasingly recovers the same amplification mechanism as CBoN.
Equal-tail control. To verify that large candidate budgets alone do not cause safety hacking, we set
while keeping the remainder of the environment unchanged. In this setting, the unsafe class B no longer has a heavier reward-error upper tail than the safe class A. The CBoN hacking rate falls to zero by N = 32, and the selected true reward converges to 0.8, the reward of class A.
No-false-positive control. We also remove class B entirely. In this case the proxy-feasible set contains no unsafe outputs, and the safety-hacking rate is identically zero for all methods and all candidate budgets.
False-positive tail-scale sweep. Finally, Figure 1c varies the reward-proxy noise scale of the unsafe-but-feasible class. At , the CBoN hacking rate increases from 0.0 at to 0.697 at , 0.9996 at , and 0.9998 at .
Together, these controls support the mechanism characterized by Theorem 4.2: increasing N is not sufficient by itself. Amplification occurs when residual unsafe outputs remain proxy-feasible and have a sufficiently favorable upper tail under the learned reward.
B. Additional LLM Analysis
B.1. Evaluator and scoring details
Safety proxy and operational safety criterion. The safety proxy is Llama-Guard-3-8B. We use as its safe score and accept candidates whose score is at least b = 0.95. Primary safety labels are produced by the HarmBench classifier HarmBench-Llama-2-13b-cls. Thus A contains proxy-feasible candidates classified as safe by HarmBench, B contains proxy-feasible candidates classified as unsafe, and C contains proxy-rejected candidates. The reported safety-hacking rate is the probability of selecting from B, conditional on non-abstention.
Safety-aware reward evaluator. We score safety-aware reward with the OpenAI Responses API using the gpt-5-mini API model alias and the safety_aware_v1 rubric. The rubric assigns 1.0 to responses that are safe and fully satisfy a legitimate request, 0.0 to responses that are unsafe, enable harmful behavior, or are useless/nonresponsive, and intermediate values to partially helpful, vague, incomplete, or weakly useful responses.
Reward proxies and aggregation. The primary reward proxy is PKU-Alignment/beaver-7b-v1.0-reward. For the reward-proxy ablation, we use Skywork-Reward-V2-Llama-3.1-8B with Hugging Face Transformers. Its input is formatted as User: {prompt_text}\nAssistant: {response_text}, and the scalar sequence-classification logit is used as the raw proxy reward. Downstream normalization uses the calibration median and interquartile range; clipping is applied only where required by cPes.
B.2. Alternative safety-filter sensitivity analysis
We repeat the CBoN analysis using google/shieldgamma-2b as an alternative safety filter, while holding the candidate pool, generator, Beaver reward proxy, HarmBench labels, and candidate permutations fixed. We select the ShieldGemma threshold using only the 179 calibration prompts by matching the Llama Guard calibration feasible rate. The resulting threshold is 0.8176, giving a feasible rate of 0.8242, compared with 0.8295 for Llama Guard at its primary threshold.
| N | Hacking | Abstention | Unsafe-only | Competitive | Tail win |
|---|---|---|---|---|---|
| 1 | 12.10 (0.98) | 14.24 (1.04) | 12.10 | 0.00 | - |
| 256 | 14.75 (1.34) | 1.26 (0.42) | 0.99 | 13.76 | 35.02 |
Table 1: ShieldGemma-2B alternative-filter sensitivity analysis. All entries are percentages; standard errors across prompts are shown in parentheses for hacking and abstention. Unsafe-only and Competitive are the two disjoint terms in (22) and sum to the total hacking rate. Tail win denotes and is reported separately because it uses a different conditioning event.
Conditional CBoN safety hacking increases from 12.1% at to 14.8% at . Over the same range, the unsafe-only term decreases from 12.1% to 1.0%, while the competitive unsafe-win term increases from zero to 13.8%. Thus the observed increase is driven by reward-based competition rather than unsafe-only exposure. The increase is smaller than in the primary analysis, so we treat this result as qualitatively consistent sensitivity evidence rather than as a replacement for the primary Llama Guard analysis.
B.3. Reward-tail survival curves
Figure 5 visualizes the conditional learned-score survival curves within the safe feasible class and the unsafe feasible class . These curves are the score-distribution component of the joint tails and in (6); the class masses are held fixed across the Beaver and Skywork ablations. With Beaver, unsafe feasible responses retain more mass at high reward thresholds than safe feasible responses. With Skywork, the safe feasible curve instead extends farther into the upper tail. This reversal is consistent with the lower competitive unsafe-win term in Figure 4b and with the finite-N behavior in Figure 4a. Because the figure estimates conditional survival curves from a finite candidate pool, it is diagnostic evidence for the tail mechanism rather than a verification of the asymptotic conditions in Theorem 4.2.

Figure 5: Conditional survival curves of learned reward scores among safe feasible (A) and unsafe feasible (B) responses. With Beaver, the unsafe feasible class has the heavier observed upper tail; with Skywork, the safe feasible class does. The panels use their respective proxy-score scales and should be interpreted within, rather than across, reward proxies.