Skip to content

Reject embedded NUL bytes during JSON deserialization - #2086

Open
jhodges10 wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
jhodges10:codex/reject-json-nul
Open

jhodges10 wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
jhodges10:codex/reject-json-nul

Conversation

@jhodges10

@jhodges10 jhodges10 commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

RapidJSON treats a raw NUL byte as end-of-input. Both JSON entry points could therefore accept a valid prefix such as {"x":1}\0{"y":2} while silently ignoring the rest. Reject these inputs so callers cannot disagree about what was parsed.

Changes

  • Parse strings through a length-aware MemoryStream and reject a successful parse that consumed fewer bytes than the supplied string.
  • Distinguish a real NUL byte from FileReadStream's synthetic end-of-file marker after file parsing; open files in binary mode so Windows text-mode EOF translation cannot truncate input.
  • Add a C++ regression test for both entry points, unchanged destination values on failure, and valid escaped \u0000 with trailing whitespace.

Validation

  • The C++ serialization tests passed in Debug and under AddressSanitizer/UndefinedBehaviorSanitizer.
  • Nine other CTest targets and eleven bundle cases passed; the disk-intensive ZIP64 case was omitted.
  • A Python API smoke test confirmed both string and file deserialization now raise ValueError for the crafted input, while escaped \u0000 remains valid.

Assisted-by: OpenAI Codex / GPT-6 Daybreak (cyber-security model)

@codecov-commenter

codecov-commenter commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.47%. Comparing base (0bfd9d6) to head (0f03940).

Files with missing lines Patch % Lines
src/opentimelineio/deserialization.cpp 55.55% 8 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2086      +/-   ##
==========================================
- Coverage   83.62%   83.47%   -0.16%     
==========================================
  Files         184      184              
  Lines       13627    13993     +366     
  Branches     1270     1274       +4     
==========================================
+ Hits        11395    11680     +285     
- Misses       2059     2140      +81     
  Partials      173      173              
Flag Coverage Δ
py-unittests 83.47% <55.55%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/opentimelineio/deserialization.cpp 63.18% <55.55%> (+0.29%) ⬆️

... and 63 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0bfd9d6...0f03940. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jhodges10 jhodges10 added the security Security-related improvements label Oct 30, 2026
Assisted-by: OpenAI Codex / GPT-6
Signed-off-by: Jeff Hodges <[email protected]>
@jhodges10
jhodges10 force-pushed the codex/reject-json-nul branch from d4f0ad3 to 0f03940 Compare October 30, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security Security-related improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants