Skip to content

fix: keep pre-auth DNS plaintext when saved DoH config hijacks dnsmasq - #2

Merged
RealCaCl2 merged 1 commit into
mainfrom
fix/pre-auth-dns-restore
Oct 23, 2026
Merged

RealCaCl2 merged 1 commit into
mainfrom
fix/pre-auth-dns-restore

Conversation

@RealCaCl2

Copy link
Copy Markdown
Owner

Problem

post_auth 认证前的“恢复明文 DNS”复用了 dns_doh_restore。它会把接管前保存的 https-dns-proxy 配置连同代理一起恢复/启动。如果这份原始配置本身就是 force_dns=1 + dnsmasq_config_update='*'(例如 Cloudflare/Google),dnsmasq 会再次指向 127.0.0.1#5053/5054,门户探测拿到 HTTP 000,最终报 E_PORTAL_NOT_FOUND / portal。

Fix

  • 拆分 dns_doh_save_original、dns_doh_pause 和完整 dns_doh_restore
  • 认证前只停止/禁用代理、保留原始快照、把 dnsmasq 拉回明文;不再启动原代理
  • DoH apply 或解析验证失败时用 dns_doh_pause 回退,不再 full restore
  • 在线轮询通过 av_state_online 刷新 /var/run 状态(不写闪存)
  • status 只统计真正的 autoverify daemon,修正 PID/数量
  • 新增回归:原始配置抢占 dnsmasq、暂停/再次接管/完整恢复
  • 包版本 r19

Verification

  • python3 test/test_dns.py:22/22 通过
  • sh test/run.sh:WSL ext4 + 清除 http_proxy/https_proxy 后全部通过
  • dash -n、git diff --check 通过
  • 实机 OpenWrt 25.12.5:r17 -> r19,doh.pub:5053,gstatic=204,status online,daemon 数量 1

APK: autoverify-1.0.0-r19.apk(48,977 字节,SHA256 ad76bebe505fcc438065a537c7a583cdbf87c0d8f21aef0d715725f43e7d1ec8)

The post_auth restore path reused dns_doh_restore, which imports and starts
the saved https-dns-proxy configuration. If that configuration itself had
force_dns=1 and dnsmasq_config_update='*' (for example Cloudflare/Google),
restore put dnsmasq back on 127.0.0.1#5053/5054. The portal probe then got
HTTP 000 and autoverify reported E_PORTAL_NOT_FOUND.

- split save-original, pre-auth pause, and full restore
- never start the saved proxy before auth; keep the snapshot for a later
  full restore
- use pause instead of full restore when DoH apply or query verification
  fails
- force dnsmasq back to the WAN-provided plaintext upstream during pause
- refresh the online runtime state without writing flash on every poll
- count only `autoverify daemon` in status PID/count
- add regressions for a pre-existing DoH hijack and repeated auth cycles
- bump package release to r19
@RealCaCl2
RealCaCl2 merged commit eb6215d into main Oct 23, 2026
2 checks passed
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