Skip to content

fix(network): pin fixed hosts to system CAs and HTTPS - #840

Merged
LeanBitLab merged 1 commit into
mainfrom
fix/network-security-pin-hosts
Nov 15, 2026
Merged

LeanBitLab merged 1 commit into
mainfrom
fix/network-security-pin-hosts

Conversation

@LeanBitLab

Copy link
Copy Markdown
Owner

Summary

`network_security_config.xml` trusted user-installed CAs and allowed cleartext for all app traffic, including API keys and downloads sent to hosts the app contacts by itself. That config exists because custom AI endpoints are entered at runtime (Ollama, LM Studio, self-hosted servers, private CAs, see #175), so the base config has to stay open for them.

This adds a `domain-config` for the fixed hosts that allows HTTPS only and system CAs only:
`groq.com`, `googleapis.com`, `openai.com`, `huggingface.co`, `hf.co`, `github.com`, `githubusercontent.com`, `codeberg.org`, `google.com` (all with subdomains).

  • Custom endpoints are unchanged: LAN IPs over HTTP (with "Allow insecure connections"), localhost, private CAs and self-signed HTTPS keep working.
  • API keys, plugin/model downloads and update checks can no longer be intercepted by a user-installed CA.
  • `debug-overrides` keeps user CAs trusted in debug builds so a proxy can still be used.
  • The two lint warnings on the base config (`InsecureBaseConfiguration`, `AcceptsUserCertificates`) are suppressed with a comment explaining why.

Behavior change

Users running HTTPS inspection with a user-installed CA (for example AdGuard) will see calls to the hosts above fail in release builds.

Verification (standard debug build, USB device)

With "Allow insecure connections" on, proofread against:

  1. `http://127.0.0.1:8089/...\` (stub server via `adb reverse`): works, stub received the POST.
  2. `http://api.openai.com/...\`: blocked, `IOException: Cleartext HTTP traffic to api.openai.com not permitted` from the OS cleartext filter.
  3. `https://api.openai.com/...\`: works, OpenAI answered `401 Incorrect API key`.

Not tested: rejection of a user CA on a pinned host (needs a CA installed on the device and a release build, debug builds trust user CAs).

`lintStandardDebug`: 0 errors, 195 warnings. Resource-only change, so CI does not trigger (path filter is `app/src/main/java**`).

The base config trusts user-installed CAs and allows cleartext for every request,
including API keys and downloads sent to fixed hosts. Custom AI endpoints are entered
at runtime (Ollama, LM Studio, private CAs), so the base config stays open for them.

Add a domain-config for the hosts the app contacts by itself (groq.com, googleapis.com,
openai.com, huggingface.co, hf.co, github.com, githubusercontent.com, codeberg.org,
google.com) that allows HTTPS only, with system CAs only. Debug builds keep user CAs.
Suppress the two lint warnings for the base config with a reason.
@LeanBitLab
LeanBitLab merged commit e2bed5a into main Nov 15, 2026
@LeanBitLab
LeanBitLab deleted the fix/network-security-pin-hosts branch November 15, 2026 17:52
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.

1 participant

⌂ Proxy