Skip to content

fix(json): limit nesting depth of parsed JSON documents - #1025

Open
lishuxu wants to merge 1 commit into
apache:mainfrom
lishuxu:fix/json-nesting-depth
Open

lishuxu wants to merge 1 commit into
apache:mainfrom
lishuxu:fix/json-nesting-depth

Conversation

@lishuxu

@lishuxu lishuxu commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Type, name-mapping and expression parsers walk parsed JSON recursively, so a deeply nested document could exhaust the stack. Check the nesting depth of objects and arrays iteratively right after parsing in FromJsonString and FileMetadataFromJsonString, and reject documents nested deeper than 1000 levels, matching the default limit of Jackson's StreamReadConstraints.

Type, name-mapping and expression parsers walk parsed JSON recursively,
so a deeply nested document could exhaust the stack. Check the nesting
depth of objects and arrays iteratively right after parsing in
FromJsonString and FileMetadataFromJsonString, and reject documents
nested deeper than 1000 levels, matching the default limit of
Jackson's StreamReadConstraints.
Comment thread src/iceberg/json_serde.cc
if (json.is_discarded()) [[unlikely]] {
return JsonParseError("Failed to parse JSON string: {}", json_string);
}
ICEBERG_RETURN_UNEXPECTED(CheckJsonNestingDepth(json));

@shangxinli shangxinli Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the puffin one cover two of the three nlohmann::json::parse sites; catalog/rest/auth/oauth2_util.cc:186 parses a JWT payload straight off the token endpoint and isn't gated. It only reads the exp claim, so leaving it out may well be deliberate - worth saying so if it is.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants