skills/browser-extension/extension-security/SKILL.md
Secure browser extensions — CSP configuration, minimal permissions, content script XSS prevention, and handling sensitive data safely.
npx skillsauth add kienbui1995/magic-powers extension-securityInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
optional_permissions for features users might enable laterhost_permissions: ["<all_urls>"] requires strong justification and detailed privacy policy"*://*.github.com/*" over "<all_urls>"MV3 default CSP (strict):
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
}
unsafe-inline, no unsafe-eval'wasm-unsafe-eval'// ❌ Dangerous — XSS if pageData contains script tags
element.innerHTML = pageData;
// ✅ Safe — text only, no HTML interpretation
element.textContent = pageData;
// ✅ Safe — create elements programmatically
const div = document.createElement('div');
div.textContent = userInput;
container.appendChild(div);
chrome.storage (not encrypted)chrome.identity for OAuth (tokens managed by browser)// Validate message sender in background
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
// Verify sender is your extension (not a malicious page)
if (sender.id !== chrome.runtime.id) return;
// Validate message structure
if (!msg.action || typeof msg.action !== 'string') return;
// Process safely
});
Only expose what's needed:
"web_accessible_resources": [{
"resources": ["images/logo.png"],
"matches": ["*://*.trusted-site.com/*"]
}]
Avoid "matches": ["<all_urls>"] for sensitive resources.
chrome.identity — secure OAuth without exposing tokens to pageweb_accessible_resources — extension files visible to web pages (exposure surface)<all_urls> without strong justification?innerHTML with external/user data (use textContent or DOMParser)?web_accessible_resources scoped to specific match patterns?eval() or dynamic code execution?innerHTML with untrusted data (XSS), hardcoded API keys, eval() usageinnerHTML = userContent in content scripts is XSS — page can inject malicious content through DOMchrome.storage is not encrypted — don't store auth tokens or sensitive data therecontent-media
Use when designing for XR (AR/VR/MR), choosing interaction modes, or adapting 2D UI patterns for spatial computing
testing
Use when creating new skills, editing existing skills, or verifying skills work before deployment
development
Use when you have a spec or requirements for a multi-step task, before touching code
development
Use when executing a structured workflow — select and run a feature, bugfix, refactor, research, or incident template with correct agent and model assignments per phase.