mORMot2 DailyDaily read of upstream commits

JSON and YAML writers close multiple buffer-overflow paths

This edition hardens the framework's JSON and YAML paths against oversized or malformed input. A sequence of commits replaces fixed-size short writes used with unbounded values, protects JSON reformatting at buffer boundaries, applies YAML depth limits to compact forms and rejects embedded NUL bytes. PostgreSQL JSONB and numeric output, SOA logging, interface command-line decoding and CSV output share the same safer writer path. Crypto users should also review the new ECrypt inheritance relationship.

TL;DR

  • Upgrade if untrusted or large values can reach JSON, YAML, PostgreSQL JSONB/numeric output, SOA logging or CSV generation.
  • JSON reformatting now checks capacity for dynamic tokens and structural delimiters instead of using fixed-size or direct writes.
  • YAML parsing now enforces depth in compact structures, rejects embedded NUL and validates quoted flow scalars.
  • ECrypt now descends from ESynCrypto so one ESynCrypto handler can cover the crypto stack.

Upgrade advice

Upgrade to the complete edition head, build 2.4.17934, rather than cherry-picking one writer fix. Keep the JSON hardening sequence through 2.4.17924 and the YAML follow-ups through 2.4.17933 together. Re-test oversized JSON tokens, long PostgreSQL JSONB/numeric values, deeply nested compact YAML and YAML containing NUL. Review exception handlers that distinguish ECrypt from ESynCrypto.

Build2.4.17915 → 2.4.17934
Commits19
Lines+872 -440
Read3 min

16 of 16 entries · 19 commits upstream

Stories
# Entry Category Units
1 Critical TJsonParser stops short-writing unbounded tokens PreprocVar and Reformat move unbounded numbers and escaped strings from AddShort to AddNoJsonEscape; AddShort documentation now explicitly limits callers to 255 bytes. Security mormot.core.json+1 31689eed+9-7

core: fixed three unbounded dynamic token writes in TJsonParser

Impact

Delphi and FPC JSON preprocessing and reformatting no longer route large dynamic tokens through a fixed temporary buffer, removing the memory-corruption path identified by the diff.

Arnaud Bouchez · 13:32 UTC · view the commit on GitHub →

2 High YAML compact recursion and quoted keys are bounded TYamlToJson applies YamlMaxDepth to compact sequences and implicit maps, fully consumes quoted keys and rejects trailing text, and fixes the line-comment pointer check. Security mormot.core.fmt 610a95a2+32-14

core: fixed YAML parsing for overflows

Impact

Delphi and FPC YAML backends no longer let compact syntax bypass the depth limit or accept extra material after a quoted scalar.

Arnaud Bouchez · 13:46 UTC · view the commit on GitHub →

3 High Long JSON-facing output uses capacity-aware writes Unbounded interface argument values, CSV separators, database column names and SOA client-IP headers now use AddNoJsonEscape instead of AddShort. Security mormot.core.interfaces+3 013da880+6-6

core: hardened JSON output against buffer overflows

Impact

Delphi and FPC backends avoid fixed short-buffer writes when these externally influenced values exceed 255 bytes.

Arnaud Bouchez · 14:23 UTC · view the commit on GitHub →

4 High JSON reformatting guards buffer boundaries TJsonParser.Reformat uses TTextWriter.LastChar for empty-safe inspection and capacity-aware Add for opening and closing delimiters instead of AddDirect. Security mormot.core.json 23b709e4+6-6

core: fixed potential buffer overflow during JSON reformat

Impact

Delphi and FPC applications reformatting large or deeply nested JSON avoid unchecked delimiter writes and empty-buffer access.

Arnaud Bouchez · 13:36 UTC · view the commit on GitHub →

5 High Long JSON properties and PostgreSQL values avoid short writes JsonObjectAsJsonArrays property names and PostgreSQL numeric, JSON and JSONB column values now use AddNoJsonEscape instead of AddShort. Security mormot.core.json+1 77c73fe6+5-5

