Commit Graph

3 Commits

Author SHA1 Message Date
王性驊 413aab7d19 fix: 手機直接連線的 http 只認真的 Tailscale 通道;ANYBOT_PHONE_BIND 讓它只聽一個位址
區網直連的 HTTPS 前面放行不加密 http 的規則,看的是「來源位址在 100.64.0.0/10」。那一段是電信業者
NAT 的共用位址,不是 Tailscale 專用:Wi-Fi 自己發 100.64.x 位址時(部分熱點、校園和公司網路),
手機和這台都是 100.x,設定頁還把這台列成 http://100.x,手機密碼和登入就在空中明文傳。真的 Tailscale
沒有問題(位址在 utun/tailscale0 通道上,WireGuard 加密,tailnet 以外連不到)。

- lantls:不加密的 http 只收 loopback,或「來源在 Tailscale 範圍、而且連到的是這台 Tailscale
  通道介面上的位址」。通道位址從 ifconfig(POINTOPOINT)或 ip -o addr(tailscale0、/32)讀,30 秒快取;
  讀不到介面的電腦(Windows)沒有通道位址,http 一律轉 https。
- remote:列出的網址只有通道位址用 http(原本凡 100. 開頭都是 http);ANYBOT_PHONE_BIND 讓手機頁面
  只聽一個位址(127.0.0.1 給前面有代理或測試用的副本、Tailscale 位址只給 tailnet),列出的網址也只剩那個;
  寫的不是位址就不打開直接連線(不會退回聽每個位址)。沒設時照舊聽 0.0.0.0。
- 伺服器部署不受影響:大腦在 Docker 裡沒有發佈這個連接埠,tailscale serve 前面接的是帳號伺服器(8780)。
- verify-anybot:scratch 的 --serve 用 ANYBOT_PHONE_BIND=127.0.0.1,doctor 檢查只聽 127.0.0.1;
  要驗證從區網/Tailscale 連進來時用 ABV_PHONE_BIND=0.0.0.0。
- 文件:phone.md(http 只認通道、ANYBOT_PHONE_BIND/ANYBOT_PHONE_PORT、Windows、驗證加 lantls::)、
  FEATURES.md(手機網址、環境變數)、SECURITY.md。

已驗證: 完整 cargo test(金鑰清空、DOCKER_HOST 指到不存在)全綠(643 過、47 ignored 沒跑);cargo clippy --bin anybot --all-targets
  -- -D warnings 沒有警告;sh deploy/ci/lint-sh.sh 過;新測試 lantls::tests::tailscale_is_the_tunnel_not_the_range、
  remote::tests::the_phone_page_listens_where_it_is_told_and_lists_that,plain_http_from_the_wifi_is_sent_to_https
  加了 Wi-Fi 發 100.64.x 的情況。實機(這台 Mac,utun4 上 100.84.144.91)用 verify-anybot:修改前 scratch 的
  --serve 聽 *:埠,Tailscale 位址 http 200、區網 http 308;修改後預設(ctl)只聽 127.0.0.1,區網和 Tailscale
  位址連不上;ABV_PHONE_BIND=0.0.0.0 時照舊 *:埠、Tailscale 位址 http 200、區網 http 308→https(預設行為沒變);
  phone 區的範例旅程在只聽 127.0.0.1 下整段照貼結束碼 0。
未驗證: Wi-Fi 自己發 100.64.x 位址的網路——手邊沒有這種網路,只有單元測試;Linux(ifconfig/ip -o addr
  的格式只用樣本測)和 Windows(認不出通道、http 轉 https)沒有實機;伺服器部署沒有重新部署(沒有改 deploy/);
  手機實機連線沒有測(用無頭 Chrome 代替)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 10:36:45 +08:00
王性驊 f9a261959c version_0_1_1-alpha 2026-11-11 16:19:06 +08:00
AnyBot Dev 410aa75690 Say what the walls are: SECURITY.md + threat model (P5)
- SECURITY.md (zh) + docs/en/security.md: trust boundaries (app /
  box / Docker API / relay / providers), where every secret lives and
  what a thief holding that thing actually gets, the injection layers
  with an honest limit (no absolute defense — the human at the gate
  is the last line), the network surface, the known-limits list and
  hardening advice
- state.json is written 0600: it carries model keys, and now says so
  with its permissions like the vault's key file
- README (zh + en) link it; reporting = private security advisory
2026-11-09 20:33:56 +08:00