Skip to content

settings API: reject an out-of-range array index instead of filling the gap #1251

Done
learnerabhinavdwivedi-droid/nostream
#1

Description

@chappie-daemon

From the 2026-11-01 scan: F-003 (low, denial of service, CWE-789), src/utils/settings-config.ts. Reachability was not established by the scan.

Current code (main 49f51378): setByPath() parses a path such as dvm.workers[2000000000] into index tokens and calls ensureArrayLength(current, token.index), which is while (target.length <= minimumLength) target.push(undefined). A single authenticated PATCH /admin/settings therefore performs two billion pushes inside the request, before any value validation can reject the setting. The index arrives as a number in the path, so it is fully caller-controlled.

Fix shape

  • Reject an index that is not a safe integer, and reject one beyond a hard maximum array length.
  • Refuse to grow an array by more than a small constant in one set; updates should target an existing index or append one element at the end.
  • Keep the error a validation issue on the path, not a thrown exception that surfaces as a 500.

Acceptance

  • A settings patch with a huge index is refused in bounded time with heap usage unchanged.
  • A normal append (arr[<length>]) and an update of an existing index both still succeed.

Activity

  1. added
    security
    on Nov 26, 2026
  2. learnerabhinavdwivedi-droid commented on Nov 28, 2026

    @learnerabhinavdwivedi-droid
    Contributor

    Hi, I'd like to work on this. My plan: reject an index that isn't a safe integer or is above a hard maximum, and in setByPath allow an index only up to the array's current length (update an existing item or append one at the end), so nothing grows before the check. The PATCH route will report this as a validation issue on the path rather than a 500. I'll add unit tests for a huge index, a normal append and an update, and open the PR from my fork as CONTRIBUTING describes.

  3. learnerabhinavdwivedi-droid commented on Nov 28, 2026

    @learnerabhinavdwivedi-droid
    Contributor

    The fix is ready in my fork: learnerabhinavdwivedi-droid#1 (one commit, f5f9184, changeset included, CI green). It caps an array index at 10,000 in the path check, lets setByPath only update an existing index or append at the end, and returns a 400 validation issue instead of a 500. Could you cherry-pick it? Thanks!

  4. learnerabhinavdwivedi-droid commented on Nov 29, 2026

    @learnerabhinavdwivedi-droid
    Contributor

    A follow-up to my earlier comment: an automated review on my fork PR pointed out that with no override in settings.yaml, an indexed write into a default array lost the rest of that array. For example, the guided field payments.feeSchedules.admission[0].enabled saved only { enabled: true }, without the default amount. That part was already happening before my fix. limits.event.content[1].maxLength was refused after my fix. Both are fixed in f63d813 (learnerabhinavdwivedi-droid#2, changeset included, CI green). Could you cherry-pick both commits, f5f9184 and then f63d813? Thanks!

  5. added 2 commits that reference this issue on Nov 29, 2026
    6fffd86
    0d07f6b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    security

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions