The vulnerability is a StackOverflowError caused by uncontrolled recursion in the org.jsonschema2pojo.rules.SchemaRule.apply method when processing a JSON schema with a self-referential \"$ref\": \"#\". This was identified by analyzing the GitHub issue #1672 for joelittlejohn/jsonschema2pojo, which includes a description of the error, a stack trace, and relevant code snippets from SchemaRule.java.
-
org.jsonschema2pojo.rules.SchemaRule.apply: This function is the primary location of the vulnerability. It recursively calls itself. The issue arises when a \"$ref\": \"#\" is encountered. The function nameFromRef is called, and for \"#\", it returns null. The apply function then calls ruleFactory.getSchemaStore().create() and updates schemaNode with schema.getContent(). Crucially, the termination condition schema.isGenerated() is not met for this scenario. As a result, apply calls itself again with parameters that do not lead to a resolution, causing infinite recursion and eventually a StackOverflowError.
-
org.jsonschema2pojo.rules.SchemaRule.nameFromRef: This helper function is directly involved in creating the vulnerable condition. Its specific behavior of returning null when the input ref is \"#\" is a key step. This null return value influences how the apply method constructs its recursive call, preventing the resolution of the reference in a way that would terminate the recursion.
The stack trace provided in the issue (at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:69), at org.jsonschema2pojo.rules.SchemaRule.apply(SchemaRule.java:76)) confirms the recursive calls to apply. The code snippets and analysis within the issue clearly demonstrate the logical flow leading to the stack overflow. No patch information was available, so the analysis relies on the detailed issue description and the provided code excerpts.