-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Protect JSONML from stack overflow exceptions caused by recursion #723
Conversation
…ngDepth param. Amend Javadoc for XML and XMLParserConfiguration classes.
Limit the XML nesting depth for CVE-2022-45688 when using the JsonML transform.
* Configuration object for the XML to JSONML parser. The configuration is immutable. | ||
*/ | ||
@SuppressWarnings({""}) | ||
public class XMLtoJSONMLParserConfiguration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for not re-using XMLParserConfiguration?
Either way, please don't expose any new APIs for JSONML besides the max nesting depth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason: not all options of XMLParserConfiguration is supported with JSONML parsing, so it seemed cleaner to create a new config class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new APIs for JSONML:
- public static JSONObject toJSONObject(String string, XMLtoJSONMLParserConfiguration config)
- public static JSONObject toJSONObject(XMLTokener x, XMLtoJSONMLParserConfiguration config)
These are both necessary to support max nesting depth and the keepStrings
option in one function.
The alternative would be to add create 4 new toJSONObject
functions that include the int maxNestingDepth
parameter, on top of the existing 4 such functions - the potential parameter combinations doubling with a new optional parameter.
Is this acceptable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed that I did not add the max depth limit override option for the toJSONArray
calls - await a fix soon.
Update - fixed now, a new commit was pushed.
…JSONML.toJSONArray(...) functions, to facilitate max nesting depth override.
@stleary I have a fix for the
|
Let's work through the JSONML changes before starting JSONObject and JSONArray. |
Fair enough, I will leave the other changes for another day.
Done, ready for review. |
@TamasPergerDWP The code looks good, just one comment |
…, enforcing the builder pattern.
@stleary Code amended as requested |
What problem does this code solve? Risks Changes to the API? Will this require a new release? Should the documentation be updated? Does it break the unit tests? Was any code refactored in this commit? Review status |
Starting 3 day comment window. |
The fix follows the method used in fixing the same issue for XML in the previous PR:
Limit the XML nesting depth for CVE-2022-45688 #720
Additionally, fixing a minor issue with XMLParserConfiguration.clone() and amending some Javadoc.
Resolves #722