core: fixed other potential buffer overflows

Impact

Delphi and FPC database backends can serialize property names and PostgreSQL values above 255 bytes without a fixed short-buffer write.

Arnaud Bouchez · 13:39 UTC · view the commit on GitHub →

6 High YAML input rejects embedded NUL bytes TYamlToJson scans each bounded input line for #0 and reports an error instead of letting a sentinel terminate parsing before the declared buffer end. Security mormot.core.fmt 788814ef+5-3

core: fixed TYamlToJson to reject #0 within input buffer

Impact

Delphi and FPC backends no longer accept a truncated YAML prefix when bytes remain after an embedded NUL, preventing parser-consumer disagreement on the same buffer.

Arnaud Bouchez · 20:15 UTC · view the commit on GitHub →

7 High Text preprocessing accepts long substitutions safely TPreproc.ExpandTo and TPreprocText.TextPreprocessToWriter write variable-length substitutions with AddNoJsonEscape rather than AddShort. Security mormot.core.fmt 02bdc167+4-4

core: fixed two further variable-length substitutions in mormot.core.fmt

Impact

Delphi and FPC text templates can expand substitutions beyond 255 bytes without entering a fixed short-write path.

Arnaud Bouchez · 13:41 UTC · view the commit on GitHub →

8 Medium Quoted YAML flow scalars parse correctly TYamlToJson only invokes quoted-token scanning when the quote begins the current flow token, preserving quotes embedded in plain scalars and delimiters inside quoted values. Fixes mormot.core.fmt 0dcd7087+4-3

core: fixed quoted scalars in YAML flow collections

Impact

Delphi and FPC applications converting YAML flow sequences or maps no longer split valid quoted values at embedded commas or misread mid-scalar quotes.

Arnaud Bouchez · 20:27 UTC · view the commit on GitHub →

9 Medium ECrypt joins the ESynCrypto hierarchy ECrypt now inherits from ESynCrypto instead of ESynException, making factory exceptions part of the common crypto exception hierarchy. Compiler & platform mormot.crypt.secure a0669b27+4-1

crypt: ECrypt now inherits from ESynCrypto

Impact

On Delphi and FPC, an except on ESynCrypto now catches ECrypt and its descendants; handlers that deliberately distinguish the old sibling classes may observe different matching.

Worth a look

Review ordered exception handlers for ESynCrypto and ECrypt, especially code adopting the ESynCrypto handler introduced by the preceding edition.

Public API

  • ECryptbehaviour-changed — Its base class changes from ESynException to ESynCrypto.

zen010101 · 11:50 UTC · view the commit on GitHub →

10 Low JSON parser state initialization is made explicit TJsonParser.Init now initializes RootCount, and GetJsonPropName checks info.Json before using an unescaped field. Under the hood mormot.core.json 906e3f85+6-5

core: two small JSON refactoring to please ValGrid

Impact

This is defensive cleanup for Delphi and FPC JSON parsing; no public contract changes.

Arnaud Bouchez · 20:35 UTC · view the commit on GitHub →

11 Low DuckDB and Quack internals are simplified DuckDBVariantSql trims trailing semicolons with FakeLength, and TQuackResponse.NewType uses PtrArrayAdd for pool growth. Under the hood mormot.db.raw.duckdb 6b5fac71+4-7

db: minor DuckDB + Quack refactoring

Impact

No functional change is visible for Delphi or FPC DuckDB consumers.

Arnaud Bouchez · 18:50 UTC · view the commit on GitHub →

12 Low Quack test messages use a binary buffer writer The DuckDB Quack server emulator replaces RawByteString concatenation with TMockQuackWriter over TBufferWriter, including explicit field and LEB128 encoding. Tests 8dae860b+628-331

test: rewritten buggy Quack server emulator

Impact

Only test infrastructure changes; it avoids Delphi/FPC string-concatenation and code-page differences in binary fixtures.

