Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function maybeDetectPhishing(theController) {

// Determine the block reason based on the type
let blockReason;
let blockedUrl = hostname;
let blockedUrl = href;
if (phishingTestResponse?.result && blockedRequestResponse.result) {
blockReason = `${phishingTestResponse.type} and ${blockedRequestResponse.type}`;
} else if (phishingTestResponse?.result) {
Expand All @@ -354,16 +354,18 @@ function maybeDetectPhishing(theController) {
blockedUrl = details.initiator;
}

const blockedHostname = new URL(blockedUrl).hostname;
Copy link

Choose a reason for hiding this comment

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

Bug: Phishing Detection Crashes on Invalid URL

The new URL(blockedUrl) constructor can throw a TypeError because blockedUrl might be null, undefined, or the string "null". This happens when blockedUrl is set from details.initiator (e.g., for opaque origins), causing the phishing detection logic to crash instead of processing the blocked request.

Fix in Cursor Fix in Web


if (!isFirefox) {
theController.metaMetricsController.trackEvent(
{
// should we differentiate between background redirection and content script redirection?
event: MetaMetricsEventName.PhishingPageDisplayed,
category: MetaMetricsEventCategory.Phishing,
properties: {
url: blockedUrl,
url: blockedHostname,
referrer: {
url: blockedUrl,
url: blockedHostname,
},
reason: blockReason,
requestDomain: blockedRequestResponse.result
Expand All @@ -376,7 +378,10 @@ function maybeDetectPhishing(theController) {
},
);
}
const querystring = new URLSearchParams({ hostname, href });
const querystring = new URLSearchParams({
hostname: blockedHostname, // used for creating the EPD issue title (false positive report)
href: blockedUrl, // used for displaying the URL on the phsihing warning page + proceed anyway URL
});
const redirectUrl = new URL(phishingPageHref);
redirectUrl.hash = querystring.toString();
const redirectHref = redirectUrl.toString();
Expand Down
Loading