Repository navigation
Description
Prerequisites
- Check that your issue is not already filed: https://github.com/leanprover/lean4/issues
- Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to Mathlib or Batteries.
- Test your test case against the latest nightly release, for example on https://live.lean-lang.org/#project=lean-nightly (You can also use the settings there to switch to “Lean nightly”)
- Affects
lake check --paranoid: yes — both Lean default and Lean paranoid accept the exploit.
Description
The kernel's native Nat reducer reduce_nat dispatches by
constant name (f == *g_nat_add) and never checks that the environment's Nat.add is the canonical
recursive definition. whnf runs reduce_nat before unfold_definition. So if the
environment binds a well-typed but non-canonical Nat.add, the two reduction paths disagree:
def Nat.add (_ _ : Nat) : Nat := 0
theorem key (a b : Nat) : Nat.add a b = 0 := rfl
theorem four_ne_zero : (4 : Nat) = 0 → False := fun h => Nat.noConfusion h
theorem contra : False := four_ne_zero (key 2 2)Nat.add 2 2 is 0 via the stored body (used for the variable-generalized key) but 4 via native
reduction (used at the literal instantiation), so the kernel accepts contra : False with no axioms.
Reproduction scripts
Exploit.lean
def myadd (_ _ : Nat) : Nat := 0
theorem key (a b : Nat) : myadd a b = 0 := rfl
theorem four_ne_zero : (4 : Nat) = 0 → False := fun h => Nat.noConfusion hmake_exploit.py
import json, sys
src, dst = sys.argv[1], sys.argv[2]
lines = open(src).read().splitlines()
out, renamed = [], False
for ln in lines:
try:
o = json.loads(ln)
except ValueError:
out.append(ln); continue
if o.get("in") == 39 and isinstance(o.get("str"), dict) and o["str"].get("str") == "myadd":
o = {"in": 39, "str": {"pre": 1, "str": "add"}}
renamed = True
out.append(json.dumps(o)); continue
out.append(ln)
assert renamed, "did not find myadd name binding to rename"
extra = [
{"in": 75, "str": {"pre": 0, "str": "contra"}},
{"const": {"name": 47, "us": []}, "ie": 290},
{"const": {"name": 74, "us": []}, "ie": 291},
{"ie": 292, "natVal": "2"},
{"app": {"arg": 292, "fn": 290}, "ie": 293},
{"app": {"arg": 292, "fn": 293}, "ie": 294},
{"app": {"arg": 294, "fn": 291}, "ie": 295},
{"thm": {"all": [75], "levelParams": [], "name": 75, "type": 154, "value": 295}},
]
out += [json.dumps(o) for o in extra]
open(dst, "w").write("\n".join(out) + "\n")
print(f"renamed myadd->Nat.add: {renamed}; wrote {dst}")Steps to Reproduce
lean -o Exploit.olean Exploit.lean
leanexport Exploit -- key four_ne_zero > raw.ndjson
python3 make_exploit.py raw.ndjson exploit.ndjson
lake check --paranoid --from-export exploit.ndjsonExpected behavior: both Lean kernels reject exploit.ndjson, like lean4lean and con-leche/con-ron.
Actual behavior: both Lean default and Lean paranoid accept it, verifying contra : False with
no axioms. Plain lake check --from-export exploit.ndjson (no --paranoid) runs only Lean default
and exits 0 — lake check accepts a proof of False.
Results
Uses no axioms
Lean paranoid kernel ACCEPTS the solution <-- proof of False
lean4lean kernel rejected ("invalid form for primitive def Nat.add")
nanoda kernel ACCEPTS the solution <-- proof of False
con-leche kernel declined ("nonstandard structural Nat operation (Nat.add)")
con-ron kernel declined ("nonstandard structural Nat operation")
Lean default kernel ACCEPTS the solution <-- proof of False
Versions
4.37.0-nightly-2026-10-23
Impact
Soundness: the shipped lake check --paranoid / leanchecker --from-export accepts an axiom-free proof of
False.
Activity
leodemoura commentedon Oct 24, 2026
This is not a kernel soundness bug. Our guide defines what qualifies: "If the official kernel accepts an exported proof of
Falseunder the standard prelude and permitted axioms, that is a kernel soundness bug." It also says: "If you write export files, keep the declarations of the official prelude as they are."Your export replaces the official prelude's
Nat.add, so it does not use the standard prelude. This case is covered in the "Non-standard prelude definitions" section: https://hackmd.io/Tu2Z97xHSQilI7b91HQfAwcomparator(https://github.com/leanprover/comparator) checks for exactly this kind of exploit. It checks that the kernel's built-in declarations, includingNat.add, match the official prelude, and it rejects your export:Please report potential soundness issues privately to [email protected], not as public GitHub issues.
Closing as not a bug.