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
Potentially unsafe deserialization in JSONObject#fromJson() static fields are not excluded #1043
This behavior may be security-relevant when JSONObject#fromJson(Class<T>) is used on untrusted input, so I am reporting it here as a public issue in line with the repository's published vulnerability-reporting guidance.
In release 20251224, JSONObject#fromJson(Class<T>) iterates clazz.getDeclaredFields(), calls Field#setAccessible(true), and assigns matching JSON values without excluding static fields:
As a result, deserialization can write not only per-instance state but also mutable declared class-level state on the caller-selected target type, subject to normal runtime access restrictions. That expands the binding surface beyond ordinary object population and may have integrity implications in applications that use fromJson() with untrusted JSON.
If helpful, I can provide a minimal reproducer and a regression test. A straightforward mitigation appears to be skipping static fields during binding.
changed the title [-]Potentially unsafe deserialization in JSONObject#fromJson(): static fields are not excluded[/-][+]Potentially unsafe deserialization in JSONObject#fromJson() static fields are not excluded[/+]on Mar 10, 2026
@yuki-matsuhashi Thanks for catching this. Any code you can provide to recreate, test, and/or fix the issue is welcome. Feel free to submit a PR when ready.
Activity
[-]Potentially unsafe deserialization in JSONObject#fromJson(): static fields are not excluded[/-][+]Potentially unsafe deserialization in JSONObject#fromJson() static fields are not excluded[/+]stleary commentedon Mar 11, 2026
@yuki-matsuhashi Thanks for catching this. Any code you can provide to recreate, test, and/or fix the issue is welcome. Feel free to submit a PR when ready.
yuki-matsuhashi commentedon Mar 12, 2026
@stleary, thanks for taking a look.
I’ve opened PR #1044 with a proposed fix, a regression test, and a small Javadoc update to address this issue.
stleary commentedon Mar 13, 2026
@yuki-matsuhashi Thank you, the fix looks good, will merge in a couple of days.