File: safe_browsing.mojom

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (284 lines) | stat: -rw-r--r-- 11,884 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module safe_browsing.mojom;

import "components/safe_browsing/core/common/safe_browsing_url_checker.mojom";
import "mojo/public/mojom/base/file.mojom";
import "mojo/public/mojom/base/proto_wrapper.mojom";
import "mojo/public/mojom/base/shared_memory.mojom";
import "services/network/public/mojom/http_request_headers.mojom";
import "third_party/blink/public/mojom/tokens/tokens.mojom";
import "url/mojom/url.mojom";

// Provided by the browser and used by renderers to perform SafeBrowsing URL
// checks.
interface SafeBrowsing {
  // Queries SafeBrowsing whether |url| is safe to load, and creates a
  // SafeBrowsingUrlChecker interface.
  //
  // The check and (subsequent checks performed using SafeBrowsingUrlChecker)
  // checks against SafeBrowsing's Malware, Phishing, and UwS blocklists.
  //
  // `frame_token` is set when the request originates from the context of a
  // frame. Dedicated workers are associated with a frame context and will
  // have the value set. Service workers and shared workers are not associated
  // with a frame and will have it set to null.
  //
  // The SafeBrowsingUrlChecker interface should be used (and only used) for
  // subsequent checks of redirects, so that the server side could keep track of
  // the redirect chain. Disconnecting the checker interface cancels on-going
  // URL checks. Please note that in that case if the check started by this
  // method hasn't completed yet, it will also be canceled and the callback is
  // ran with |proceed == true| and |showed_interstitial == false| as if the URL
  // is safe.
  //
  // |proceed| indicates whether it is okay to proceed with loading the URL.
  // |showed_interstitial| indicates whether the SafeBrowsing interstitial page
  // has been shown to the user.
  CreateCheckerAndCheck(blink.mojom.LocalFrameToken? frame_token,
                        pending_receiver<SafeBrowsingUrlChecker> receiver,
                        url.mojom.Url url,
                        string method,
                        network.mojom.HttpRequestHeaders headers,
                        int32 load_flags,
                        bool has_user_gesture,
                        bool originated_from_service_worker)
      => (bool proceed, bool showed_interstitial);

  // Bind an additional pipe to this instance of the SafeBrowsing interface.
  Clone(pending_receiver<SafeBrowsing> receiver);
};

// Used to store the name and value of an HTML Element's attribute.
struct AttributeNameValue {
  string name;
  string value;
};

// A node is essentially a frame.
struct ThreatDOMDetailsNode {
  // A unique ID for this node, unique to the current Render Frame.
  int32 node_id;
  // URL of this resource. Can be empty.
  url.mojom.Url url;
  // If this resource was in the "src" attribute of a tag, this is the tagname
  // (eg "IFRAME"). Can be empty.
  string tag_name;
  // URL of the parent node. Can be empty.
  url.mojom.Url parent;
  // The unique ID of the parent node. Can be 0 if this is the top node.
  int32 parent_node_id;
  // Children of this node. Can be empty.
  array<url.mojom.Url> children;
  // The unique IDs of the child nodes. Can be empty if there are no children.
  array<int32> child_node_ids;
  // The node's attributes as a collection of name-value pairs.
  array<AttributeNameValue> attributes;
  // If this node represents a frame or iframe, then this field is set to the
  // FrameToken of the local or remote frame in this renderer process that is
  // responsible for rendering the contents of this frame (to handle OOPIFs).
  blink.mojom.FrameToken? child_frame_token;
  // This field holds inline JavaScript content and remotely hosted scripts.
  string inner_html;
};

interface ThreatReporter {
  // Client-side detection message sent from the browser to the renderer.
  // Request a DOM tree when a safe browsing interstitial is shown.
  // Renderer returns part of the DOM to be used in a threat report.
  GetThreatDOMDetails() => (array<ThreatDOMDetailsNode> nodes);
};

// Enum representing possible outcomes of the renderer-side classification.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum PhishingDetectorResult {
  // The feature collection succeeded.
  SUCCESS = 0,

  // The classifier either did not exist, or was not ready.
  CLASSIFIER_NOT_READY = 1,

  // Another classification was requesting, cancelling this one.
  CANCELLED = 2,

  // The last recorded transition was a forward/back in history. Since the
  // classifier previously ran on this URL, it did not run again.
  FORWARD_BACK_TRANSITION = 3,

  // The classifier returned an invalid score because the model is
  // misconfigured.
  INVALID_SCORE = 4,

  // Invalid URL request came in that is not HTTP/HTTPS or GET requests.
  INVALID_URL_FORMAT_REQUEST = 5,

  // WebDocumentLoader failed to load.
  INVALID_DOCUMENT_LOADER = 6,

  // URL feature extraction has failed.
  URL_FEATURE_EXTRACTION_FAILED = 7,

  // DOM feature extraction failed.
  DOM_EXTRACTION_FAILED = 8,

  // Term feature extraction failed.
  TERM_EXTRACTION_FAILED = 9,

  // Visual extraction failed.
  VISUAL_EXTRACTION_FAILED = 10,
};

enum ClientSideDetectionType {
  // Send a CSD request regardless of the client side model's score values.
  kForceRequest,
  // Either the local DOM or visual model triggered.
  kTriggerModels,
  // A Notification prompt triggered.
  kNotificationPermissionPrompt,
  // Keyboard lock request triggered.
  kKeyboardLock,
  // Pointer lock request triggered.
  kPointerLock,
  // Vibration API request triggered.
  kVibrationApi,
  // Fullscreen API request triggered.
  kFullscreen,
  // Password protection request triggered.
  kPasswordProtection,
};

