Dev.to Security 🔐 Cybersecurity 👁 2 📖 3 min read

How to Detect Corporate TLS MITM & Distrusted CAs in Firefox vs Chrome MV3 (Why Chromium Hides Raw Cert Chains)

Yesterday someone asked a deceptively simple question on X: "I want a browser extension that warns me if the certificate on the site I'm visiting is from one of the bad authorities. Or if it changes. Or if I'm being MI

Yesterday someone asked a deceptively simple question on X:

"I want a browser extension that warns me if the certificate on the site I'm visiting is from one of the bad authorities. Or if it changes. Or if I'm being MITMed by my employer. The fact that we haven't made this easily visible is shameful."

They're completely right. Most browsers tuck TLS issuer details three clicks behind the lock/tune icon, so if an employer pushes a CorpProxy SSL Inspection Root CA (Zscaler, Netskope, Palo Alto, etc.) into your OS trust store, every single HTTPS site silently shows the same calm padlock while corporate middleboxes decrypt your sessions.

So I built CertWatch — an open interactive demo + downloadable browser extension bundle (Firefox + Chrome MV3 + zero-dependency Node.js loopback probe).

While building it, you immediately run head-first into one of the starkest security-API differences between Firefox and Chromium.

1. Firefox: True In-Browser TLS Chain Inspection (webRequest.getSecurityInfo)

Firefox is the only mainstream desktop browser that lets a WebExtension directly inspect the live TLS certificate chain during onHeadersReceived via browser.webRequest.getSecurityInfo():

browser.webRequest.onHeadersReceived.addListener(
  async (details) => {
    if (details.type !== "main_frame") return;

    const info = await browser.webRequest.getSecurityInfo(details.requestId, {
      certificateChain: true,
    });

    if (!info || info.state !== "secure" || !info.certificates?.length) return;

    const leaf = info.certificates[0];
    const root = info.certificates[info.certificates.length - 1];

    // 1. Enterprise MITM detection: non-built-in root installed in OS trust store
    const isEnterpriseMitm = root.isBuiltInRoot === false;

    // 2. Watchlist match (Zscaler, Netskope, CorpProxy, WoSign, CNNIC, etc.)
    const issuerChainText = info.certificates
      .map((c) => `${c.subject} ${c.issuer}`)
      .join(" ");

    // 3. First-seen SHA-256 fingerprint pin ledger per hostname
    const fingerprint = leaf.fingerprint.sha256;
    await evaluateAndAlert(details.tabId, new URL(details.url).hostname, {
      isEnterpriseMitm,
      issuerChainText,
      fingerprint,
    });
  },
  { urls: ["<all_urls>"] },
  ["blocking"]
);

Notice root.isBuiltInRoot === false! That single boolean instantly distinguishes a public Mozilla-trusted root CA from a locally injected enterprise MITM root certificate — 100% locally inside the browser with zero external requests.

2. Chrome Manifest V3: Why Chromium Extensions Can't Read Raw TLS Certs Directly

In Chrome/Edge/Brave Manifest V3, there is no equivalent to webRequest.getSecurityInfo(). Extensions cannot read leaf.fingerprint.sha256, the intermediate chain, or isBuiltInRoot from a browser tab's live TLS handshake.

Whenever a Chrome extension claims to do "pure JS SSL certificate inspection" without a companion binary or external API, check the source — it's either calling a remote third-party server (which defeats corporate MITM detection, because a remote server doesn't sit behind your corporate proxy!) or guessing from headers.

The Honest Architecture for Chrome MV3

To keep verification 100% local on the user's machine so corporate proxies are actually caught from the user's network vantage point, CertWatch pairs the Chrome MV3 extension (chrome.storage.local pin ledger + CA watchlist) with a tiny zero-dependency Node.js (>=18) loopback probe bound strictly to 127.0.0.1:47189:

import tls from "node:tls";

function inspectHostTls(hostname, port = 443) {
  return new Promise((resolve, reject) => {
    const socket = tls.connect(
      { host: hostname, port, servername: hostname, rejectUnauthorized: false },
      () => {
        const cert = socket.getPeerCertificate(true);
        const chain = [];
        let cursor = cert;
        const seen = new Set();
        while (cursor && cursor.fingerprint256 && !seen.has(cursor.fingerprint256)) {
          seen.add(cursor.fingerprint256);
          chain.push({
            subject: cursor.subject?.CN || cursor.subject?.O || "Unknown",
            issuer: cursor.issuer?.CN || cursor.issuer?.O || "Unknown",
            fingerprint256: cursor.fingerprint256,
            validTo: cursor.valid_to,
          });
          cursor = cursor.issuerCertificate;
        }
        socket.end();
        resolve({ authorized: socket.authorized, chain });
      }
    );
    socket.on("error", reject);
  });
}

Because the probe opens the TLS socket directly from your own workstation, any transparent TLS inspection proxy on your network intercepts it too — exposing the proxy's root CA and SHA-256 mismatch immediately against your pinned baseline.

3. Try the Interactive Simulation + Download the Full Extension ZIP

You can test all 4 scenarios (github.com verified pin, mail.company-portal.io corporate MITM alert, bank-example.com sudden issuer change to a watchlisted CA, and docs.signal.org pinned cert), add your own CA watchlist rules, and download the complete Firefox + Chrome MV3 + local probe ZIP free here:

If you also run self-hosted endpoints and want 30-day uptime bars + SSL expiry countdown alerts (14d warning badges) in a lightweight CLI, check out PingPulse.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.