Bug 1874684 - Part 28: Return DateDuration from DifferenceISODateTime. r=mgaudet
[gecko.git] / remote / doc / Security.md
blob848a63fd452245d0c105b20e122cbb2e6be3b5e8
1 # Security aspects of the Remote Agent
3 The Remote Agent is not a web-facing feature and as such has different
4 security characteristics than traditional web platform APIs.  The
5 primary consumers are out-of-process programs that connect to the
6 agent via a remote protocol, but can theoretically be extended to
7 facilitate browser-local clients communicating over IPDL.
9 ## Design considerations
11 The Remote Agent allows consumers to interface with Firefox through
12 an assorted set of domains for inspecting the state and controlling
13 execution of documents running in web content, injecting arbitrary
14 scripts to documents, do browser service instrumentation, simulation
15 of user interaction for automation purposes, and for subscribing
16 to updates in the browser such as network- and console logs.
18 The remote interfaces are served over an HTTP wire protocol, by a
19 server listener hosted in the Firefox binary.  This can only be
20 started by passing the `--remote-debugging-port`
21 flag.  Connections are restricted to loopback devices
22 (such as localhost and 127.0.0.1).
24 Since the Remote Agent is not an in-document web feature, the
25 security concerns we have for this feature are essentially different
26 to other web platform features.  The primary concern is that the
27 HTTPD is not spun up without passing one of the command-line flags.
28 It is out perception that if a malicious user has the capability
29 to execute arbitrary shell commands, there is little we can do to
30 prevent the browser being turned into an evil listening device.
32 ## User privacy concerns
34 There are no user privacy concerns beyond the fact that the offered
35 interfaces will give the client access to all browser internals,
36 and thereby follows all browser-internal secrets.
38 ## How the Remote Agent works
40 When the `--remote-debugging-port` flag is used,
41 it spins up an HTTPD on the desired port, or defaults to
42 localhost:9222.  The HTTPD serves WebSocket connections via
43 `nsIWebSocket.createServerWebSocket` that clients connect to in
44 order to give the agent remote instructions. Hereby the HTTPD only
45 accepts system-local loopback connections from clients:
47 ```javascript
48 if (!LOOPBACKS.includes(host)) {
49   throw new Error("Restricted to loopback devices");
51 ```
53 The Remote Agent implements a large subset of the Chrome DevTools
54 Protocol (CDP).  This protocol allows a client to:
56 * take control over the user session for automation purposes, for
57   example to simulate user interaction such as clicking and typing;
59 * instrument the browser for analytical reasons, such as intercepting
60   network traffic;
62 * and extract information from the user session, including cookies
63   and local storage.
65 There are no web-exposed features in the Remote Agent whatsoever.
67 ## Security model
69 It shares the same security model as DevTools and Marionette, in
70 that there is no other mechanism for enabling the Remote Agent than
71 by passing a command-line flag.
73 It is our assumption that if an attacker has shell access to the
74 user account, there is little we can do to prevent secrets from
75 being accessed or leaked.
77 The Remote Agent is available on all release channels.
79 ## Remote Hosts and Origins
81 By default RemoteAgent only accepts connections with no `Origin` header and a
82 `Host` header set to an IP address or a localhost loopback address.
84 Other `Host` or `Origin` headers can be allowed by starting Firefox with the
85 `--remote-allow-origins` and `--remote-allow-hosts` arguments:
87 * `--remote-allow-hosts` expects a comma separated list of hostnames
89 * `--remote-allow-origins` expects a comma separated list of origins
91 Note: Users are strongly discouraged from using the Remote Agent in a way that
92 allows it to be accessed by untrusted hosts e.g. by binding it to a publicly
93 routeable interface.
95 The Remote Agent does not provide message encryption, which means that all
96 protocol messages are subject to eavesdropping and tampering. It also does not
97 provide any authentication system. This is acceptable in an isolated test
98 environment, but not to be used on an untrusted network such as the internet.
99 People wishing to provide remote access to Firefox sessions via the Remote Agent
100 must provide their own encryption, authentication, and authorization.
102 ## Security reviews
104 More details can be found in the security reviews conducted for Remote Agent and
105 WebDriver BiDi:
107 * [Remote Agent security review] (November 2019)
109 * [WebDriver BiDi security review] (April 2022)
111 [Remote Agent security review]: https://bugzilla.mozilla.org/show_bug.cgi?id=1542229
112 [WebDriver BiDi security review]: https://bugzilla.mozilla.org/show_bug.cgi?id=1753997