No global state pollution
Why it matters
When plugins receive mutable references to shared objects — config, process.env, shared caches — any plugin can modify state that all other plugins and the host depend on. Plugin A changes config.apiUrl and Plugin B silently uses the wrong endpoint. A plugin calling require('dotenv').config() overwrites environment variables for every module in the process. CWE-454 (Unintended Variable Set from External Scope) and CWE-829 cover this class. The failure mode is load-order-dependent and nearly impossible to reproduce in isolation, making it one of the hardest bugs to diagnose in plugin ecosystems.
Severity rationale
High because plugins writing to shared global state or mutating passed-by-reference objects create load-order-dependent bugs between plugins that are invisible during individual plugin testing.
Remediation
Freeze or deep-clone any object before passing it to plugin code. For config objects, a Proxy that throws on write gives a clear error attributing the mutation attempt to the offending plugin.
// Freeze config before passing to plugins:
const pluginConfig = Object.freeze(structuredClone(hostConfig));
// Or use a Proxy to prevent writes:
const readonlyConfig = new Proxy(config, {
set() { throw new Error('Config is read-only for plugins'); },
deleteProperty() { throw new Error('Config is read-only for plugins'); }
});
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Plugin / Extension Architecture Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-829 — Inclusion of Functionality from Untrusted Control Sphere — plugin code must not modify shared global state or host prototypes
- cwe · CWE-454 — External Initialization of Trusted Variables or Data Stores — plugins writing to process.env or global can compromise host integrity
- owasp:2021 · A03 — Injection — prototype pollution is a JavaScript injection vector
Taxons
History
- 2026-04-18·v1.0.0·Initial import from plugin-extension-architecture·automated