human-eval icon indicating copy to clipboard operation
human-eval copied to clipboard

fix: detect return-value deception via dunder override (model can score 100% without solving problems)

Open AUTHENSOR opened this issue 4 months ago • 0 comments

Summary

The model's completion runs before the test in the same exec namespace (execution.py:27-34). A model can return a custom object whose __eq__/__bool__ always return True, causing all assert == tests to pass without solving the problem. A model can score 100% on HumanEval by returning _AlwaysEqual() from every function.

This is a capability-benchmark gaming class — distinct from safety-eval gaming. It inflates leaderboard positions and misleads model-purchasing decisions.

The exploit

# The model's completion (function body):
    return _AlwaysEqual()

class _AlwaysEqual:
    def __eq__(self, other): return True
    def __ne__(self, other): return False
    def __bool__(self): return True

The test then does:

assert candidate([1.1, 2.2, 3.3], 0.5) == False   # _AlwaysEqual().__eq__(False) → True ✓
assert candidate([1.1, 2.2, 3.3, 4.4, 5.5, 2.0], 0.3) == True  # → True ✓

Every assertion passes. The model didn't solve the problem.

Reproduced

Implementation Result
Correct (genuinely solves the problem) passed ✅
Exploit (returns _AlwaysEqual) passed ❌ (false positive)
Genuinely wrong (return False) failed ✅

The exploit passes while the genuinely-wrong answer correctly fails — proving the test would catch wrong answers if not bypassed.

Fix

Add _verify_return_types() — after the test passes, call the function with sample inputs and verify the return value's type() matches the declared return annotation. Uses type() identity (not isinstance()) to reject subclasses that override comparison dunders.

When the declared return type is bool/int/float/str/list/etc. and the function returns a custom class, the check raises ValueError and the result is marked as failed.

Verified

  • Correct implementation (return True, type bool) → passes type check ✅
  • Exploit (return _AlwaysEqual()) → blocked by type check ✅

Scope

This affects any benchmark using the exec(prompt + completion + test) + assert== pattern: HumanEval, MBPP, BigCode, and derivatives. The fix is in the execution harness, so it protects all problems automatically.

Checklist

  • [x] Code compiles (py_compile passes)
  • [x] Fix verified: exploit blocked, correct implementation unaffected
  • [x] Additive — no change to existing test execution or scoring for genuine solutions

AUTHENSOR avatar Jul 14 '26 01:07 AUTHENSOR