v0.2.1: fix C UB on admitted 1e20-class inputs; sanitizer CI gate; hardening - #2
Merged
Conversation
…location + supply-chain hardening
The C write_number fast-path cast double->long long BEFORE its range
guard — undefined behavior (C11 6.3.1.4p1) for integer-valued fraction
tokens >= 2^63 inside the supported domain, caught by UBSan on
{"x":100000000000000000000.0}. Guard now precedes any conversion
(same order as the C++ lineage). No known wrong hash was produced
(x86-64 saturation fell through to the correct branch; 7/7 agreement
on the affected class verified before and after).
- corpus: pin huge_integer_valued_float regression vector (25 accept + 31 reject, 7/7 green)
- CI: sanitize job (ASan+UBSan+float-cast-overflow, -fno-sanitize-recover=all) for C and C++
running full corpus via conformance/run_corpus_cli.py
- C strbuf: OOM latch, checked malloc/realloc, size_t-overflow-guarded growth;
baion_canonicalize_json returns NULL on allocation failure (never a partial string)
- workflow: permissions contents:read, job timeouts, exact toolchain pins
(Rust 1.94.0, DMD 2.112.0, GHC 9.6.7, cabal 3.16.1.0, opam package pins)
- supply chain: cJSON pinned to commit acc76239 (v1.7.18); Cargo.lock and
cabal.project.freeze committed
- CHANGELOG.md added; v0.2.0 preserved, superseded not replaced
Receipts: verify_all_lineages.sh PASS 7/7; differential_probe 234 cases 0
divergent; fuzz_agreement seed=20260715 8000 cases 0 failures; sanitized
C and C++ CLIs green on full corpus.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Corrective release candidate for the C-lineage undefined behavior found in the 2026-07-15 external security review. v0.2.0 stays published; this supersedes it.
The defect
c/src/canonical_json.cwrite_numberevaluated(double)(long long)dbefore itsfabs(d) < 1e15range guard. For integer-valued fraction tokens ≥ 2⁶³ inside the supported domain (e.g.{"x":100000000000000000000.0}, |v| < 10²¹) the conversion is undefined behavior (C11 §6.3.1.4p1) — reproduced under UBSan through the real CLI. No known wrong hash was produced (on x86-64 the conversion saturates and falls through to the correct big-integer branch; 7/7 agreement on the affected class verified before and after), but UB is not a cross-platform contract.Changes
fabs(d) < 1e15 && trunc(d) == d— same order the C++ lineage already usedhuge_integer_valued_floatpinned in the corpus (25 accept + 31 reject, 7/7 green)sanitizejob — C and C++ under-fsanitize=address,undefined,float-cast-overflow -fno-sanitize-recover=all, unit tests + full corpus through the instrumented CLIs via newconformance/run_corpus_cli.py(reject = clean nonzero exit; sanitizer abort = crash, not a rejection)malloc/realloc(no live-pointer overwrite),size_t-overflow-guarded growth;baion_canonicalize_jsonreturns NULL on failure — never a partial canonical stringpermissions: contents: read; job timeouts; cJSON pinned to commitacc76239(v1.7.18); exact toolchain pins (Rust 1.94.0, DMD 2.112.0, GHC 9.6.7, cabal 3.16.1.0, opam package pins);Cargo.lockandcabal.project.freezecommittedDeliberately deferred (documented in CHANGELOG)
Resource limits (input size, nesting depth, member counts): a limit changes which documents are rejected, so it is a cross-lineage contract change — all seven lineages must adopt identical limits in one release or uniform rejection breaks. Same for the O(n²) duplicate-key scan cap and the C-locale assumption.
Local receipts at this RC
canonical_json.c:189:5: runtime error: 1e+20 is outside the range of representable values of type 'long long int'(UBSan, real CLI, in-domain input)356acd21…, exit 0verify_all_lineages.shPASS 7/7 ·differential_probe.py234 cases 0 divergent ·fuzz_agreement.pyseed=20260715, 8000 cases, 0 failuresReview questions
🤖 Generated with Claude Code