Browser extension
Note for AI agents: This page is baseline guidance, not an exact prescription. Read it, tell your owner what applies to their project, and get their approval before you change anything. Your project's own rules take precedence. If something important for this project is missing here, suggest it to your owner.
For agents
- An extension sees pages the user visits, so mistakes expose browsing data. Typical class: M (S if it never touches page data).
- Rule 1: ask for the fewest permissions and the narrowest host patterns; request more only at the moment of use.
- Rule 2: no remote or evaluated code; treat page data and page messages as untrusted.
- Rule 3: follow the store’s program policies and publish an accurate privacy policy.
Which class?
- S: a small tool that never reads page content or user data.
- M: reads pages, stores data, or uses a server-side API.
- L: broad host access, enterprise deployment, sensitive data.
- XL: a very large install base.
Audit checklist
Every project
- Facts are verified from current official documentation
- What: Commands, libraries, APIs and platform policies in the project come from current official documents, not from memory.
- How to check: Open the dependency list and the platform configuration; for each non-trivial choice find the official page it relies on (link in a comment or a decision note).
- Evidence: Decision note or code comment with the official URL and the date it was checked.
- Packages come from official sources, stable versions only
- What: Packages and versions are chosen from official sources; the current stable release is used, not alpha or beta.
- How to check: Read the dependency file for pre-release tags (alpha, beta, rc, next); check each package on its official registry page.
- Evidence: Dependency file without pre-release versions.
- No secrets in code, chat, commits or logs
- What: Passwords, keys and tokens live in environment variables or a secret manager;
.envis ignored by git; the repository has only.env.example. - How to check: Check
.gitignorefor.env; run a secret scanner (for example gitleaks) over the full history; search for key-like strings. - Evidence:
.gitignoreline, scanner report with zero findings,.env.examplepath.
- What: Passwords, keys and tokens live in environment variables or a secret manager;
- Reports separate “written”, “tested” and “works end to end”
- What: Status reports say clearly whether something is written, passed its tests, or was run end to end; skipped or failed steps are stated.
- How to check: Read the last HANDOFF or release notes; look for features reported as done that have no test or run record.
- Evidence: HANDOFF lines or a test log for each feature marked done.
- Project memory files exist and are current
- What: The repository has CLAUDE.md or AGENTS.md (permanent rules) and HANDOFF.md (where we stopped), updated at the end of every work round.
- How to check: Look in the repository root for both files; compare the HANDOFF date with the latest commit date.
- Evidence: File paths and the date of the last HANDOFF update.
- Permissions are the minimum needed
- What: The manifest requests only needed permissions and the narrowest host patterns; optional permissions are requested at the moment of use.
- How to check: Read
permissions,host_permissionsandoptional_permissions; remove each in a test and see what breaks. - Evidence: Permission list with a reason each.
- No remotely hosted or evaluated code
- What: All executable code is inside the package; no
eval, no loading scripts from the internet; the extension CSP is not loosened. - How to check: Search for
eval,new Function, remote script URLs; read the manifest CSP. - Evidence: Search result; manifest CSP.
- What: All executable code is inside the package; no
- Content scripts treat page data as untrusted
- What: Content scripts do not trust page content or messages from the page; messages are validated and the sender is checked; no raw HTML is inserted from page data.
- How to check: Read message handlers and DOM insertion code.
- Evidence: Handler code with validation.
+ If it has users, personal data or API keys (M)
- One package manager, lockfile committed
- What: Exactly one package manager is used and enforced; the lockfile is committed; installs are done from the lockfile (for example
--frozen-lockfile). - How to check: Look for a lockfile in the repository and a rule that forbids other managers; check the CI and Docker install commands.
- Evidence: Lockfile path; install command lines.
- What: Exactly one package manager is used and enforced; the lockfile is committed; installs are done from the lockfile (for example
- Store policies and privacy declarations are met
- What: The extension meets the store’s current program policies (single purpose, user data handling) and has an accurate privacy policy and data disclosure.
- How to check: Read the store policy pages and compare with the listing and behavior.
- Evidence: Policy notes; privacy policy URL.
- Secrets are not stored in plain extension storage
- What: Tokens are kept as short-lived as possible and not in places other scripts can read; no API keys in the package.
- How to check: Search the package for keys; read how tokens are stored.
- Evidence: Search result; storage code.
- All input is validated on the server with a schema
- What: Every request body, query and parameter is checked on the server against a schema; the client check is only a convenience.
- How to check: For each endpoint find the schema or validator; send invalid, oversized and unexpected fields and see the response.
- Evidence: Validator files per endpoint; test cases for invalid input.
- External API keys stay on the server
- What: Third-party API keys (including LLM keys) are kept on the server and never shipped to the browser or app.
- How to check: Search the client bundle and app package for key-like strings; check that client calls go to your own server.
- Evidence: Search result with zero keys in the client build.
- Logs contain no personal data or secrets
- What: Logs do not record passwords, tokens, keys or personal data; if needed they are masked.
- How to check: Read the logging setup; trigger a login and a form and inspect the log lines; search for e-mail and token patterns.
- Evidence: Sample log lines after a test run showing masking.
- Personal data fields are documented
- What: For every personal data field the purpose, retention time and legal basis (KVKK, GDPR) are written down.
- How to check: List the database columns and form fields with personal data; find the matching entries in the data note.
- Evidence: Data note listing each field with purpose, period and basis.
- Critical flows have automated tests and a local check
- What: Login, saving data, payment (if any) and permission checks have automated tests; one local command runs the checks before pushing.
- How to check: List the test files; run the check command; look for a git hook that runs it.
- Evidence: Test names and a passing run log.
- Secret scanning runs before push and in CI
- What: A scanner (for example gitleaks or secretlint) runs before code is pushed and in CI.
- How to check: Find the hook or CI step that runs the scanner.
- Evidence: Hook file or CI step; latest clean run.
- Accessibility basics meet WCAG 2.2 AA
- What: Correct heading order, text alternatives, enough contrast, keyboard navigation, visible focus, sufficient touch targets, and respect for reduced-motion settings.
- How to check: Tab through every screen; run an automated checker (for example axe) and a contrast check; test with a screen reader once; check
prefers-reduced-motionhandling. - Evidence: Checker report, list of screens tried with keyboard and screen reader.
- Open source licenses are shown
- What: A published app or site shows the name and license of each library (for example Settings → Open source licenses), generated from the lockfile; forbidden licenses fail a check.
- How to check: Find the licenses screen or file and how it is generated; look for a license check in CI.
- Evidence: Generated license list; CI step.
+ If it has an admin panel, file uploads, many users or a store app (L)
Items for class L: see Browser extension: classes L–XL checklist.
+ If it targets millions of users (XL)
Items for class XL: see Browser extension: classes L–XL checklist.
Common mistakes
- Requesting access to all websites when one site is enough.
- Loading a script from a remote server or using
eval. - Trusting messages that come from the web page.
- Inserting page text into the DOM as raw HTML.
- Storing tokens where page scripts or other extensions can read them.
- A privacy policy that does not mention data the extension really sends.
- Asking for tabs, history and cookies together without a clear reason.
- Shipping API keys inside the package.
Example projects
- Dark mode toggler for one site: extension, S.
- Tab organizer: extension, M, tab data.
- Password helper extension: extension, L, sensitive data.
- Price tracker reading shop pages: extension, M.
- Ad blocker with a rule list: extension, M.
- Developer tools panel extension: extension, M.
- Web clipper that saves pages to a server: extension, M, personal data.
- Translator on selected text: extension, M.
- Accessibility helper that changes fonts: extension, S.
- Company-wide extension on managed browsers: extension, L.
- Screenshot tool: extension, M.
- Social media scheduler extension: extension, M.
Sources
- Declare permissions — Chrome for Developers
- Permission warning guidelines — Chrome for Developers
- Content scripts — Chrome for Developers
- Stay secure (extensions) — Chrome for Developers
- Extensions manifest: Content Security Policy — Chrome for Developers
- Chrome Web Store program policies — Chrome for Developers
- Chrome Web Store: user data FAQ — Chrome for Developers
- Manifest V3 — Chrome for Developers
- WebExtensions manifest: permissions — MDN Web Docs
- Content scripts — MDN Web Docs
- Browser Extension Vulnerabilities Cheat Sheet — OWASP Cheat Sheet Series
- Pro Build Guide v1.2: compiled team practices — Pro Build Guide