fix(security): replace global TLS bypass with scoped certificate-error handler - #369
khawarahemad wants to merge 1 commit into
Conversation
|
I'll review this PR later, it's already quite late over here 🥲 |
There was a problem hiding this comment.
🟡 Changes recommended
The new certificate-error allowlist currently permits invalid certificates for a public domain (discord.com via Constants.CustomDiscordDomain), which materially weakens the intended TLS security posture if host mapping is bypassed or changes later.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR removes a process-wide Chromium TLS bypass (ignore-certificate-errors) and replaces it with a scoped Electron app.on("certificate-error") handler intended to only trust local/self-signed endpoints, reducing MITM exposure for external HTTPS traffic.
Changes:
- Removed the global
ignore-certificate-errorsChromium switch and introduced acertificate-errorevent handler to selectively allow specific hostnames. - Adjusted Express request type augmentation to use
declare global { namespace Express { ... } }. - Made Vencord extension loading resilient by checking for existence and handling load failures with logging.
File summaries
| File | Description |
|---|---|
| src/overrides.d.ts | Updates Express Request type augmentation approach while preserving custom fields. |
| src/AppCore/index.ts | Replaces global TLS bypass with a certificate-error handler and hardens extension loading behavior/logging. |
Review details
- Files reviewed: 1/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if ( | ||
| hostname === Constants.CustomDiscordDomain || | ||
| hostname === "localhost" || | ||
| hostname === "127.0.0.1" | ||
| ) { |
| event.preventDefault(); | ||
| return callback(true); | ||
| } | ||
| } catch {} |
|
Thanks for the review feedback. I investigated the certificate handling further and found an important detail.
The current That means the hostname-only check is broader than intended if the host mapping is ever bypassed or does not apply to a particular request. The local HTTPS server certificate is generated at runtime by I haven't changed the PR yet because I wanted to confirm the intended certificate trust model with you first. |
Summary
This PR removes the process-global Chromium switch
ignore-certificate-errorsand replaces it with a scopedapp.on("certificate-error")handler.Impact
The
--ignore-certificate-errorscommand-line switch disabled TLS certificate validation globally across all Chromium network requests. Any external HTTPS traffic (such as CDN scripts loaded in the Monaco Config Editor) was vulnerable to network transit interception (MITM).Root Cause
app.commandLine.appendSwitch("ignore-certificate-errors")applied universally to all network connections instead of being restricted to localhost self-signed certificates.Fix
Removed the global command-line flag and implemented
app.on("certificate-error")insideapp.whenReady(). The handler explicitly verifies that the requested URL's hostname matchesConstants.CustomDiscordDomain,localhost, or127.0.0.1before trusting the certificate, preserving standard PKI validation for all external remote domains.Validation
npm run test:typescriptandnpm run build:ts.