Arnaud Bouchez · 18:51 UTC · view the commit on GitHub →

13 Low YAML and DuckDB regression coverage expands Tests add quoted flow-collection, embedded NUL and malformed YAML cases, and refine the DuckDB Quack mock writer coverage. Tests b517ff42+92-40

tests: enhanced DuckDB and YAML coverage

Impact

No runtime behavior changes for Delphi or FPC; the preceding parser and test-emulator fixes gain regression coverage.

Arnaud Bouchez · 20:28 UTC · view the commit on GitHub →

14 Low Large JSON and deep YAML cases gain regression tests Tests cover a 70,000-character JSON token, long property names, deep structural sequences, YAML injection-like quoted text and compact recursion limits. Tests 66b5e528+28-3

test: cover latest JSON + YAML fixes

Impact

No runtime behavior changes; Delphi and FPC regression coverage demonstrates the intended boundaries of the adjacent fixes.

Arnaud Bouchez · 13:53 UTC · view the commit on GitHub →

15 Low DHCP scope rules gain targeted tests Tests confirm that DISCOVER without giaddr ignores ciaddr and uses the receiving interface, while RELEASE selects the scope from ciaddr even on another interface. Tests bab760db+13-0

tests: DHCP scope selection of DISCOVER with ciaddr, and of RELEASE

Impact

No runtime behavior changes for Delphi or FPC; this extends coverage of the DHCP fixes from the preceding edition.

zen010101 · 09:49 UTC · view the commit on GitHub →

16 Low IsValidJson limitations are documented The API comment now states that IsValidJson, including Strict=true, is a fast parser-compatibility check rather than full RFC 8259 validation. Docs mormot.core.json 35f43955+5-3

core: document that IsValidJson() is not a RFC compliance validation

Impact

No Delphi or FPC runtime behavior changes; callers should not infer standards compliance from this helper.

Arnaud Bouchez · 14:25 UTC · view the commit on GitHub →

Upstream activity commits per day · last 60 days
Commits1007
Active days49/60
Busiest2026-09-30
Peak60
2026-09-30: 60 commits2026-10-01: 26 commits2026-10-02: 30 commits2026-10-03: 32 commits2026-10-04: 15 commits2026-10-05: 1 commit2026-10-06: 26 commits2026-10-07: 37 commits2026-10-08: 27 commits2026-10-09: 35 commits2026-10-10: 12 commits2026-10-11: 2 commits2026-10-12: 40 commits2026-10-13: 31 commits2026-10-14: 23 commits2026-10-15: 16 commits2026-10-16: 27 commits2026-10-17: 0 commits2026-10-18: 0 commits2026-10-19: 0 commits2026-10-20: 0 commits2026-10-21: 0 commits2026-10-22: 3 commits2026-10-23: 6 commits2026-10-24: 29 commits2026-10-25: 7 commits2026-10-26: 25 commits2026-10-27: 4 commits2026-10-28: 8 commits2026-10-29: 17 commits2026-10-30: 20 commits2026-10-31: 0 commits2026-11-01: 0 commits2026-11-02: 16 commits2026-11-03: 32 commits2026-11-04: 15 commits2026-11-05: 32 commits2026-11-06: 26 commits2026-11-07: 19 commits2026-11-08: 2 commits2026-11-09: 29 commits2026-11-10: 17 commits2026-11-11: 8 commits2026-11-12: 38 commits2026-11-13: 39 commits2026-11-14: 9 commits2026-11-15: 6 commits2026-11-16: 21 commits2026-11-17: 30 commits2026-11-18: 37 commits2026-11-19: 28 commits2026-11-20: 31 commits2026-11-21: 0 commits2026-11-22: 0 commits2026-11-23: 1 commit2026-11-24: 6 commits2026-11-25: 3 commits2026-11-26: 3 commits2026-11-27: 0 commits2026-11-28: 0 commits
2026-09-302026-11-28