DOM changes are cleaned up
Why it matters
When a Chrome extension is updated or disabled while the user has a tab open, the content script context is invalidated but any DOM elements it injected remain. Without cleanup logic, updating the extension leaves orphaned buttons, sidebars, or overlays on long-lived pages — a support and reliability failure that manifests as 'ghost UI' that does nothing when clicked. ISO 25010 reliability requirements apply: a component that cannot clean up its own side effects on context invalidation is not reliably bounded. In enterprise environments where tabs stay open for days, uncleaned DOM from invalidated extension contexts accumulates and causes user-visible breakage.
Severity rationale
Low because orphaned DOM elements are a reliability failure rather than a security vulnerability, but they directly surface to users as broken UI after every extension update.
Remediation
Connect a port in your content script and listen for onDisconnect to remove injected elements when the extension context is invalidated.
// src/content.js
const port = chrome.runtime.connect();
port.onDisconnect.addListener(() => {
host.remove(); // Clean up injected UI
});
Alternatively, assign a unique data-extension-id attribute to all injected elements and remove them all via querySelectorAll in a MutationObserver callback that detects context invalidation.
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 Extension Permissions & Security Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · reliability.recoverability — Recoverability — injected DOM cleaned up after extension context invalidation
Taxons
History
- 2026-04-18·v1.0.0·Initial import from extension-permissions-security·automated