Chrome 扩展权限:危险的那几项到底能让扩展做什么

扩展权限是扩展在 manifest.json 里声明的浏览器能力——cookies、历史等 API 访问权,以及对你访问的页面的主机访问权——Chrome 在安装时授予,以换取扩展承诺的功能。安装对话框用一两行概括它们,而计算领域里后果最重的一行,可能正是人们点得最快的一行:“读取和更改你在所有网站上的所有数据。”本指南点名把浏览器交出去的那几项权限,讲清扩展到底能用每一项做什么,说明为什么 Manifest V3 的方向更安全,并带你用浏览器扩展(CRX)权限检查器在两分钟内自己检查一个 .crx。

把浏览器交出去的那几项

Four asks matter above all others. cookies lets an extension read and modify the cookies of the sites you visit — and a session cookie is the token that proves to a site that you are signed in, so reading cookies can mean reading your signed-in sessions. history reads (and can delete) the list of everywhere you have been. webRequest lets an extension observe your network requests as they happen; its MV2 blocking form, webRequestBlocking, goes further and can block or redirect them, sitting directly in the path of your traffic. And the host pattern — host access, not an API — lets an extension read and change the content of every page on every site.

Each one has honest uses: a session manager needs cookies, a research tool may need history, a privacy tool watches requests, and a page-customising tool touches every page. The permission is not the verdict — the match between the permission and the job is. A password manager asking for broad access is doing its stated job; a unit converter asking for the same four permissions is asking for your browsing life in exchange for arithmetic. Read the install prompt as a question: does THIS job need THIS access?

扩展到底能用每一项做什么

With cookies plus , an extension can read the page you are on and the session that signs you into it — the raw material of account takeover, which is why the combination scores worst in any audit. With history, it builds a profile of your interests, your bank, your employer and your health questions, whether or not it ever opens a page. With webRequest it sees URLs as you load them — including, on careless sites, tokens carried in the URL itself. With tabs it watches what is open; with downloads it can start and open downloads; with nativeMessaging it steps outside the browser entirely and talks to programs on your computer.

Host breadth is a multiplier on all of it. The same cookies permission scoped to one site is a tool; scoped to it is a harvest. That is why a good audit reads the match patterns, not just the permission names: *://*.example.com/* is a claim about one service, *://*/* is a claim about the web. When you inspect a package, read the host patterns first, then the API list — the breadth decides how much the list is worth.CRX permission inspector showing the scary demo at permission risk score 49 of 100

MV3 更安全的方向:declarativeNetRequest、activeTab、服务工作线程

Manifest V3 changed the shape of the dangerous asks. webRequestBlocking — the extension sitting in your traffic, reading and rewriting it — is replaced for most uses by declarativeNetRequest: the extension hands Chrome a list of rules (block this, redirect that), Chrome enforces them, and the extension never sees the requests themselves. Same feature for an ad blocker, radically less exposure for you. Where a tool genuinely needs to react to a page, activeTab offers the narrow path: no standing host access at all, just the one tab you clicked the extension on, until you navigate away.

MV3 also replaced the always-running background page with a service worker that wakes for events and sleeps when idle — less code running all the time, and no persistent page quietly holding state. None of this makes an MV3 extension automatically safe: MV3 extensions can still ask for cookies, history and , and many do. What MV3 changes is the default shape — the safer pattern is now the easy pattern, and an extension that still reaches for the broadest access is making a choice you can ask about.

为什么“读取所有网站上的数据”值得在安装时停一下

Chrome's warning "This extension can read and change your data on sites you visit" (and its strongest form, on all sites) is generated from the manifest: host permissions and content-script matches. It is worth pausing on because it is the one moment the browser shows you the contract before you sign it. After install, the same access is silent — content scripts run on every page, and nothing in normal browsing shows you which extensions touched the page you are reading.

The pause takes ten seconds. Ask what the extension does, and whether doing it requires every site. A screenshot tool needs the current page (activeTab would do); a grammar checker plausibly needs the pages you type in; a theme or a coupon finder needs almost nothing. If the stated job and the requested reach do not match, the store page's privacy section and the permission list in this guide are a better guide than the star rating — popularity measures how many people clicked through the same prompt, not whether they should have.

可选权限与必需权限——以及检查器告诉不了你的事

Required permissions are granted at install: say no, and there is no extension. Optional permissions are declared too, but granted later, one at a time, when a feature needs them — Chrome prompts you at that moment, in context. Well-built extensions put their scariest access behind optional permissions: a history-cleaning tool that asks for history only when you press 'clean' is respecting the boundary, and an inspector should list optional permissions without scoring them like granted ones. When you review a manifest, read the split: what is taken up front, and what is only ever requested in context?

Then the honest limit, for this guide and for the inspector alike: a manifest states what an extension MAY do, never what it DOES do. It cannot tell you whether the code exfiltrates what it reads, whether the publisher sells data, or whether next month's update changes either — updates arrive with the permissions already granted, which is why the update source (store vs a private update_url) is itself a finding. Judging behaviour needs code review or store review. Judging declared access — proportionate or not — takes two minutes and a manifest, and it is the check anyone can run.

两分钟检查一个 .crx

Get the package: from the store, use a CRX-downloader extension or service to fetch the .crx; for a package you were sent, keep the file as-is — both .crx and plain extension .zip work. Open the Browser Extension (CRX) Permission Inspector, load the scary demo first to see a bad report (cookies, history, webRequest, , an off-store update URL — score 49), then the minimal demo (activeTab and storage — score 98), then your own file. Everything runs in your browser: only manifest.json is decompressed, and nothing is uploaded. The same look-inside-before-you-install habit applies on mobile: the IPA Analyzer does it for iOS app packages.

Read the report in this order: the score and its arithmetic (100 minus 12 per critical permission, capped at 48; minus 6 per high, capped at 24; minus 2 per medium, capped at 10; minus 10 for broad host access; minus 3 for a persistent background page; minus 5 for a non-store update URL), then the permission table row by row — each row says what the permission lets the extension do — then the findings. If the access matches the job, install with a clear head. If it does not, the two minutes just bought you the only cheap answer in extension safety: no.

自己试试:一个最小的 MV3 清单

{
  "manifest_version": 3,
  "name": "Minimal Demo Extension",
  "version": "0.1.0",
  "permissions": ["activeTab", "storage"],
  "background": { "service_worker": "sw.js" }
}

来源

常见问题

Can an extension with <all_urls> really see my banking page?

It can read and change the content of pages on all sites, banking pages included, while you are using them. It does not get your bank password from the bank — but it sees what the page shows you and what you type into fields it can read, which is why broad host access combined with cookies is the riskiest pattern in this guide. Use narrow extensions for sensitive browsing, or a separate browser profile.

Are MV3 extensions automatically safe?

No. MV3 removes the most dangerous mechanism (blocking webRequest that reads your traffic) and makes service workers sleep, but an MV3 extension can still request cookies, history and . MV3 makes the safer pattern the easy pattern; it does not force anyone to use it. The manifest is still worth reading — which is the whole point of the inspector.

An extension updated and now behaves differently. Did its permissions change?

Possibly — or the same permissions are being used differently, which no manifest check can see. New permissions beyond the original grant do trigger a Chrome prompt (the extension is disabled until you approve), but behaviour changes inside already-granted permissions are silent. That asymmetry is why the update source matters: store updates pass store review; a private update_url does not.