Repository navigation
v4: Verify upstream TLS certificates when retrieving Manager notices - #3405
Closed
StevenLi-phoenix wants to merge 1 commit into
Closed
StevenLi-phoenix wants to merge 1 commit into
StevenLi-phoenix wants to merge 1 commit into
Conversation
The legacy /v2/manager/notice handler fetched the GitHub wiki News page with certificate verification turned off, so anyone able to intercept the connection could supply notice text and links. Follow the bypass_ssl setting like manager_util.get_data does, and return the existing "Unable to retrieve Notice" response on connection, certificate or timeout errors instead of an HTTP 500. Refs Comfy-Org#3302 Co-authored-by: Claude Opus-5-5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
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.
Refs #3302
This is the v4 (
manager-v4) half. The v3 handler onmaingets the same fix in #3404.Problem
The legacy
GET /v2/manager/noticehandler downloads the GitHub wiki News page and shows its text and links in the legacy Manager dialog. It built its connector withaiohttp.TCPConnector(verify_ssl=False). Certificate verification was therefore off for every user, whatever thebypass_sslsetting said. Anyone who can intercept the connection can present any certificate for github.com and choose the notice text and links. The sanitizer from #3297 limits the markup, but it cannot authenticate the content.Also, a connection error made the handler raise, so the notice area showed aiohttp's "500 Internal Server Error" page text.
Fix
TCPConnector(verify_ssl=not manager_util.bypass_ssl). This is the expressioncommon/manager_util.get_dataalready uses. Verification is on by default.bypass_ssl = Trueinconfig.inistill turns it off.trust_env=Trueis unchanged, soHTTP(S)_PROXYandSSL_CERT_FILEkeep working.aiohttp.ClientErrorandasyncio.TimeoutErroraround the request. The handler logs a warning with the cause and returns the existingUnable to retrieve Noticeresponse (status 200), the same response it already gives for a non-200 reply.I used
verify_ssl=instead ofssl=on purpose. On aiohttp 3.8.x,TCPConnector(ssl=True)gives an unverified context. I checked this with the new test: withssl=not manager_util.bypass_ssl, the untrusted-certificate case fails on aiohttp 3.8.6 and passes on 3.14.verify_ssl=Trueverifies on every 3.x release and gives no deprecation warning.Most of the diff is re-indentation for the new
try:. Withgit diff -wthe handler change is 5 lines.Behavior change
Users behind a TLS-intercepting proxy whose CA is not trusted now see
Unable to retrieve Noticeinstead of the notice. They get it back by trusting the proxy's CA (for example throughSSL_CERT_FILE) or by settingbypass_ssl = True. Manager's other fetches throughget_dataalready behave this way.Scope
comfyui_manager/glob/share_3rdparty.pyandcomfyui_manager/legacy/share_3rdparty.pystill build their connectors withTCPConnector(verify_ssl=False)(4 call sites each). I left them alone on purpose, because #3302 covers notice retrieval only. They could be a follow-up.Tests
tests/test_notice_tls.py. Each case runs the real legacyget_noticein a child process, loaded throughlegacy_html_testutil.load_functions. The child setsHTTPS_PROXYto a local CONNECT proxy. The proxy forwards the tunnel to a local HTTPS server that presents agithub.comcertificate from a throwaway CA made with theopensslCLI. The cases are: an untrusted certificate is rejected, a CA trusted throughSSL_CERT_FILEis accepted,bypass_ssl = Truestill accepts the certificate, and an unreachable upstream returnsUnable to retrieve Notice. All traffic stays on 127.0.0.1. The module is skipped if there is noopensslCLI.tests/test_notice_html_sanitizer.py: the stub namespace now providesmanager_util, because the handler readsmanager_util.bypass_ssl.Before the fix:
After the fix:
The 3 failures are
tests/common/test_git_helper.py::test_single_collision,test_multi_collisionandtest_uuid_fallback_on_full_collision. They fail the same way onmanager-v4without this change, and they do not touch the notice code.Other checks: the new tests also pass on Python 3.10 with aiohttp 3.8.6, and with the LibreSSL 3.3.6
opensslthat ships with macOS. I did not run the e2e or Playwright suites, which need a prepared ComfyUI environment.