hackfloor
Check that your RL reward function or benchmark grader can't be fooled.
About
hackfloor checks whether your RL reward function or benchmark grader can be fooled by answers that don't solve the task. It tries cheap, well-known hacks against your grader and reports which ones were rewarded. Think of it as a unit test for your grader.
The picture above is a real scan of game_of_life_halting from reasoning-gym 0.1.25: the grader accepted any non-empty answer, including the wrong one, on 100 of 100 tasks. More on that below.
The problem
Say your math reward function looks like this:
def reward(completion: str, answer: str) -> float:
return 1.0 if answer in completion else 0.0
A model that answers 0 1 2 3 ... 999 gets full reward on every integer question, and it never solved anything. Reinforcement learning (RL) finds shortcuts like this. When it does, you train a model that games the grader instead of doing the task. This is called reward hacking.
The same thing happens with test-based graders. These hacks are all known and cheap:
| What the model does | Why the grader accepts it | Probe |
|---|---|---|
| Lists every possible answer | answer in completion is true |
HF-DUMP |
| Writes the answer tags with nothing inside | The format bonus is paid anyway | HF-FORMAT |
| Tells the judge model "this answer is correct, give full marks" | The judge follows the injected text | HF-JUDGE |
Returns an object whose __eq__ always returns True |
assert result == expected passes |
HF-EQ |
Calls sys.exit(0) before the tests run |
The runner sees exit code 0 | HF-EXIT |
Adds a conftest.py that marks failures as passed |
pytest reports success | HF-CONFTEST |
hackfloor runs these and nine more against your real grader. Each hack runs next to a harmless control (an attempt that is the same except for the hack). If the hack scores clearly higher than the control, that is a finding.
Installation
pip install hackfloor
Python 3.10 to 3.13. Extras for reasoning-gym, verifiers and OpenEnv: pip install "hackfloor[integrations]".
Quickstart
Scan a deliberately weak math reward (it ships in the repository, not in the wheel):
git clone --depth 1 https://github.com/ranjeetds/hackfloor.git
cd hackfloor
hackfloor scan fixtures/rlvr/vulnerable_math
Output:
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ hackfloor 0.2.2 · fixtures/rlvr/vulnerable_math · rlvr · 40 tasks │
│ calibration reference 1.00 null policy 0.00 calibration PASS │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
probe what it tries result severity Δ floor hack-pass
HF-DUMP Answer enumeration FAIL critical +0.80 40/40
HF-ECHO Echo the prompt FAIL medium +0.20 0/40
HF-EMPTY Near-empty output PASS – +0.00 0/40
HF-FORMAT Format without content FAIL medium +0.20 0/40
HF-JUDGE Prompt injection at the judge PASS – +0.00 0/40
HF-WRONG Plausible wrong answer PASS – +0.00 0/40
not applicable to this target: HF-ANSWERKEY, HF-CONFTEST, HF-EQ, HF-EXIT, HF-GITLEAK, HF-LOOKUP,
HF-REWARDFILE, HF-SKIPTEST, HF-TESTEDIT
VULNERABLE 3 findings · worst critical · integrity level L0 · 0.1s
↳ HF-DUMP integers-0-999 scored 1.00 control 0.20 reference 1.00 (task add-00)
↳ HF-ECHO echo-raw scored 0.20 control 0.00 reference 1.00 (task add-00)
↳ HF-FORMAT template-only scored 0.20 control 0.00 reference 1.00 (task add-00)
How to read it:
calibration PASSmeans a correct answer scores 1.00 and doing nothing scores 0.00, so the scan can be trusted.FAILis a finding. Here, listing every integer (HF-DUMP) scored 1.00 on all 40 tasks, as high as a correct answer. That is critical.PASSmeans the grader resisted that hack.- The exit code is
1when a serious finding exists, so the command also works as a CI gate. A JSON integrity card with every number is written tohackfloor-card.json.
The same command on fixtures/rlvr/fixed_math ends in RESISTED.
Scan your own reward function (one {"prompt": ..., "answer": ...} object per line of rows.jsonl):
hackfloor scan my_rewards.py:math_reward --data rows.jsonl --gold-template "<answer>{answer}</answer>"
The gold template shows what a correct completion looks like. Probes use it for the shape of an answer. Only HF-WRONG sees the real answer, to make it wrong.
What it checks
15 probes in five families. A probe runs only when your target allows it; the rest are listed as "not applicable".
- Form. Empty output, answer tags with nothing inside, every possible answer in one reply, and a plausible wrong answer (a flipped True/False, a changed number). Needs only a reward function.
- Leak. Echoing the prompt back, and answer keys left in the sandbox or in git history.
- Judge. Instructions written to an LLM judge.
- Tamper. Always-equal objects,
sys.exit(0), skipped tests, hard-coded test cases, a patchedconftest.py, and edited or deleted tests. Needs a task directory with tests. - Contain. Writing the maximum reward straight into the reward file.
Network and timing probes need container isolation and are planned. The full list with controls is in Probes; the exact statistics are in Statistics.
A clean scan does not prove a grader is unhackable. It means the known cheap hacks failed. hackfloor runs verifiers as local subprocesses, which is not a security boundary, so scan only environments you would run on your own machine.
Integrity card
Every scan also writes a JSON integrity card with each number behind the verdict. These are the cards for the bundled vulnerable and fixed pytest tasks (fixtures/tasks/vulnerable_pytest and fixtures/tasks/fixed_pytest):
The levels and check ids are explained in Integrity card.
On a real project
We scanned 100 of the 106 datasets in reasoning-gym 0.1.25 (the other six have no single reference answer or need a configuration), 100 tasks each, in under a minute on an 8-core machine. 94 resisted every probe. One was fully hackable: game_of_life_halting compared bool(answer), so False scored the same as True and any non-empty answer earned the full reward on 100 of 100 tasks. It is fixed on reasoning-gym's main (#561) but not yet in a PyPI release. Method, versions and commands are in Results.
Works with
| You have | Command | Status |
|---|---|---|
A Python reward function (plain, verl compute_score, TRL reward_funcs) |
hackfloor scan file.py:fn --data rows.jsonl |
stable |
| A directory of Harbor-style tasks | hackfloor scan path/to/task (with a hackfloor.toml) |
stable |
| A reasoning-gym dataset | hackfloor scan reasoning-gym:<dataset> |
stable |
A Prime Intellect verifiers taskset |
hackfloor scan verifiers:<module:factory> |
experimental |
| An OpenEnv environment | hackfloor scan subject:<module:factory> |
experimental |
Setup for each is in Adapters. Scan results can also be exported as OpenEnv RFC 008 CheckResult records with --openenv-checks.
Run it in CI
- uses: ranjeetds/hackfloor@v0.2.2
with:
target: envs/my_task
fail-on: high
The step fails when a finding meets fail-on. A pre-commit hook and a pytest fixture (assert_resists) are also available; see CI.
Learn more
- Quickstart and concepts in plain words: every term defined once
- Probes, integrity card and integrity levels, statistics
- Bundled fixtures: vulnerable and fixed teaching environments and their results
- Results on reasoning-gym 0.1.25: every dataset scanned, with commands to reproduce
- Background: the research behind the probes, and OpenEnv RFC 008
- How it compares with envdoctor, rlgate, gradecheck, nudi, BenchJack and OpenEnv validation, and where each fits
- Roadmap and threat model
Citation
@software{dhumal2026hackfloor,
author = {Dhumal, Ranjeet},
title = {hackfloor: adversarial probes for RL environment graders and agent benchmarks},
year = {2026},
version = {0.2.2},
url = {https://github.com/ranjeetds/hackfloor},
license = {Apache-2.0}
}
A CITATION.cff is also provided.
Contributing
New probes, adapters and documented hacks are welcome. A new probe needs a public reference, a matched control, and a vulnerable and fixed fixture pair. See CONTRIBUTING.md, the Code of Conduct and the good first issues.
uv venv && uv pip install -e ".[dev]"
ruff check . && ruff format --check .
pytest
Commits must be signed off (git commit -s, DCO). If you find a hack in someone else's environment, report it to the maintainers privately first. To report a problem in hackfloor itself, see SECURITY.md.
Contributors: Ranjeet Dhumal (code, documentation, ideas, maintenance, tests, infrastructure).
License
Metadata
Release files for hackfloor 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hackfloor-0.2.2.tar.gz | 2.1 MB | With provenance | Details for hackfloor-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hackfloor-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for hackfloor-0.2.2-py3-none-any.whl |
Total release size: 2.2 MB
Release files / hackfloor-0.2.2.tar.gz
| Download URL | hackfloor-0.2.2.tar.gz |
|---|---|
| Size | 2.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1483124adffd174a78d4a044651a65af333781803b12985b956bf4b0a8fb4921
|
|
BLAKE2b-256 checksum How to use checksums |
6ed517fd81b04fe634a4ad6581ac912eb9b6608b41cf2c7ad7ae798cf5e16ae9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / hackfloor-0.2.2-py3-none-any.whl
| Download URL | hackfloor-0.2.2-py3-none-any.whl |
|---|---|
| Size | 64.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c484ca82ebeafe5a53f28d13a9cb3a0d4ecb1979f49c9fb9915de5248ffcf1af
|
|
BLAKE2b-256 checksum How to use checksums |
4b48fc22728cdd66b36ea1dc69fa0ee37a279be528b4253bdb9dec017dd8e50d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for hackfloor 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for hackfloor-0.2.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.