Proof Portal
jsonparser
ProbeLabs36 findings · 123 requirementsSet with array-index path component under an object parent produces malformed JSON output
This defect has been fixed and verified.
Introduced
When and where this issue first entered the codebase — the commit it traces back to.
Affected requirements
The requirement(s) this issue violates — click through to the spec.
What this means for you
Plain-language impact — what this issue could mean for your users and your system, before any of the technical detail.
When Set is called with a key path that contains an array-index component ([N]) whose parent in the addressed JSON is an OBJECT rather than an array, the implementation emits malformed JSON output and returns it with a nil error. Examples (all currently produce invalid JSON, err=nil): Set({"a":{"b":1}}, 9, "a", "[5]") -> {"a":{"b":1,9}} Set({"a":{"b":1}}, 9, "a", "[0]", "x") -> {"a":{"b":1,{"x":9}}} Set({"a":1}, 9, "[0]") -> {"a":1,9}. Root cause: createInsertComponent (parser.go:756) with isIndex=true, comma=true, object=false emits only ",<value>" (no quoted object key), so the value is spliced into the object body where JSON requires a "key":value pair. Set (parser.go:1018-1038) does not reject the cross-type path before invoking createInsertComponent.
Severity, explained
Why this is rated the way it is — and the scoring signals behind the rating (each ⓘ explains the term).
- why this rating
- Reproducer-confirmed
- risk area
- Data Integrity
- CVE surface
- Unlikely
Where it is
The code the issue lives in — peek the affected function inline to see it in context.
- Set
How it's proven
The reproducer — an actual test that drives the real code and shows the issue happening. Run it yourself, or peek the test and the source it covers.
// Reproduces: markergo test -v -run TestSetArrayIndexUnderObjectMalformedJSON_KI3 ./...
Reproduction steps
Technical steps for your engineers to confirm the issue by hand.
go test -v -run TestSetArrayIndexUnderObjectMalformedJSON_KI3 ./... go test -v -run TestSetArrayIndexUnderObjectMalformedJSON_KI3 ./...
How it can be triggered
The input or condition that sets this issue off.
caller-supplied key path containing [N] component under an object parent (variadic ...string keys argument)
What protects you, and the fix
What limits your exposure today, and the planned remediation.
What protects you now
No mitigation in code; users must avoid mixing array-index path components ([N]) with object-typed parents in Set key paths. Validation in upstream callers (e.g. JSON-Schema validators) can reject such paths before they reach jsonparser.Set.
The fix
Add a type-mismatch guard in parser.go:Set (around lines 1018-1038): when the resolved subpath parent is an object and the trailing key is an array-index (or vice-versa), return KeyPathNotFoundError instead of invoking createInsertComponent. Alternative: reject in createInsertComponent when isIndex mismatches the parent context.
Blast radius
If you touch this issue, what else may need re-checking — the requirements it affects and the code and tests that hang off them.
Touch this finding and you re-check 3 requirements · 5 code files · 17 tests.
- append.go
- escape.go
- fuzz.go
- parser.go
- path_compiler.go
- empty_key_path_test.go
- escape_test.go
- fuzz_native_test.go
- issues_56_107_229_test.go
- mcdc_code_supplement_test.go
- mcdc_spec_witnesses_test.go
- mcdc_supplement_test.go
- obligation_evidence_test.go
- and 9 more
Per-requirement evidence
For each requirement this finding touches: the implementing code, verifying tests, and proof obligations that discharge it.
Per-requirement evidence
For each requirement this finding touches: the implementing code, verifying tests, and proof obligations that discharge it.
Evidence trail
The raw evidence manifests behind this finding — superseded by the resolved reproducer above, kept here for traceability.
Evidence trail
The raw evidence manifests behind this finding — superseded by the resolved reproducer above, kept here for traceability.
- proof/evidence/ki3-set-array-index-under-object.yaml
Discussions
Discuss this with the proof team. Nothing changes in your audit automatically — you open a request and a staff member records any outcome inside the thread.