Skip to content

fix(project): Bound configuration file size and nesting - #1687

Open
RandomByte wants to merge 1 commit into
mainfrom
fix/project-config-size-limits
Open

RandomByte wants to merge 1 commit into
mainfrom
fix/project-config-size-limits

Conversation

@RandomByte

Copy link
Copy Markdown
Member

Project loading read ui5.yaml, manifest.json, manifest.appdescr_variant and build-manifest.json and passed them to js-yaml, AJV, JSON.parse and structuredClone with no size, collection or nesting bound. Oversized or deeply nested inputs consumed unbounded parsing and validation resources.

Enforce finite, configurable limits before parsing, validation, defaults processing or cloning:

  • Byte size of ui5.yaml and of each manifest, checked from file metadata before the content is read. The ui5.yaml budget covers every YAML document in the file.
  • YAML nesting, through an explicit js-yaml maxDepth option. The parser default of 100 was previously implicit.
  • JSON nesting, through a string scan before JSON.parse that skips brackets inside strings and handles escapes.
  • Collection size, the entries in any one array or properties in any one object, checked after parsing and before validation.

Limits default to generous values and accept overrides through UI5_CONFIG_MAX_BYTES, UI5_MANIFEST_MAX_BYTES, UI5_CONFIG_MAX_DEPTH, UI5_JSON_MAX_DEPTH and UI5_CONFIG_MAX_COLLECTION. Each failure is a handled error that names the input and the exceeded limit, with a stable code (ERR_CONFIG_TOO_LARGE, ERR_CONFIG_TOO_DEEP,
ERR_CONFIG_COLLECTION_TOO_LARGE, ERR_CONFIG_INVALID_LIMIT).

Per-document limits do not bound a graph assembled from many dependency documents. CI jobs and containers building untrusted projects must still set process and container resource limits. The Configuration documentation describes the settings and their defaults.

@RandomByte
RandomByte requested a review from a team October 30, 2026 10:03
@devtomtom
devtomtom force-pushed the fix/project-config-size-limits branch from 05e9f21 to dbf7b6b Compare November 23, 2026 10:09
Project loading read ui5.yaml, manifest.json, manifest.appdescr_variant
and build-manifest.json and passed them to js-yaml, AJV, JSON.parse and
structuredClone with no size, collection or nesting bound. Oversized or
deeply nested inputs consumed unbounded parsing and validation resources.

Enforce finite, configurable limits before parsing, validation, defaults
processing or cloning:

- Byte size of ui5.yaml and of each manifest, checked from file metadata
  before the content is read. The ui5.yaml budget covers every YAML
  document in the file.
- YAML nesting, through an explicit js-yaml maxDepth option. The parser
  default of 100 was previously implicit.
- JSON nesting, through a string scan before JSON.parse that skips
  brackets inside strings and handles escapes.
- Collection size, the entries in any one array or properties in any one
  object, checked after parsing and before validation.

Limits default to generous values and accept overrides through
UI5_CONFIG_MAX_BYTES, UI5_MANIFEST_MAX_BYTES, UI5_CONFIG_MAX_DEPTH,
UI5_JSON_MAX_DEPTH and UI5_CONFIG_MAX_COLLECTION. Each failure is a
handled error that names the input and the exceeded limit, with a stable
code (ERR_CONFIG_TOO_LARGE, ERR_CONFIG_TOO_DEEP,
ERR_CONFIG_COLLECTION_TOO_LARGE, ERR_CONFIG_INVALID_LIMIT).

Per-document limits do not bound a graph assembled from many dependency
documents. CI jobs and containers building untrusted projects must still
set process and container resource limits. The Configuration
documentation describes the settings and their defaults.
@devtomtom
devtomtom force-pushed the fix/project-config-size-limits branch from dbf7b6b to 7163d2c Compare November 23, 2026 10:41
@devtomtom

Copy link
Copy Markdown
Member

What about .library files? Do we need a byte limit for these, too?

@codeworrior

codeworrior commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

...and why not for sources? We parse all *.js files and AST creation creates much more overhead than JSON parsing (however, a meaningful limit is even harder than for config files)

| `UI5_CONFIG_MAX_BYTES` | 1048576 bytes (1 MiB) | One `ui5.yaml` file, including all YAML documents in that file |
| `UI5_MANIFEST_MAX_BYTES` | 4194304 bytes (4 MiB) | Each `manifest.json`, `manifest.appdescr_variant`, or `.ui5/build-manifest.json` read during project loading |
| `UI5_CONFIG_MAX_DEPTH` | 100 | YAML parser nesting depth |
| `UI5_JSON_MAX_DEPTH` | 100 | Nested objects and arrays in JSON read through the project JSON parser |

@codeworrior codeworrior Nov 23, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just for my understanding: Why is the nesting level taken as an additional measure, not only file size? Is it to further limit the max heap size needed to represent the content? If I'm not mistaken, the max. number of objects that could be created from a JSON string is roughly max_bytes / 3 (two curly braces + a comma give one empty object).

Or is it reg. stack size, assuming a recursive descent parser or sth. similar?

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.

3 participants

⌂ Proxy