This was originally reported to us as a security report. We do not see practical ways to exploit this, but it is nevertheless a bug worth fixing.
Minimal repro:
type hiddenFallback struct {
Extra map[string]any `json:",embed"`
}
type destination struct {
*hiddenFallback // nil unexported embedded pointer
}
func main() {
var dst destination
// Unmatched field "unmatched" routes to the embedded fallback, causing panic.
err := json.Unmarshal([]byte(`{"unmatched": 1}`), &dst)
fmt.Printf("err=%v dst=%+v\n", err, dst)
}
The same repro does not panic with GOEXPERIMENT=nojsonv2.
This was originally reported to us as a security report. We do not see practical ways to exploit this, but it is nevertheless a bug worth fixing.
Minimal repro:
The same repro does not panic with
GOEXPERIMENT=nojsonv2.