// Interface for starting phishing classification. This is scoped to a
// particular RenderFrame.
[EnableIf=full_safe_browsing]
interface PhishingDetector {
  // Tells the renderer to begin phishing detection for the given toplevel URL
  // which it has started loading. Returns the serialized request proto and a
  // `result` enum to indicate failure. If the URL is phishing the `request`
  // ClientPhishingRequest will have `is_phishing()` set to true. The
  // `request_type` correlates to the phishing detection request type from the
  // browser process and is only used for logging on the renderer.
  StartPhishingDetection(
    url.mojom.Url url, ClientSideDetectionType request_type)
      => (PhishingDetectorResult result,
          mojo_base.mojom.ProtoWrapper? request);
};

// Interface for setting a phishing model. This is scoped to an entire
// RenderProcess.
[EnableIf=full_safe_browsing]
interface PhishingModelSetter {
  // A classification model for client-side phishing detection in addition to
  // the image embedding model. This call sends the model and the image
  // embedding model from browser process to the renderer process. The image
  // embedding model is converted from a TfLite file to a string in the browser
  // process to be used to create an ImageEmbedder in the renderer process. This
  // function call should only be called for Enhanced Safe Browsing enabled
  // users who will allow the ImageEmbedding output as part of the CSD-Phishing
  // ping to be sent to CSPP for better model training. All else is the same as
  // the SetPhishingFlatBufferModel function.
  SetImageEmbeddingAndPhishingFlatBufferModel(
      mojo_base.mojom.ReadOnlySharedMemoryRegion region,
      mojo_base.mojom.ReadOnlyFile? tflite_model,
      mojo_base.mojom.ReadOnlyFile? image_embedding_model);

  // The image embedding model is a complementary model that is used with the
  // classification process, and this function will attach the model to an
  // already existing model object in the renderer process if the versions
  // match.
  AttachImageEmbeddingModel(
      mojo_base.mojom.ReadOnlyFile? image_embedding_model);

  // A classification model for client-side phishing detection. This call sends
  // the model from the browser process to the renderer process. The model is
  // sent as a safe_browsing::ClientSideModel flatbuffer string in a
  // ReadOnlySharedMemoryRegion to client-side phishing detection on the
  // renderer process. An invalid region is used to disable classification. The
  // |tflite_model| is a file handle with contents a TfLite model, which is used
  // to classify the appearance of pages.
  SetPhishingFlatBufferModel(
      mojo_base.mojom.ReadOnlySharedMemoryRegion region,
      mojo_base.mojom.ReadOnlyFile? tflite_model);

  // When OptimizationGuide server sends a null model, this signals there is a
  // bad model on disk. Calling this function clears the current Scorer object
  // in the renderer so that classification isn't used with the bad model.
  ClearScorer();

  // This is used in tests to ensure that the model has been set before sending
  // IPCs to start classification.
  SetTestObserver(pending_remote<PhishingModelSetterTestObserver>? observer)
      => ();
};

// This is used in tests to ensure that the model has been set before sending
// IPCs to start classification.
interface PhishingModelSetterTestObserver {
  // Called whenever the phishing model has changed.
  PhishingModelUpdated();
};

// Enum representing possible outcomes of the renderer-side image embedding
// process. These values are persisted to logs. Entries should not be renumbered
// and numeric values should never be reused.
enum PhishingImageEmbeddingResult {
  // The feature collection succeeded.
  kSuccess,
  // The image embedder either did not exist, or was not ready.
  kImageEmbedderNotReady,
  // Another image embedding was requesting, cancelling this one.
  kCancelled,
  // last recorded transition was a forward/back in history. Since the
  // image embedder previously ran on this URL, it did not run again.
  kForwardBackTransition,
  // the image embedder process failed
  kFailed,
};

// Interface for starting image embedding. This is scoped to a
// particular RenderFrame.
[EnableIf=full_safe_browsing]
interface PhishingImageEmbedderDetector {
  // Tells the renderer to begin image embedding. This should only happen if the
  // user is subscribed to ESB, and the verdict is phishy or LLAMA force trigger
  // the CSPP ping. The return objects are Image Embedding process result and a
  // ImageFeatureEmbedding object declared in csd.proto
  StartImageEmbedding(url.mojom.Url url)
      => (PhishingImageEmbeddingResult result,
          mojo_base.mojom.ProtoWrapper? image_embedding_request);
};

// Enum representing protocol type of a web request.
enum WebRequestProtocolType {
  kHttpHttps = 0,
  kWebSocket = 1,
};

// Enum representing contact initiator type of an extension web request.
enum WebRequestContactInitiatorType {
  kExtension = 0,
  kContentScript = 1,
};

// Interface to send extension web request data from the renderer to the
// browser.
interface ExtensionWebRequestReporter {
  // Send the url contacted and connect protocol type from an extension web
  // request.
  //
  // |origin_extension_id| is the id of the extension that initiated the web
  // request. Only safe to use for telemetry purposes. Untrustworthy to use
  // otherwise.
  // |telemetry_url| indictates the host contacted. Only safe to use for
  // telemetry purposes. Untrustworthy to use otherwise.
  SendWebRequestData(string origin_extension_id,
                     url.mojom.Url telemetry_url,
                     WebRequestProtocolType protocol_type,
                     WebRequestContactInitiatorType contact_initiator_type);

  // Bind an additional pipe to this instance of the ExtensionWebRequestReporter
  // interface.
  Clone(pending_receiver<ExtensionWebRequestReporter> receiver);
};