Extension Analyze (Security & Compliance Auditor)
Audit an existing Chrome extension. Do NOT just explain — execute the workflow.
Workflow (Execute This)
Step 1: Locate extension root and detect framework
Ask user for path if not provided. Detect framework:
ls wxt.config.ts plasmo.config.ts vite.config.ts manifest.json 2>/dev/null
- Plasmo: manifest auto-generated; check
package.json and plasmo.config.ts instead
- WXT: check
wxt.config.ts manifest section
- Vanilla/CRXJS: check
manifest.json directly
Step 2: Scan manifest.json (or equivalent config)
# Check MV version, permissions, host_permissions, CSP, web_accessible_resources
cat <ext>/manifest.json | jq '{manifest_version, permissions, host_permissions, content_security_policy, web_accessible_resources}'
Step 3: Quick grep scans
# XSS vectors
grep -rn "innerHTML\|outerHTML\|document\.write\|insertAdjacentHTML" <ext>/src --include="*.ts" --include="*.js"
# Unsafe patterns
grep -rn "eval(\|new Function(\|setTimeout.*string\|setInterval.*string" <ext>/src
# Hardcoded secrets
grep -rn "api_key\|apiKey\|secret\|password\|token" <ext>/src --include="*.ts" --include="*.js" | grep -v "\.test\." | grep -v "node_modules"
# HTTP (non-HTTPS) calls
grep -rn "http://" <ext>/src --include="*.ts" --include="*.js"
# Message handler sender validation
grep -rn "onMessage\|addListener" <ext>/src | grep -v "node_modules"
# Remote code loading
grep -rn "importScripts\|fetch.*\.js\|eval\|chrome\.scripting\.executeScript" <ext>/src
Step 4: Check CSP configuration
- MV3 default CSP:
script-src 'self'; object-src 'self'
- Flag any
unsafe-inline, unsafe-eval, or http: sources
- Verify no remote script sources
Step 5: Dependency audit
cd <ext> && npm audit --json | jq '.vulnerabilities | to_entries[] | {pkg: .key, severity: .value.severity}'
Step 6: Generate report
Output findings grouped by severity. See Output Format below.
Severity Levels
| Level |
Criteria |
| Critical |
RCE, data exfiltration, remote code loading, eval with untrusted input |
| High |
XSS, missing sender validation, API keys in source, HTTP API calls |
| Medium |
Overly broad permissions, unsafe-inline CSP, sync storage secrets |
| Low |
Missing error handling, no TypeScript, console.log in production |
Top 10 Issues Found in Most Extensions
innerHTML with page-sourced data (XSS) — High
onMessage without sender origin check — High
<all_urls> host permission when not needed — Medium
unsafe-inline or unsafe-eval in CSP — Medium/Critical
- API keys hardcoded in source — Critical
eval() or new Function() usage — Critical
chrome.storage.sync storing sensitive data — Medium
- HTTP endpoints instead of HTTPS — High
- Remote script loading (MV3 violation) — Critical
- Missing
web_accessible_resources restrictions — Medium
Output Format
## Extension Audit Report: <name> v<version>
Date: <date> | MV: <2|3>
### Summary
Critical: X | High: X | Medium: X | Low: X
### Findings
#### [CRITICAL] API Key Exposed in Source
File: src/background.ts:42
Pattern: `const API_KEY = "sk-..."`
Fix: Move to environment variable or user-provided settings
Reference: references/common-vulnerabilities.md#4
...
### Passed Checks
- CSP: No unsafe-inline/eval ✓
- HTTPS: All API calls use HTTPS ✓
References
references/security-checklist.md — Full security audit checklist
references/best-practices-checklist.md — Performance, UX, accessibility, CWS
references/common-vulnerabilities.md — Vulnerability patterns with grep/fix
references/cws-compliance-checklist.md — Chrome Web Store policy compliance
- Chrome Permissions List
- Chrome Extensions Docs
Related Skills
extension-manifest — Generate/validate manifest.json
extension-create — Scaffold new extension
extension-publish — Store submission checklist
1---2name: extension-analyze3description: Audit Chrome extensions for security issues, best practice violations, performance problems, and CWS compliance. Scans manifest, code, CSP, message handlers, storage, and dependencies.4---56# Extension Analyze (Security & Compliance Auditor)78Audit an existing Chrome extension. Do NOT just explain — execute the workflow.910## Workflow (Execute This)1112### Step 1: Locate extension root and detect framework1314Ask user for path if not provided. Detect framework:15```bash16ls wxt.config.ts plasmo.config.ts vite.config.ts manifest.json 2>/dev/null17```18- **Plasmo**: manifest auto-generated; check `package.json` and `plasmo.config.ts` instead19- **WXT**: check `wxt.config.ts` manifest section20- **Vanilla/CRXJS**: check `manifest.json` directly2122### Step 2: Scan manifest.json (or equivalent config)2324```bash25# Check MV version, permissions, host_permissions, CSP, web_accessible_resources26cat <ext>/manifest.json | jq '{manifest_version, permissions, host_permissions, content_security_policy, web_accessible_resources}'27```2829### Step 3: Quick grep scans3031```bash32# XSS vectors33grep -rn "innerHTML\|outerHTML\|document\.write\|insertAdjacentHTML" <ext>/src --include="*.ts" --include="*.js"3435# Unsafe patterns36grep -rn "eval(\|new Function(\|setTimeout.*string\|setInterval.*string" <ext>/src3738# Hardcoded secrets39grep -rn "api_key\|apiKey\|secret\|password\|token" <ext>/src --include="*.ts" --include="*.js" | grep -v "\.test\." | grep -v "node_modules"4041# HTTP (non-HTTPS) calls42grep -rn "http://" <ext>/src --include="*.ts" --include="*.js"4344# Message handler sender validation45grep -rn "onMessage\|addListener" <ext>/src | grep -v "node_modules"4647# Remote code loading48grep -rn "importScripts\|fetch.*\.js\|eval\|chrome\.scripting\.executeScript" <ext>/src49```5051### Step 4: Check CSP configuration5253- MV3 default CSP: `script-src 'self'; object-src 'self'`54- Flag any `unsafe-inline`, `unsafe-eval`, or `http:` sources55- Verify no remote script sources5657### Step 5: Dependency audit5859```bash60cd <ext> && npm audit --json | jq '.vulnerabilities | to_entries[] | {pkg: .key, severity: .value.severity}'61```6263### Step 6: Generate report6465Output findings grouped by severity. See **Output Format** below.6667---6869## Severity Levels7071| Level | Criteria |72|-------|----------|73| **Critical** | RCE, data exfiltration, remote code loading, eval with untrusted input |74| **High** | XSS, missing sender validation, API keys in source, HTTP API calls |75| **Medium** | Overly broad permissions, unsafe-inline CSP, sync storage secrets |76| **Low** | Missing error handling, no TypeScript, console.log in production |7778---7980## Top 10 Issues Found in Most Extensions81821. `innerHTML` with page-sourced data (XSS) — **High**832. `onMessage` without sender origin check — **High**843. `<all_urls>` host permission when not needed — **Medium**854. `unsafe-inline` or `unsafe-eval` in CSP — **Medium/Critical**865. API keys hardcoded in source — **Critical**876. `eval()` or `new Function()` usage — **Critical**887. `chrome.storage.sync` storing sensitive data — **Medium**898. HTTP endpoints instead of HTTPS — **High**909. Remote script loading (MV3 violation) — **Critical**9110. Missing `web_accessible_resources` restrictions — **Medium**9293---9495## Output Format9697```98## Extension Audit Report: <name> v<version>99Date: <date> | MV: <2|3>100101### Summary102Critical: X | High: X | Medium: X | Low: X103104### Findings105106#### [CRITICAL] API Key Exposed in Source107File: src/background.ts:42108Pattern: `const API_KEY = "sk-..."`109Fix: Move to environment variable or user-provided settings110Reference: references/common-vulnerabilities.md#4111112...113114### Passed Checks115- CSP: No unsafe-inline/eval ✓116- HTTPS: All API calls use HTTPS ✓117```118119---120121## References122123- `references/security-checklist.md` — Full security audit checklist124- `references/best-practices-checklist.md` — Performance, UX, accessibility, CWS125- `references/common-vulnerabilities.md` — Vulnerability patterns with grep/fix126- `references/cws-compliance-checklist.md` — Chrome Web Store policy compliance127- [Chrome Permissions List](https://developer.chrome.com/docs/extensions/reference/permissions-list)128- [Chrome Extensions Docs](https://developer.chrome.com/docs/extensions/develop)129130## Related Skills131132- `extension-manifest` — Generate/validate manifest.json133- `extension-create` — Scaffold new extension134- `extension-publish` — Store submission checklist