1. Introduction
Today, user agents generally identify themselves to servers by sending a User-Agent HTTP request
header field along with each request (defined in Section 5.5.3 of [RFC7231]). Ideally, this header
would give servers the ability to perform content negotiation, sending down exactly those bits that
best represent the requested resource in a given user agent, optimizing both bandwidth and user
experience. In practice, however, this header’s value exposes far more information about the user’s
device than seems appropriate as a default, on the one hand, and intentionally obscures the true
user agent in order to bypass misguided server-side heuristics, on the other.
For example, a recent version of Chrome on iOS identifies itself as:
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X)
AppleWebKit/605.1.15 (KHTML, like Gecko)
CriOS/69.0.3497.105 Mobile/15E148 Safari/605.1
While a recent version of Edge identifies itself as:
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.2704.79
Safari/537.36 Edge/18.014
There’s quite a bit of information packed into those strings (along with a fair number of lies). Version numbers, platform details, model information, etc. are all broadcast along with every request, and form the basis for fingerprinting schemes of all sorts. Individual vendors have taken stabs at altering their user agent strings, and have run into a few categories of feedback from developers that have stymied historical approaches:
-
Brand and version information (e.g. "Chrome 69") allows websites to work around known bugs in specific releases that aren’t otherwise detectable. For example, implementations of Content Security Policy have varied wildly between vendors, and it’s difficult to know what policy to send in an HTTP response without knowing what browser is responsible for its parsing and execution.
-
Developers will often negotiate what content to send based on the user agent and platform. Some application frameworks, for instance, will style an application on iOS differently from the same application on Android in order to match each platform’s aesthetic and design patterns.
-
Similarly to #1, OS revisions and architecture can be responsible for specific bugs which can be worked around in website’s code, and narrowly useful for things like selecting appropriate executables for download (32 vs 64 bit, ARM vs Intel, etc).
-
Sophisticated developers use model/make to tailor their sites to the capabilities of the device (e.g. [FacebookYearClass]) and to pinpoint performance bugs and regressions which sometimes are specific to model/make.
This document proposes a mechanism which might allow user agents to be a bit more aggressive about
removing entropy from the User-Agent string generally by giving servers that really need some
specific details about the client the ability to opt-into receiving them. It introduces four new
Client Hints ([RFC8942]) that can provide the client’s branding and version
information, the underlying operating system’s branding and major version, as well as details about
the underlying device. Rather than broadcasting this data to everyone, all the time, user agents can
make reasonable decisions about how to respond to given sites' requests for more granular data,
reducing the passive fingerprinting surface area exposed to the network (see Best Practice 1 in [FINGERPRINTING-GUIDANCE]).
1.1. Examples
A user navigates to https://example.com/ for the first time using the latest version of the
"Examplary Browser". Their user agent sends the following headers along with the HTTP request:
Sec-CH-UA: "Examplary Browser"; v="73", ";Not?A.Brand"; v="27" Sec-CH-UA-Mobile: ?0 Sec-CH-UA-Platform: "Windows"
The server is interested in rendering content consistent with the user’s underlying platform version,
and asks for a little more information by sending an Accept-CH header (Section 2.2.1 of [RFC8942]) along with the initial response:
Accept-CH: Sec-CH-UA-Platform-Version
In response, the user agent includes the platform version information in the next request:
Sec-CH-UA: "Examplary Browser"; v="73", ";Not?A.Brand"; v="27" Sec-CH-UA-Mobile: ?0 Sec-CH-UA-Platform: "Windows" Sec-CH-UA-Full-Version: "10.0.19042"
2. Infrastructure
This specification depends on Client Hints Infrastructure, HTTP Client Hints, and the Infra Standard. [CLIENT-HINTS-INFRASTRUCTURE] [RFC8942] [INFRA]
Some of the terms used in this specification are defined in Structured Field Values for HTTP. [RFC8941]
3. User Agent Hints
The following sections define a number of HTTP request header fields that expose detail about a given user agent, which servers can opt-into receiving via the Client Hints infrastructure defined in [RFC8942]. The definitions below assume that each user agent has defined a number of properties for itself:
-
brand - The user agent's commercial name (e.g., "cURL", "Edge", "The World’s Best Web Browser")
-
significant version - The user agent's marketing version, which includes distinguishable web-exposed features (e.g., "72", "3", or "12.1")
-
full version - The user agent's build version (e.g., "72.0.3245.12", "3.14159", or "297.70E04154A")
-
platform brand - The user agent's operating system’s commercial name. (e.g., "Windows", "iOS", or "AmazingOS")
-
platform version - The user agent's operating system’s version. (e.g., "NT 6.0", "15", or "17G")
-
platform architecture - The user agent's underlying CPU architecture (e.g., "ARM", or "x86")
-
platform bitness - The user agent's underlying CPU architecture bitness (e.g., "32" or "64")
-
model - The user agent's device model (e.g., "", or "Pixel 2 XL")
-
mobileness - A boolean indicating if the user agent's device is a mobile device. (e.g., ?0 or ?1)
User agents SHOULD keep these strings short and to the point, but servers MUST accept arbitrary values for each, as they are all values constructed at the user agent's whim.
User agents MUST map higher-entropy platform architecture values to the following buckets:
-
x86 CPU architectures => "x86"
-
ARM CPU architectures => "arm"
Other CPU architectures could be mapped into one of these values in case that makes sense, or be mapped to the empty string.
User agents SHOULD return the empty string or a fictitious value for platform architecture or platform bitness unless the user’s platform is one where both the following conditions apply:
-
Binary download of executables is likely.
-
Different CPU architectures are likely to require different binary executable resources, and different binary executable resources are likely to be available.
User Agents MUST return the empty string for model if mobileness is false. User Agents MUST return the empty string for model even if mobileness is true, except on platforms where the model is typically exposed.
User agents MAY return the empty string or a fictitious value for full version, platform architecture, platform bitness or model, for privacy, compatibility, or other reasons.
3.1. The 'Sec-CH-UA' Header Field
The Sec-CH-UA request header field gives a server information about a user agent's branding and version. It is a Structured Header whose value MUST be a list [RFC8941]. The list’s items MUST be string. The value of each item SHOULD include a "v" parameter, indicating the user agent's version.
The header’s ABNF is:
Sec-CH-UA = sf-list
Note: Unlike most Client Hints, since it’s included in the low entropy hint table,
the Sec-CH-UA header will be sent by default, whether or not the server opted-into
receiving the header via an Accept-CH header (although it can still be controlled by it’s policy controlled client hints feature.
It is considered low entropy because it includes only the user agent's branding information,
and the significant version number (both of which are fairly clearly sniffable by "examining the
structure of other headers and by testing for the availability and semantics of the features
introduced or modified between releases of a particular browser" [Janc2014]).
3.2. The 'Sec-CH-UA-Arch' Header Field
The Sec-CH-UA-Arch request header field gives a server information about
the architecture of the platform on which a given user agent is executing. It is a Structured Header whose value MUST be a string [RFC8941].
The header’s ABNF is:
Sec-CH-UA-Arch = sf-string
3.3. The 'Sec-CH-UA-Bitness' Header Field
The Sec-CH-UA-Bitness request header field gives a server information about
the bitness of the architecture of the platform on which a given user agent is executing. It is
a Structured Header whose value MUST be a string [RFC8941].
The header’s ABNF is:
Sec-CH-UA-Bitness = sf-string
3.4. The 'Sec-CH-UA-Full-Version' Header Field
The Sec-CH-UA-Full-Version request header field gives a server information
about the user agent’s full version. It is a Structured Header whose value MUST be a string [RFC8941].
The header’s ABNF is:
Sec-CH-UA-Full-Version = sf-string
3.5. The 'Sec-CH-UA-Mobile' Header Field
The Sec-CH-UA-Mobile request header field gives a server information about
whether or not a user agent prefers a "mobile" user experience. It is a Structured Header whose value MUST be a boolean [RFC8941].
The header’s ABNF is:
Sec-CH-UA-Mobile = sf-boolean
Note: Like Sec-CH-UA above, since it’s included in the low entropy hint table,
the Sec-CH-UA-Mobile header will be sent by default, whether or not the server opted-into
receiving the header via an Accept-CH header (although it can still be controlled by its policy controlled client hints feature). It is considered low entropy because it is a single
bit of information directly controllable by the user.
3.6. The 'Sec-CH-UA-Model' Header Field
The Sec-CH-UA-Model request header field gives a server information about
the device on which a given user agent is executing. It is a Structured Header whose value MUST
be a string [RFC8941].
The header’s ABNF is:
Sec-CH-UA-Model = sf-string
Perhaps Sec-CH-UA-Mobile is enough, and we don’t need to expose the model?
3.7. The 'Sec-CH-UA-Platform' Header Field
The Sec-CH-UA-Platform request header field gives a server information
about the platform on which a given user agent is executing. It is a Structured Header whose value MUST be a string [RFC8941]. Its value SHOULD match one of the
following common platform values: "Android", "Chrome OS", "iOS", "Linux", "macOS", "Windows", or
"Unknown".
The header’s ABNF is:
Sec-CH-UA-Platform = sf-string
Note: Like Sec-CH-UA above, since it’s included in the low entropy hint table, the Sec-CH-UA-Platform header will be sent by default, whether or not the server opted-into receiving
the header via an Accept-CH header (although it can still be controlled by its policy controlled client hints feature).
3.8. The 'Sec-CH-UA-Platform-Version' Header Field
The Sec-CH-UA-Platform-Version request header field gives a server
information about the platform version on which a given user agent is executing. It is a Structured Header whose value MUST be a string [RFC8941].
The header’s ABNF is:
Sec-CH-UA-Platform-Version = sf-string
To return the Sec-CH-UA value for a request, user agents MUST:
-
Let list be a list, initially empty.
-
For each brandVersion in brands:
-
Let parameter be a dictionary, initially empty.
-
Set parameter["param_name"] to "v".
-
Set parameter["param_value"] to brandVersion’s
version. -
Let pair be a tuple comprised of brandVersion’s
brandand parameter. -
Append pair to list.
-
-
Return the output of running serializing a list with list as input.
Note: These client hints can be evoked with the following set of client hints tokens: Sec-CH-UA, Sec-CH-UA-Arch, Sec-CH-UA-Bitness, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version
4. Interface
dictionary {NavigatorUABrandVersion DOMString ;brand DOMString ; };version dictionary {UADataValues FrozenArray <NavigatorUABrandVersion >;brands boolean ;mobile DOMString ;platform DOMString ;architecture DOMString ;bitness DOMString ;model DOMString ;platformVersion DOMString ; }; [uaFullVersion Exposed =(Window ,Worker )]interface {NavigatorUAData readonly attribute FrozenArray <NavigatorUABrandVersion >;brands readonly attribute boolean ;mobile readonly attribute DOMString ;platform Promise <UADataValues >(getHighEntropyValues sequence <DOMString >); };hints interface mixin { [NavigatorUA SecureContext ]readonly attribute NavigatorUAData ; };userAgentData Navigator includes NavigatorUA ;WorkerNavigator includes NavigatorUA ;
Note: The high-entropy portions of the user agent information are retrieved through a Promise, in order to give user agents the opportunity to gate their exposure behind potentially time-consuming checks (e.g. by asking the user for their permission).
4.1. Processing model
4.1.1. WindowOrWorkerGlobalScope
Each user agent has an associated brands, which is a list created by running create brands.
Every WindowOrWorkerGlobalScope object has an associated brands frozen array,
which is a FrozenArray<NavigatorUABrandVersion>. It is initially the
result of creating a frozen array from the user agent's brands.
4.1.2. Create brands
When asked to run the create brands algorithm, the user agent MUST run the following steps:
-
Let list be a list.
-
Collect pairs of brand and significant version which represent the user agent or equivalence classes.
-
For each pair:
-
Let dict be a new
NavigatorUABrandVersiondictionary, with brand asbrandand significant version asversion. -
Append dict to list.
-
-
The user agent SHOULD execute the following steps:
-
Append one additional item to list containing a
NavigatorUABrandVersiondictionary, initialized with arbitrary brand and arbitrary version combinations. -
Randomize the order of the items in list.
Note: One approach to minimize caching variance when generating these random components could be to determine them at build time, and keep them identical throughout the lifetime of the user agent's significant version.
Note: See § 6.2 GREASE-like UA Brand Lists for more details on when and why these randomization steps might be appropriate.
-
-
Return list.
An equivalence class represents a group of browsers believed to be compatibile with each other. A shared rendering engine may form an equivalence class, for example.
4.1.3. Create arbitrary brand and version values
To create an arbitrary brand, the user agent MUST run these steps:
-
Let arbitraryBrand be a string composed of ASCII alpha. arbitraryBrand MUST contain one or more 0x20 (SP) bytes and be no longer than twenty ASCII bytes.
-
Let arbitraryBrandList be the result of splitting arbitraryBrand on ASCII whitespace.
-
Let greaseyStack be a stack.
-
Let greaseyChars be the list of ASCII bytes « 0x20 (SP), 0x28 (left parenthesis), 0x29 (right parenthesis), 0x2D (-), 0x2E (.), 0x2F (/), 0x3A (:), 0x3B (;), 0x3D (=), 0x3F (?), 0x5F (_) ».
-
For each item of arbitraryBrandList, push a randomly selected item from greaseyChars onto greaseyStack.
-
Let greaseyBrandList be a list and index be 0.
-
While greaseyStack is not empty:
-
Let item be the result of popping from greaseyStack.
-
Append item to greaseyBrandList.
-
Append arbitraryBrandList[index] to greaseyBrandList.
-
Increment index by 1.
-
-
Return the result of stripping leading and trailing ASCII whitespace from the concatenation of greaseyBrandList (with no separator).
Note: Structured Headers allows for escaped 0x22 (\") and 0x5C (\\) inside a string, but these are known to not be web-compatible.
To create an arbitrary version, return a string that MUST match the format of the user agent's significant version, but MUST NOT match the value.
Note: User Agents may decide to send arbitrarily low versions to ensure proper version checking, and should vary them over time.
4.1.4. Getters
On getting, the brands attribute MUST return this's relevant global object's brands frozen array.
On getting, the mobile attribute must return the user agent's mobileness.
On getting, the platform attribute must return the user agent's platform brand.
4.1.5. getHighEntropyValues method
The getHighEntropyValues(hints) method MUST run these steps:
-
Let p be a a new promise created in the current realm.
-
If the user agent decides one or more values in hints should not be returned, then reject and return p with a "
NotAllowedError".
We can improve upon when and why a UA decides to refuse a hint once Issue #151 is resolved.
-
Otherwise, run the following steps in parallel:
-
Let uaData be a new
UADataValues. -
set uaData["
brands"] to this's relevant global object's brands frozen array. -
set uaData["
mobile"] to the user agent's mobileness. -
set uaData["
platform"] to the user agent's platform brand. -
If hints contains "architecture", set uaData["
architecture"] to the user agent's platform architecture. -
If hints contains "bitness", set uaData["
bitness"] to the user agent's platform bitness. -
If hints contains "model", set uaData["
model"] to the user agent's model. -
If hints contains "platformVersion", set uaData["
platformVersion"] to the user agent's platform version. -
If hints contains "uaFullVersion", let uaData["
uaFullVersion"] be the the user agent’s full version. -
Queue a task on the permission task source to resolve p with uaData.
-
-
Return p.
5. Security and Privacy Considerations
5.1. Secure Transport
Client Hints will not be delivered to non-secure endpoints (see the secure transport requirements in Section 2.2.1 of [RFC8941]). This means that user agent information will not be leaked over plaintext channels, reducing the opportunity for network attackers to build a profile of a given agent’s behavior over time.
5.2. Delegation
Client Hints will be delegated from top-level pages via Permissions Policy. This reduces the likelihood that user agent information will be delivered along with subresource requests, which reduces the potential for passive fingerprinting.
That delegation is defined as part of append client hints to request.
5.3. Fingerprinting
The primary goal of User Agent Client Hints is to reduce the default entropy available to the network for passive fingerprinting. However, it will still be possible for some, or all, hints to be requested and used for active fingerprinting purposes by first or delegated third parties. As noted in § 5.4 Access Restrictions, User agents should consider policies to restrict or reduce access to parties that are known to actively fingerprint their users.
5.4. Access Restrictions
The information in the Client Hints defined above reveals quite a bit of information about the user agent and the device upon which it runs. User agents ought to exercise judgement before granting access to this information, and MAY impose restrictions above and beyond the secure transport and delegation requirements noted above. For instance, user agents could choose to reveal platform architecture or platform bitness only on requests it intends to download, giving the server the opportunity to serve the right binary. Likewise, they could offer users control over the values revealed to servers, or gate access on explicit user interaction via a permission prompt or via a settings interface.
6. Implementation Considerations
6.1. The 'User-Agent' Header
User agents SHOULD deprecate usage of the User-Agent header by reducing its information granularity
or removing the header entirely, in favor of the Client Hints model described in this document. The header,
however, is likely to be impossible to remove entirely in the near-term, as existing sites' content negotiation
code will continue to require its presence (see [Rossi2015] for a recent example of a new browser’s struggles
in this area).
One approach which might be advisable could be for each user agent to lock the value of its User-Agent header, ensuring backwards compatibility by maintaining the crufty declarations of
"like Gecko" and "AppleWebKit/537.36" on into eternity. This can ratchet over time, first freezing
the version number, then shifting platform and model information to something reasonably generic in
order to reduce the fingerprint the header provides.
6.2. GREASE-like UA Brand Lists
History has shown us that there are real incentives for user agents to lie about their branding in order to thread the needle of sites' sniffing scripts, and prevent their users from being blocked by UA-based allow/block lists.
Resetting expectations may help to prevent abuse of the brands list in the short term, but probably won’t help in the long run. The world of network protocols introduced the notion of GREASE [I-D.ietf-tls-grease]. We could borrow from that concept to tackle this problem.
User agents' brands containing more than a single entry could encourage standardized processing of the brands list. By randomly including additional, intentionally incorrect, comma-separated entries with arbitrary ordering, they would reduce the chance that we ossify on a few required strings.
Let’s examine a few examples:
-
In order to avoid sites from barring unknown browsers from their allow lists, Chrome could send a UA set that includes an non-existent browser, and which varies once in a while.
-
"Chrome"; v="73", "(Not;Browser"; v="12"
-
-
In order to enable equivalence classes based on Chromium versions, Chrome could add the rendering engine and its version to that.
-
"Chrome"; v="73", "(Not;Browser"; v="12", "Chromium"; v="73"
-
-
In order to encourage sites to rely on equivalence classes based on Chromium versions rather than exact UA sniffing, Chrome might remove itself from the set entirely.
-
"(Not;Browser"; v="12", Chromium"; v="73"
-
-
Browsers based on Chromium may use a similar UA string, but use their own brand as part of the set, enabling sites to count them.
-
"Chrome"; v="73", "Xwebs mega"; v="60", "Chromium"; v="73", "(Not;Browser"; v="12"
-
User agents MUST include more than a single value in brands, where one of these values is an arbitrary value.
The value order in brands MUST change over time to prevent receivers of the header from relying on certain values being in certain locations in the list.
When choosing GREASE strategies, user agents SHOULD keep caching variance and analytics use cases in mind and minimize variance among identical user agent versions.
Note: One approach to minimize variance for caching and analytics could be to determine the GREASE parts of the UA set at build time, and keep them identical throughout the lifetime of the user agent's significant version.
6.3. The 'Sec-CH-' prefix
Restricting user-land JavaScript code from influencing and modifying UA-CH headers has various security related advantages. At the same time, there don’t seem to be any legitimate use-cases which require such user-land rewriting.
As such and based on discussions with the TAG, it seems
reasonable to forbid write access to these headers from JavaScript (e.g. through fetch or Service
Workers), and demarcate them as browser-controlled client hints so they can be documented and
included in requests without triggering CORS preflights.
Therefore, request headers defined in this specification include a Sec-CH- prefix.
7. IANA Considerations
This document intends to define the Sec-CH-UA, Sec-CH-UA-Arch, Sec-CH-UA-Bitness, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform, and the Sec-CH-UA-Platform-Version HTTP request header fields, and register them in the permanent message
header field registry ([RFC3864]).
It also intends to deprecate usage of the User-Agent header field.
7.1. 'Sec-CH-UA' Header Field
Header field name: Sec-CH-UA
Applicable protocol: http
Status: standard
Author/Change controller: IETF
Specification document: this specification (§ 3.1 The 'Sec-CH-UA' Header Field)
7.2. 'Sec-CH-UA-Arch' Header Field
Header field name: Sec-CH-UA-Arch
Applicable protocol: http
Status: standard
Author/Change controller: IETF
Specification document: this specification (§ 3.2 The 'Sec-CH-UA-Arch' Header Field)
7.3. 'Sec-CH-UA-Bitness' Header Field
Header field name: Sec-CH-UA-Bitness
Applicable protocol: http
Status: standard
Author/Change controller: IETF
Specification document: this specification (§ 3.3 The 'Sec-CH-UA-Bitness' Header Field)
7.4. 'Sec-CH-UA-Full-Version' Header Field
Header field name: Sec-CH-UA-Full-Version
Applicable protocol: http
Status: standard
Author/Change controller: IETF
Specification document: this specification (§ 3.4 The 'Sec-CH-UA-Full-Version' Header Field)
7.5. 'Sec-CH-UA-Mobile' Header Field
Header field name: Sec-CH-UA-Mobile
Applicable protocol: http
Status: standard
Author/Change controller: IETF
Specification document: this specification (§ 3.5 The 'Sec-CH-UA-Mobile' Header Field)
7.6. 'Sec-CH-UA-Model' Header Field
Header field name: Sec-CH-UA-Model
Applicable protocol: http
Status: standard
Author/Change controller: IETF
Specification document: this specification (§ 3.6 The 'Sec-CH-UA-Model' Header Field)
7.7. 'Sec-CH-UA-Platform' Header Field
Header field name: Sec-CH-UA-Platform
Applicable protocol: http
Status: standard
Author/Change controller: IETF
Specification document: this specification (§ 3.7 The 'Sec-CH-UA-Platform' Header Field)
7.8. 'Sec-CH-UA-Platform-Version' Header Field
Header field name: Sec-CH-UA-Platform-Version
Applicable protocol: http
Status: standard
Author/Change controller: IETF
Specification document: this specification (§ 3.8 The 'Sec-CH-UA-Platform-Version' Header Field)
7.9. 'User-Agent' Header Field
Header field name: User-Agent
Applicable protocol: http
Status: deprecated
Author/Change controller: IETF
Specification document: this specification (§ 6.1 The 'User-Agent' Header), and Section 5.5.3 of [RFC7231]
8. Acknowledgments
Thanks to Aaron Tagliaboschi, ArkUmbra, jasonwee, Luke Williams, Mike West, and Toru Kobayashi for valuable feedback and contributions to this specification.