Skip to content

maxDrawlistBytes config has no upper bound unlike maxEventBytes #409

@sulthonzh

Description

@sulthonzh

Description

The maxDrawlistBytes config option is only validated as a positive integer with requirePositiveInt(), but has no upper bound. In contrast, maxEventBytes is capped at MAX_SAFE_EVENT_BYTES (4 MiB) via requirePositiveIntAtMost(). This inconsistency means a misconfigured or malicious config value could attempt to allocate arbitrarily large buffers.

Context

  • File: packages/core/src/app/createApp/config.ts:97-99
  • Component: App configuration / memory safety

Current Behavior

const maxDrawlistBytes =
    config.maxDrawlistBytes === undefined
      ? DEFAULT_CONFIG.maxDrawlistBytes
      : requirePositiveInt("maxDrawlistBytes", config.maxDrawlistBytes);

While maxEventBytes does:

const maxEventBytes =
    config.maxEventBytes === undefined
      ? DEFAULT_CONFIG.maxEventBytes
      : requirePositiveIntAtMost("maxEventBytes", config.maxEventBytes, MAX_SAFE_EVENT_BYTES);

A consumer passing { maxDrawlistBytes: 2 << 30 } (2 GiB) would be accepted without error, potentially causing OOM crashes at runtime when the drawlist buffer is allocated.

Expected Behavior

maxDrawlistBytes should have an upper bound consistent with the project's memory safety approach, similar to maxEventBytes.

Suggested Fix

 const MAX_SAFE_FPS_CAP = 1000;
 const MAX_SAFE_EVENT_BYTES = 4 << 20; /* 4 MiB */
+const MAX_SAFE_DRAWLIST_BYTES = 8 << 20; /* 8 MiB */

 // ...

 const maxDrawlistBytes =
     config.maxDrawlistBytes === undefined
       ? DEFAULT_CONFIG.maxDrawlistBytes
-      : requirePositiveInt("maxDrawlistBytes", config.maxDrawlistBytes);
+      : requirePositiveIntAtMost("maxDrawlistBytes", config.maxDrawlistBytes, MAX_SAFE_DRAWLIST_BYTES);

Note: The default is 2 << 20 (2 MiB) which is already well within bounds. An 8 MiB cap gives headroom for complex UIs while preventing pathological configs.

Impact

  • Severity: low-medium — requires explicit misconfiguration, but the inconsistency with maxEventBytes could confuse consumers
  • Affects anyone constructing AppConfig with very large maxDrawlistBytes

Positively — happy to submit a PR if this is welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions