Skip to content

Proposal: Limits on lengths of strings passed to WebExtension APIs #935

@bershanskiy

Description

@bershanskiy

Most WebExtension APIs hang when they receive overly long strings. In a typical page, when JS calls a Web-exposed API, at worst it can hang a singe web frame or a tab. Extensions run with less isolation and in practice can hang the entire browser. This is a blanket issue where I'll index all WebExtension APIs and manifest fields and current browser behavior.

API Analysis

Action Title

String sources
  • action.setTitle() (user-visible, dynamic)
  • action.default_title manifest key (user-visible, static, localizable)
  • browser_action.default_title manifest key (user-visible, static, localizable)

Alarm Name #422

String sources
  • alarms.create({name}) - (non-user-visible, dynamic)
    • Alarm name length limit - No length limits in any browser, every browser can hang.
    • Alarm count limit
      • Chromium 117 (PSA, commit) limits each extension to 500 alarms, throwing an error 'An extension cannot have more than 500 active alarms.' if extension attempts to create 501-th alarm.
      • Firefox does not have a limit, tracking bug
  • alarms.clear(name)
  • alarms.get(name)
Next Action

Collect data from Chrome 144 Histogram, discuss during meeting on Jan 29, 2026.

Paths in extensions

Extension icon path length
  • action.setIcon({path})
Extension popup path length
  • action.setPopup({popup})
  • browser_action.setPopup({popup})

Extension badge text #960

  • action.setBadgeText({text})

Chrome issue: https://issues.chromium.org/issues/491158086
Chrome Histogram CL: https://chromium-review.googlesource.com/c/chromium/src/+/7651914

Process to introduce string length limit

Tentative steps to introduce a limit for an API:

  1. Identify parameter which does not have a limit yet. Fill out Column 1.
    For example, "alarm name".
  2. Identify every API method and/or manifest key where this parameter may occur as an input (source of long inputs for browser). Fill out Column 2.
    For example, for "alarm name", sources can be alarms.create({name}) alarms.clear(name) alarms.get(name). While some other APIs also deal with alarm names (e.g., alarm.getAll() would still be overloaded by long alarm names), they are actually outputs (sinks of long names).
  3. Figure out current behavior in browsers.
    Try to pass long inputs for each method and/or manifest key identified in step 2 and record outcome. Repeat with a few browsers, if technically possible and time allows.
  4. Introduce a study (a histogram) to track usage in one browser.
    Identify appropriate "buckets" of input lengths. Preferably, list them in the table above and/or dedicated issue under WECG repository. Also, discuss potential future behaviors for dealing with long inputs (silently ignore, ignore with a warning, or throw an error).
  5. Wait for study results
    Wait a few "milestones" for histogram code to reach stable releases, then a few more to collect reasonably representative data.
  6. Finalize the proper limit and behavior for long inputs.
    Discuss study results in WECG tracker or a meeting.
  7. Add WPT cases for he limit and implement the new behavior in at least one browser.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions