Skip to content

getPlan() returns Object.prototype members for a plan id like "constructor" #223

Closed

Description

@nc9

getPlan in packages/core-contracts/src/plans.ts is:

return PLANS[planId] ?? PLANS.free;

PLANS is a plain object literal, so a lookup by a key that names an Object.prototype member returns that member instead of falling back to Free. getPlan("constructor") returns the Object function, which is truthy, so the ?? never fires. The caller then reads .id as undefined, .maxPagesPerAudit as undefined, and planMaxPages() produces NaN from it, which silently disables the clamp it was supposed to apply.

The key comes from a database column, not from request input, so this is latent rather than exploitable today. It is one bad row or one webhook mapping change away from being live, and the failure is silent in the direction that removes a limit.

Found while reviewing per-plan container sizing, where an unrecognized plan id has to fail closed to Free.

Acceptance Criteria

  • getPlan("constructor"), getPlan("__proto__") and getPlan("toString") each return the Free plan
  • The fix uses an own-property check (Object.hasOwn) or a null-prototype registry rather than a denylist of key names
  • A test covers those three keys plus an ordinary unknown id

Activity

  1. added
    bug
    security
    P3
    size: XS
    on Sep 23, 2026
  2. nc9 commented on Oct 11, 2026

    @nc9
    ContributorAuthor

    Checked against current main (ad95fb2): REPRODUCES. getPlan is still return PLANS[planId as PlanId] ?? PLANS.free; over a plain object literal (packages/core-contracts/src/plans.ts:191-193).

    I loaded plans.ts from main with Bun and called it:

    constructor -> function id= undefined maxPagesPerAudit= undefined
    __proto__ -> object id= undefined maxPagesPerAudit= undefined
    toString -> function id= undefined maxPagesPerAudit= undefined
    nope -> object id= free maxPagesPerAudit= 500
    

    Only the ordinary unknown id falls back to Free.

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

    P3bugsecuritysize: XS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions