Skip to content

Pit toggle: trust each pit name's certificate on first https use, against the registry pin - #104

Merged
ralyodio merged 1 commit into
mainfrom
feat/pit-https-trust
Sep 16, 2026
Merged

ralyodio merged 1 commit into
mainfrom
feat/pit-https-trust

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

What

https://chovy.hacker/ on the 🤘 Pit route showed an invalid certificate. The pit resolver connects to the real origin, which serves a self-signed leaf for its own name (no public CA issues outside the ICANN root), and nothing had told the browser to trust it. moshcode dns trust <name> solves this for the system store, with root. This PR does the no-root equivalent for the browser, automatically, per name.

How

On the first HTTPS CONNECT for a pit name, before replying to the browser, the helper:

  1. fetches the certificate the origin serves for that SNI (unverified: deciding whether to trust it is the point);
  2. computes the RFC 7469 pin of its key (SHA-256 of the SubjectPublicKeyInfo, base64) with a ~40-line DER walker, no dependencies;
  3. fetches the registry's published pins (/api/moshpit/pins?name=); the key must match one, and the certificate must not be CA:TRUE (same refusal moshcode dns trust makes: a CA trusted directly could vouch for any name);
  4. writes the leaf to ~/.tronbrowser/pit-certs/moshpit-<name>.crt and imports it into ~/.pki/nssdb as a peer (certutil -t P,,) under the nickname moshpit <name>, the same one the launcher's trust sync uses, so neither imports the other's work twice.

Because it happens before the SOCKS reply, the browser's TLS handshake that follows already finds the leaf trusted. Once per name per pit run; refusals leave the browser's own warning in place. A 404 from the pins endpoint means "no pin", not an outage.

Linux only (Chromium on macOS reads the keychain) and needs certutil; /pit/status and /pit/start now report trust: {available, why} and the sidebar's "Pit is on" line says which case applies (trusted per name / install libnss3-tools / run moshcode dns enable). Helper 3.4.0, matched in the launcher. Doc updated.

Verified (scratch NSS database, scratch cert dir, scratch ports)

  • DER walker on the probed chovy.hacker certificate → pin v6k99jmaVZC/RqHH5nBEXcCFgqKErHQTsn2umcBHPzQ=, CA:FALSE. Matches openssl and the registry's published pin.
  • https://chovy.hacker/ through the pit → the helper log shows the import; certutil -L shows moshpit chovy.hacker P,,; certutil -V -u V says valid.
  • tstclnt (NSS's own TLS client) against the origin with the scratch DB: handshake completes, HTTP/1.1 200 OK. Same connection with an empty DB: SEC_ERROR_UNKNOWN_ISSUER. The import is what makes it pass.
  • https://mosh.eggs/ (registry publishes no pin): logged "publishes no pin", nothing imported.
  • Second connect is a cache hit. pnpm lint clean, extension tests 30/30, helper compiles, launcher sh -n ok.

Not clicked through in a live TronBrowser (no browser here). One caveat for that: if a name was already opened and rejected earlier in the session, Chromium may keep the verdict cached; reopen the tab or restart.

🤖 Generated with Claude Code

…inst the registry pin

https://chovy.hacker/ on the pit route showed an invalid certificate: the resolver reaches the real origin, which serves a self-signed leaf for its own name, and nothing told the browser to trust it. moshcode dns trust <name> does that for the system store with root; the helper now does the no-root browser equivalent per name. On the first HTTPS CONNECT it fetches the served certificate, computes the RFC 7469 pin of its key (small DER walker, no deps), checks it against the registry's published pins, refuses CA:TRUE, and imports the leaf as a peer (certutil -t P,,) into ~/.pki/nssdb under the launcher's nickname, all before the SOCKS reply so the browser's handshake already finds it trusted. Linux + certutil only; /pit/start reports trust availability and the sidebar says which case applies. Proven with tstclnt: 200 OK with the imported DB, SEC_ERROR_UNKNOWN_ISSUER with an empty one. Helper 3.4.0.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Comment thread apps/desktop/launcher/tron-tor-helper Dismissed
@github-actions

Copy link
Copy Markdown

ThreatCrush Security Scan

54 finding(s)

HIGH/CRITICAL: 2 | MEDIUM: 32 | LOW: 20

Severity Rule Location
HIGH py-ssrf-outbound-request apps/desktop/launcher/tron-tor-helper:303
HIGH py-ssrf-outbound-request apps/desktop/launcher/tron-tor-helper:418
MEDIUM js-open-redirect apps/desktop/extensions/ai-sidebar/install-helper.js:156
MEDIUM js-unescaped-html-sink apps/desktop/extensions/ai-sidebar/media.js:34
MEDIUM js-unescaped-html-sink apps/desktop/extensions/ai-sidebar/media.js:57
MEDIUM js-unescaped-html-sink apps/desktop/extensions/ai-sidebar/newtab.js:237
MEDIUM js-unescaped-html-sink apps/desktop/extensions/ai-sidebar/newtab.js:266
MEDIUM js-unescaped-html-sink apps/desktop/extensions/ai-sidebar/newtab.js:336
MEDIUM js-unescaped-html-sink apps/desktop/extensions/ai-sidebar/options.js:305
MEDIUM js-unescaped-html-sink apps/desktop/extensions/ai-sidebar/sidepanel.js:78
MEDIUM js-unescaped-html-sink apps/desktop/extensions/ai-sidebar/sidepanel.js:166
MEDIUM sh-remote-script-execution apps/desktop/launcher/tronbrowser:122
MEDIUM sh-remote-script-execution apps/desktop/launcher/tronbrowser:433
MEDIUM js-unescaped-html-sink apps/extensions/public/store.js:77
MEDIUM js-unescaped-html-sink apps/extensions/public/store.js:227
MEDIUM js-unescaped-html-sink apps/extensions/public/store.js:569
MEDIUM js-unescaped-html-sink apps/web/public/app.js:29
MEDIUM js-unescaped-html-sink apps/web/public/dns.js:54
MEDIUM sh-remote-script-execution apps/web/public/install.sh:161
MEDIUM sh-remote-script-execution apps/web/public/install.sh:166
MEDIUM sh-remote-script-execution apps/web/public/install.sh:279
MEDIUM sh-remote-script-execution apps/web/public/install.sh:297
MEDIUM sh-remote-script-execution apps/web/public/install.sh:704
MEDIUM sh-remote-script-execution apps/web/public/install.sh:985
MEDIUM js-unescaped-html-sink apps/web/public/settings.js:96
MEDIUM js-unescaped-html-sink apps/web/public/settings.js:168
MEDIUM js-dynamic-code-execution packages/sdk/src/mcp/tools.ts:80
MEDIUM js-dynamic-code-execution packages/sdk/src/mcp/tools.ts:92
MEDIUM js-dynamic-code-execution packages/sdk/src/mcp/tools.ts:103
MEDIUM js-dynamic-code-execution packages/sdk/src/page.ts:65
MEDIUM js-dynamic-code-execution packages/sdk/src/page.ts:70
MEDIUM sql-template-interpolation services/api/src/store/db.ts:116
MEDIUM js-dynamic-code-execution services/api/src/store/scanner.ts:44
MEDIUM sh-predictable-temp-path start.sh:25
LOW js-dynamic-code-execution apps/desktop/extensions/ai-sidebar/pit-proxy.test.js:8
LOW js-dynamic-code-execution packages/agent-runtime/src/analyze/form-script.test.ts:6
LOW js-unescaped-html-sink packages/agent-runtime/src/analyze/form-script.test.ts:26
LOW js-unescaped-html-sink packages/agent-runtime/src/analyze/form-script.test.ts:49
LOW js-dynamic-code-execution packages/browser-core/src/automation/extract-script.test.ts:6
LOW js-unescaped-html-sink packages/browser-core/src/automation/extract-script.test.ts:35
LOW js-unescaped-html-sink packages/browser-core/src/automation/extract-script.test.ts:47
LOW js-unescaped-html-sink packages/browser-core/src/automation/extract-script.test.ts:70
LOW js-unescaped-html-sink packages/browser-core/src/automation/extract-script.test.ts:89
LOW js-dynamic-code-execution packages/browser-core/src/automation/snapshot-script.test.ts:11
LOW js-unescaped-html-sink packages/browser-core/src/automation/snapshot-script.test.ts:24
LOW js-unescaped-html-sink packages/browser-core/src/automation/snapshot-script.test.ts:63
LOW js-unescaped-html-sink packages/provenance/src/scan.test.ts:47
LOW js-unescaped-html-sink packages/provenance/src/scan.test.ts:170
LOW js-unescaped-html-sink packages/provenance/src/scan.test.ts:216
LOW js-dynamic-code-execution packages/sdk/src/mcp/automate.test.ts:258

…and 4 more. Full results in the Security tab.

Snippets are redacted; ThreatCrush never prints matched credential material.

@ralyodio
ralyodio merged commit 2c73072 into main Sep 16, 2026
5 of 6 checks passed
@ralyodio
ralyodio deleted the feat/pit-https-trust branch September 17, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants