Skip to content

Bug 2039258 - Send security event in case of unsafe site visit#1116

Draft
mz-darnold wants to merge 22 commits into
mozilla:enterprise-mainfrom
mz-darnold:bug-2039258
Draft

Bug 2039258 - Send security event in case of unsafe site visit#1116
mz-darnold wants to merge 22 commits into
mozilla:enterprise-mainfrom
mz-darnold:bug-2039258

Conversation

@mz-darnold

@mz-darnold mz-darnold commented Jul 7, 2026

Copy link
Copy Markdown

Description

Bugzilla: Bug-2039258

Send telemetry when a user visits a URL identified as malicious by Google Safe Browsing. Also applies to unsafe downloads.


Testing

  • Added tests
  • Manual testing performed

Steps to verify changes:

  1. Visit https://testsafebrowsing.appspot.com/
  2. Click links
  3. Confirm unsafe browsing telemetry in console

Copilot AI review requested due to automatic review settings July 7, 2026 13:40
@firefoxci-taskcluster

Copy link
Copy Markdown
No Taskcluster jobs started for this pull request

The allowPullRequests configuration for this repository (in .taskcluster.yml on the default branch) does not allow starting tasks for this pull request.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds enterprise-only telemetry for Safe Browsing “unsafe site” hits, recording a new Glean event and submitting it via the enterprise ping when users land on blocked top-level threat pages in MOZ_ENTERPRISE builds.

Changes:

  • Add a new Glean event metric (security.unsafe_site_visit) gated to MOZ_ENTERPRISE and sent in the enterprise ping.
  • Emit a new actor message from the blocked-site error page (child actor) and record/submit the telemetry in the parent actor.
  • Add an enterprise-only browser-chrome test validating event recording and URL logging policy behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
browser/components/safebrowsing/content/test/browser.toml Registers the new enterprise-only browser-chrome test.
browser/components/safebrowsing/content/test/browser_enterprise_unsafe_site_telemetry.js Adds coverage for unsafe-site event recording and URL logging policy modes.
browser/actors/metrics.yaml Defines the new enterprise-only security.unsafe_site_visit Glean event and its extra keys.
browser/actors/BlockedSiteParent.sys.mjs Records the event and submits the enterprise ping when notified of an unsafe-site visit.
browser/actors/BlockedSiteChild.sys.mjs Detects top-level unsafe-site hits and notifies the parent actor with threat details.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jonathanmendez jonathanmendez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks structurally good overall, but there are a few things to follow up on.

Comment thread browser/actors/BlockedSiteChild.sys.mjs Outdated

// Safe Browsing threat types that represent an unsafe site visit. Note that
// "addon" (addonBlocked) is intentionally excluded as it is not a site threat.
const UNSAFE_SITE_THREAT_TYPES = new Set([

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the bug is requesting a security event "in case of unsafe site visit", it's not clear to me why we would only care about a subset of unsafe site threats instead of reporting them all. I don't think we want to filter the threat type at all, unless that has been requested at the Product level (i.e. by @bsmth )

Comment thread browser/actors/BlockedSiteChild.sys.mjs Outdated
if (
!Services.prefs.getBoolPref(
"browser.safebrowsing.enterprise.telemetry.unsafeSiteVisit.enabled",
true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches what we have elsewhere, but I think we should use false for the default value, i.e. only send these events if the policy to do so has been set (and we should fix the other uses). Probably worth double-checking with @gcp in case we want to default to true for some reason.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what the default is for the others but it should at least be consistent.

Comment thread browser/actors/metrics.yaml Outdated
Comment thread browser/actors/metrics.yaml Outdated
Comment thread browser/actors/BlockedSiteParent.sys.mjs Outdated
@mz-darnold mz-darnold changed the title Bug 2039258 Bug 2039258 - Send security event in case of unsafe site visit Jul 7, 2026
Copilot AI review requested due to automatic review settings July 8, 2026 11:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread browser/actors/BlockedSiteChild.sys.mjs Outdated
Comment on lines +61 to +65
if (
AppConstants.MOZ_ENTERPRISE &&
this.browsingContext === this.browsingContext.top &&
UNSAFE_SITE_THREAT_TYPES.has(aEvent.detail.err)
) {
Copilot AI review requested due to automatic review settings July 12, 2026 16:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 12, 2026 17:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread netwerk/url-classifier/nsChannelClassifier.cpp Outdated
Comment thread netwerk/url-classifier/nsChannelClassifier.cpp Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 14:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread toolkit/components/reputationservice/metrics.yaml
Copilot AI review requested due to automatic review settings July 13, 2026 15:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 15, 2026 15:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment on lines +439 to +444
if (nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel)) {
if (nsCOMPtr<nsIReferrerInfo> referrerInfo =
httpChannel->GetReferrerInfo()) {
referrerUri = referrerInfo->GetOriginalReferrer();
}
}
Comment on lines +55 to +57
void MaybeSubmitEnterprisePing() {
MOZ_ASSERT(NS_IsMainThread());

Copilot AI review requested due to automatic review settings July 20, 2026 09:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 20, 2026 10:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread toolkit/components/reputationservice/test/unit/xpcshell.toml
Copilot AI review requested due to automatic review settings July 20, 2026 11:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 20, 2026 11:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 20, 2026 12:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread toolkit/components/url-classifier/metrics.yaml
Comment thread toolkit/components/reputationservice/metrics.yaml
Copilot AI review requested due to automatic review settings July 20, 2026 12:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants