Skip to content

WS002 · Mutable global variable

Default severity: HIGH · Framework: Any

Detects global declarations and writes to $GLOBALS or superglobals. Process-wide state can be shared between requests; the persistence of request superglobals depends on the selected runtime. Read the finding-level severity and lifecycle details.

  • Pass the value explicitly, or resolve it from a request-scoped service.
  • If a process-wide value is genuinely needed, expose it through an immutable object built once at boot.
  • Never write application state into $GLOBALS or into the request superglobals.
Terminal window
vendor/bin/worker-safety rules WS002

Use a targeted suppression or a baseline only after reviewing the value’s origin and lifetime. Changing an assignment elsewhere may not invalidate an existing property-level suppression.