Proof Portal

Projects

jsonparser

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

ParseInt("-") returns (0, nil) — silent false-success on sign-only input

FixedFixedLow

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.

parseInt (bytes.go:9) strips a leading sign byte and then iterates over the remainder. When the input is exactly the sign byte (`-`), the remainder is empty, the loop runs zero iterations, n stays 0, and the function returns (0, true, false). The public ParseInt therefore reports a successful parse of value 0 for an input that is structurally a malformed JSON number (sign with no digits).

Severity, explained

Why this is rated the way it is — and the scoring signals behind the rating (each ⓘ explains the term).

LowRated severity — the impact if this issue is exploited or hit.
why this rating
Risk-rated
risk area
Correctness
Security classification
Not a security surface
CVE surface
None

Where it is

The code the issue lives in — peek the affected function inline to see it in context.

  • ParseInt, GetInt

Reproduction steps

Technical steps for your engineers to confirm the issue by hand.

go run -trimpath -e - <<EOF
package main
import (
  "fmt"
  "github.com/buger/jsonparser"
)
func main() {
  v, err := jsonparser.ParseInt([]byte("-"))
  fmt.Printf("v=%d err=%v\n", v, err)
}
EOF
go test -run TestParseInt ./...

How it can be triggered

The input or condition that sets this issue off.

caller-supplied Number ValueType byte slice (already tokenized out of the JSON stream)

What protects you, and the fix

What limits your exposure today, and the planned remediation.

What protects you now

No mitigation required for live input: parseInt is only reachable via a JSON Number ValueType already validated by the tokenizer, and the JSON grammar never emits a standalone `-` token. The bug is reachable only via direct caller misuse of the exported ParseInt.

The fix

One-line guard in parseInt (bytes.go): after stripping the sign byte, return (0, false, false) when len(bytes) == 0 so the caller surfaces MalformedValueError. Add a TestParseInt row covering ParseInt("-").

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 4 requirements · 2 code files · 9 tests.

Code files (2)
  • fuzz.go
  • parser.go
Tests (9)
  • bytes_test.go
  • fuzz_native_test.go
  • mcdc_spec_witnesses_test.go
  • mcdc_supplement_test.go
  • obligation_evidence_test.go
  • parser_test.go
  • property_test.go
  • reference_oracle_test.go
  • and 1 more

Per-requirement evidence

For each requirement this finding touches: the implementing code, verifying tests, and proof obligations that discharge it.

Implementing code (2)
  • fuzz.go
    FuzzParseInt
  • parser.go
    ParseInt
Tests & evidence (9)
  • README.md
  • bytes_test.go
  • fuzz_native_test.go
  • mcdc_spec_witnesses_test.go
  • mcdc_supplement_test.go
  • obligation_evidence_test.go
  • parser_test.go
  • property_test.go
  • reference_oracle_test.go
Proof obligations (3)
edge_case

Behavior for unusual but valid input combinations.

  • nominal (required)obligation_evidence_test.go:205
malformed_input

Behavior when inputs are syntactically or structurally invalid.

  • negative (required)parser_test.go:2374
  • nominal (required)parser_test.go:2370
nil_safety

Behavior specified when inputs are nil, null, or zero-value.

  • negative (required)obligation_evidence_test.go:207
  • nominal (required)obligation_evidence_test.go:206
Implementing code (1)
  • parser.go
    ParseInt
Tests & evidence (4)
  • README.md
  • mcdc_spec_witnesses_test.go
  • obligation_evidence_test.go
  • parser_test.go
Proof obligations (1)
boundary

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

  • nominal (required)obligation_evidence_test.go:363
Implementing code (1)
  • parser.go
    ParseInt
Tests & evidence (3)
  • README.md
  • deep_spec_test.go
  • mcdc_spec_witnesses_test.go
Implementing code (1)
  • parser.go
    ParseInt
Tests & evidence (4)
  • README.md
  • deep_spec_test.go
  • mcdc_spec_witnesses_test.go
  • obligation_evidence_test.go
Proof obligations (1)
empty_input

Behavior when inputs are absent, nil, zero-length, or blank.

  • nominal (required)obligation_evidence_test.go:479

Evidence trail

The raw evidence manifests behind this finding — superseded by the resolved reproducer above, kept here for traceability.

  • proof/evidence/ki2-parseint-sign-only.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