-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add websocket support for c2 detection #28782
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Builds ready [60a3ac7]
Page Load Metrics (1763 ± 94 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
@@ -327,7 +327,7 @@ function maybeDetectPhishing(theController) { | |||
return {}; | |||
}, | |||
{ | |||
urls: ['http://*/*', 'https://*/*'], | |||
urls: ['http://*/*', 'https://*/*', 'ws://*/*', 'wss://*/*'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change needs automated tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a few tests!
Builds ready [d2c7f78]
Page Load Metrics (1614 ± 53 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Excited for this to land in prod! |
test/e2e/tests/phishing-controller/mock-malicious-websocket-connection/index.html
Fixed
Show fixed
Hide fixed
test/e2e/tests/phishing-controller/mock-safe-websocket-connection/index.html
Fixed
Show fixed
Hide fixed
…metamask-extension into feat/websocket-support
…metamask-extension into feat/websocket-support
Builds ready [395bf8c]
Page Load Metrics (1896 ± 90 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [dabc7a8]
Page Load Metrics (1974 ± 52 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
@@ -72,5 +72,6 @@ | |||
"unresponsive-rpc.test", | |||
"unresponsive-rpc.url", | |||
"user-storage.api.cx.metamask.io", | |||
"www.4byte.directory" | |||
"www.4byte.directory", | |||
"verify.walletconnect.com" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Builds ready [d64c13c]
Page Load Metrics (2032 ± 127 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [fe74a38]
Page Load Metrics (1923 ± 72 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [28c26bf]
Page Load Metrics (1572 ± 29 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Tested with the e2e tests locally, and it appears to work well. I also double-checked that the manifest file changes didn't introduce new warnings, and they do not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've confirmed that this new code intercepts wss
requests and redirects the user to the phishing page. However, the Proceed anyway
link on the phishing page now redirects the user to the websocket URL.
Not sure what the "fix" is here, but it is something we should figure out how to handle better.
Description
This pull request adds WebSocket support to the MetaMask extension's phishing detection functionality. Scammers have started using WebSocket connections for command-and-control (C2) operations to bypass traditional HTTP-based phishing detection. This PR allows the extension to intercept and block WebSocket handshake requests (
ws://
andwss://
) in addition to HTTP/HTTPS requests.The key changes include:
ws://*/*
andwss://*/*
) to theurls
filter inbackground.js
.manifest.json
to include WebSocket permissions in thehost_permissions
field.This ensures that malicious WebSocket connections can be detected and blocked.
Related issues
Fixes: https://github.com/MetaMask/MetaMask-planning/issues/3788
Manual testing steps
example.com
wss://example.com
) and verify it works as expected by going to theconsole
via right clicking and hitting inspect. Then type into the consolenew WebSocket("https://example.com/")
console
via right clicking and hitting inspect. Then type into the consolenew WebSocket("https://walietconnectapi.com/")
Screenshots/Recordings
Before
No support for detecting WebSocket phishing connections.
After
WebSocket phishing connections are detected and blocked during the handshake phase.
Pre-merge author checklist
Pre-merge reviewer checklist