Why declarativeNetRequest is better for your privacy
Header extensions used to work by reading every request your browser made. Manifest V3's declarativeNetRequest flips that: the extension hands Chrome a set of rules, and Chrome applies them without showing the extension your traffic.
The old way: webRequest
With the blocking webRequest API, Chrome paused each request and passed it to the extension's code: the URL, the headers, everything. The extension decided what to change and handed it back. That works, but the extension sees every request on the sites it can access, and nothing but its own good behaviour stops it keeping a copy.
The new way: declarativeNetRequest
With declarativeNetRequest (DNR), an extension registers rules ahead of time, for example:
{
"id": 1,
"action": {
"type": "modifyHeaders",
"requestHeaders": [{ "header": "Authorization", "operation": "set", "value": "Bearer …" }]
},
"condition": { "urlFilter": "||api.example.com", "resourceTypes": ["xmlhttprequest"] }
}
Chrome's network stack matches requests against those rules and applies them itself. The extension's code isn't called per request, so it never sees the URLs or headers going by. Changing headers, redirecting, blocking and upgrading to HTTPS all work this way.
What that buys you
- Less to trust. An extension that only uses DNR doesn't receive your traffic, so it can't leak it, even by accident.
- Easier to audit. If the manifest has no
webRequestpermission and the code just builds rules, there's no path for request data into the extension. - Speed. Rules run in the browser's network code, without a round trip to an extension's JavaScript.
The limits, honestly
- DNR alone isn't a guarantee. The same extension could also ask for
webRequest,cookiesortabs, or inject content scripts. Read the whole permission list. - Rule feedback. The
declarativeNetRequestFeedbackpermission lets an unpacked extension see which rules matched which requests, for debugging. Worth noticing if a published extension asks for it. - Less flexible. Rules can't compute a value per request or read a response body. That's why some tools want more access, and why that access deserves a reason.
How ProperHeader uses it
ProperHeader turns your profiles into DNR rules and gives them to Chrome. It doesn't request webRequest, so its code never reads your requests. You can check this in the package in a few minutes.
Questions
Can a declarativeNetRequest extension see my requests?
Not through declarativeNetRequest itself: Chrome applies the rules without passing requests to the extension. Check that it doesn't also request webRequest or similar permissions.
Can declarativeNetRequest modify response headers?
Yes. modifyHeaders rules can set, append or remove both request and response headers.