fix: restrict SSL certificate bypass to localhost only - #2204
Open
Marnie0415 wants to merge 1 commit into
Open
Conversation
Marnie0415
force-pushed
the
fix/global-cert-validation-bypass
branch
2 times, most recently
from
July 10, 2026 18:34
c8e4a85 to
729d98f
Compare
The previous implementation disabled certificate validation for ALL HTTP connections via \�adCertificateCallback = (_, _, _) => true\. This made every outbound request (subscription downloads, update checks, WebDAV sync) vulnerable to man-in-the-middle attacks. Certificate bypass is only needed for localhost connections where the local proxy may use self-signed certificates. External connections should use proper certificate validation.
Marnie0415
force-pushed
the
fix/global-cert-validation-bypass
branch
from
July 10, 2026 18:36
729d98f to
3a462e2
Compare
34 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
lib/common/http.dart:27disables SSL certificate validation for all HTTP connections:This affects subscription downloads, update checks, and WebDAV sync — all of which connect to external servers over HTTPS. An attacker on the same network can perform man-in-the-middle attacks to inject malicious proxy nodes, redirect updates, or steal credentials.
Why the bypass exists
The app routes external traffic through the local ClashMeta proxy via
handleFindProxy, which returnsPROXY localhost:$mixedPort. The proxy handles outbound TLS. The Flutter app only needs certificate bypass for local proxy connections, not external endpoints.Fix
Restrict
badCertificateCallbackto only bypass validation for local addresses:Why two checks
localhostisconst localhost = '127.0.0.1'(lib/common/constant.dart:55) — the IP address'localhost'is the hostname string — this is whathandleFindProxyreturns in the proxy URL (PROXY localhost:$mixedPort)When the HTTP client connects through the proxy, it uses the hostname from the proxy URL. Depending on DNS resolution and platform behavior, the
hostparameter in the callback may receive either'127.0.0.1'or'localhost'. Both must be handled.Scope
127.0.0.1(local proxy)localhosthostname (local proxy)IPv6
IPv6 (
::1) is not included because the codebase consistently uses IPv4 for local connections. Thelocalhostconstant,defaultExternalController, and proxy configuration all use127.0.0.1. If IPv6 support is added later, the callback can be extended.