Proof Portal

Projects

jsonparser

ProbeLabs36 findings · 123 requirements
Back to findings
Known issueKI-3

Set with array-index path component under an object parent produces malformed JSON output

FixedFixedHigh

This defect has been fixed and verified.

Introduced

When and where this issue first entered the codebase — the commit it traces back to.

Inception (latent from the first version)

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).

HighRated severity — the impact if this issue is exploited or hit.
why this rating
Reproducer-confirmed
risk area
Data Integrity
Security classification
Security-relevant
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.

Recorded
Reproducer test
from // Reproduces: marker
Run it yourself
go 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.

Tracing blast radius…

Touch this finding and you re-check 3 requirements · 5 code files · 17 tests.

Code files (5)
  • append.go
  • escape.go
  • fuzz.go
  • parser.go
  • path_compiler.go
Tests (17)
  • 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.

Implementing code (8)
  • append.go
    Append
  • escape.go
    SetString
  • fuzz.go
    FuzzSet
  • parser.go
    Set
  • parser.go
    WriteToBuffer
  • parser.go
    calcAllocateSpace
  • parser.go
    createInsertComponent
  • parser.go
    setConfig
Tests & evidence (15)
  • README.md
  • 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
  • path_compiler.go
  • path_compiler_test.go
  • property_test.go
  • reference_oracle_test.go
  • set_spec_test.go
  • v131_regression_test.go
Proof obligations (4)
boundary

Behavior at limits, thresholds, and edge-of-range values.

idempotency

Applying the operation twice produces the same result as applying once.

  • nominal (required)obligation_evidence_test.go:159
malformed_input

Behavior when inputs are syntactically or structurally invalid.

  • negative (required)set_spec_test.go:73
  • nominal (required)set_spec_test.go:11
nested_mutation
Implementing code (4)
  • append.go
    Append
  • parser.go
    Set
  • parser.go
    createInsertComponent
  • parser.go
    setConfig
Tests & evidence (9)
  • README.md
  • append_test.go
  • docs/proof-gap-root-cause.md
  • fuzz_native_test.go
  • mcdc_supplement_test.go
  • parser_test.go
  • reference_oracle_test.go
  • set_spec_test.go
  • sys_req_110_111_witness_test.go
Proof obligations (3)
boundary

Behavior at limits, thresholds, and edge-of-range values.

  • nominal (required)sys_req_110_111_witness_test.go:33
  • negativeparser_test.go:2484
element_type_partition
  • nominal (required)parser_test.go:2485
nested_mutation
  • nominal (required)sys_req_110_111_witness_test.go:81
Implementing code (7)
  • parser.go
    GetArrayLen
  • parser.go
    GetObjectLen
  • parser.go
    containerStart
  • parser.go
    isContainerWhitespace
  • parser.go
    scanContainerLen
  • parser.go
    validContainerPrimitive
  • parser.go
    validJSONNumber
Tests & evidence (4)
  • README.md
  • len_uint_test.go
  • mcdc_spec_witnesses_test.go
  • parser_test.go
Proof obligations (3)
boundary

Behavior at limits, thresholds, and edge-of-range values.

  • nominal (required)len_uint_test.go:11, len_uint_test.go:95
malformed_input

Behavior when inputs are syntactically or structurally invalid.

  • negative (required)len_uint_test.go:13, len_uint_test.go:97
  • nominal (required)len_uint_test.go:12, len_uint_test.go:96
nominal

Happy-path behavior with valid inputs.

  • nominal (required)len_uint_test.go:10, len_uint_test.go:94

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.

Sign in to discuss this with the proof team.Sign in