You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Strict JSON parse: accepted non-JSON forms, O(n^2) duplicate check, no depth cap #67
Two low-severity gaps in the new strict JSON parse (JsonParseStrict / JsonParseFileStrict). The author of the file is trusted, hence low.
A. Accepted non-JSON forms
The strict parse still accepts non-JSON forms, so it is not a full conformance gate. Where: overlay/libntech/0005-Added-JsonParseStrict-and-JsonParseFileStrict.patch:315-329 (the json.h doc: "refusing input a lenient parse would repair"). Not strictly refused:
Unquoted keys (the patch's own test at 0005:379 accepts plain: true).
A missing colon, since JsonParseAsObject appends a value whenever property_name != NULL without checking prev_char == ':' (so {"a" "b"} parses as {"a":"b"}).
\u0000, which Utf8EncodeCodePointWriter writes as a NUL that StringWriterWriteLen's strnlen drops ("a\u0000b" becomes "ab").
Scenario: a parser differential with any validator that uses a conformant parser, such as Python json in tendcf's projector or lint. A key "tendcf_interlock\u0000" is a different key to Python but tendcf_interlock to CFEngine. Inside one file a collision is refused as a duplicate, so the outcome is fail-closed, but a validator and the loader can disagree on the name of a lone key.
Suggested fix: document these accepted forms next to JsonParseStrict, or refuse missing colons and \u0000 under reject_duplicates. Separately, have the projector refuse \u0000 in keys and values.
This is a linear lookup for every member. Nesting depth is pre-existing.
Scenario: a 5 MiB host_specific.json with one flat object of ~400k short keys means on the order of 10^11 comparisons. Root cf-agent then spins until agent_expireafter kills it, and nothing is installed. A deeply nested [[[[... overflows the stack, which is pre-existing.
Suggested fix: a hash set of seen keys per object under reject_duplicates, or a member-count cap in JsonParseFileStrict. Add a nesting cap for the strict variant.
Activity