Repository navigation
Replies: 1 comment
foot 与 wezterm 源码定向安全审计报告
结论摘要两个终端均未发现键盘监听、未发现恶意数据外发后门。 foot 攻击面极为克制:全树 0 处 IP 网络访问,无遥测、无状态落盘、无敏感文件读取,且构建时 残余关注点均为设计内的终端能力(非后门):
第一部分:foot1. 网络外发通道 —— 无
foot 是一个纯粹的本地终端:它不发起任何 IP 网络连接,也没有任何"把数据送出去"的代码路径。 2. 构建期联网 —— 有 1 处兜底路径,已在本次处置中封死
3. 转义序列副作用与本地数据 —— 干净,1 项能力需知悉OSC 52(剪贴板)—— 原默认读+写均开,已收紧为仅写(见 §4 修复 3)上游编译默认
两者都有焦点守卫(
即:后台程序无法静默窃取剪贴板。这是终端的既有能力而非后门;kan-linux 已把读取方向封死(见 §4 修复 3),写入方向按需可再收紧为 其他 OSC
URL 打开
日志 / 写盘 / utmp
混淆与隐藏载荷 —— 无ELF 二进制 0 个、base64 blob 0 个、 输入侧 —— 无键记录
第二部分:wezterm1. 默认网络外发 —— 1 处:更新检查(已在本次处置中关闭)
泄露面:向 GitHub(第三方)披露客户端 IP 与 wezterm 版本,每 24 小时一次。 上游
该 feature 的唯一效果就是把 2. 用户主动的网络能力 —— 设计内
3. 遥测 / 键记录 / 隐藏载荷 —— 均无
4. 转义序列与本地数据
URL 打开
Lua 配置与插件
mux socket 权限
5. 构建期网络
4. 关联修复记录(本次配合处理)修复 1:wezterm 默认更新检查(默认外发点)问题: cargo 构建未启用 处置: wezterm 构建命令追加 效果:构建出的 wezterm 默认不再发起任何更新检查请求;用户仍可在 Lua 配置中显式打开。 修复 2:foot 构建期联网兜底问题: 处置:foot 的 效果:依赖解析失败时直接报错而非静默联网,保持 kan-linux 构建的离线确定性。 修复 3:foot 剪贴板读取能力收紧问题: 处置:编译默认改为
效果:默认不再有剪贴板被终端内程序窃取的隐私面;写入能力与常用工作流保持不变。 5. 覆盖范围声明与后续工作本次审计仅覆盖
6. 与 kan-linux "secure" 特征的关系本次审计进一步确认 kan-linux 选型的两个终端在源码层无键记录、无后门、无隐意外发。 |
Uh oh!
There was an error while loading. Please reload this page.
Foot & WezTerm Security Audit: Keylogging / Backdoors / Data Exfiltration
external/apps/foot— foot terminal emulator (C, ~59 .c + 63 .h)external/apps/wezterm— WezTerm terminal emulator (Rust, ~459 .rs across multiple crates)foot-wezterm-源码定向安全审计-2026-11-01.md(Chinese, combined). This audit is a three-track re-verification in the same format as the Hyprland and Quickshell auditsExecutive Summary
debug_key_eventsdefault-off and logs only to the log sink;wezterm recordcaptures output, not keystrokes~/.ssh(by design, wezterm-ssh)distro-defaultsfeature; no telemetry/crash reportingBoth terminals are clean on all three tracks. Residual risks are design-inherent terminal capabilities (clipboard write, file transfer, notification spawning) and two foot IPC hardening gaps [NEW]. The prior audit's three findings were re-verified as remediated in source (see §4).
Part 1: foot
1.1 Keyboard Monitoring — clean
input.c→term_to_slave()→ pty write (terminal.c:74) only. IME commit likewise goes to the pty (ime.c:205).LOG_DBGbehind_DEBUG && LOG_ENABLE_DBG(input.c:1648-1668), andLOG_ENABLE_DBGis0in every .c file — compiled out in release builds. Note:ime.c:99,116would log preedit/commit text if debug logging were enabled (relevant only for debug builds).grid.c); no disk dump of terminal content.csi.c:1406-1426), DA1 (csi.c:847), DECRQM (csi.c:606+), XTGETTCAP (dcs.c:112-172), DECRQSS (dcs.c:255), color queries (osc.c:1305+).#if 0(csi.c:1355-1362,osc.c:1636-1646) — no title-readback leak.input.c:240-317sends scrollback/selection to a user-configured command) and the clipboard — no covert path.1.2 Backdoors — none found; two hardening notes
Ruled out:
system()/popen()(zero),dlopen(zero),ptrace(zero), credential-file access (~/.ssh,.gnupg,/etc/shadow,.netrc, keyring — zero; the/etc/shellsread atslave.c:93is legitimate). No date/env/hostname-gated behavior (env use is XDG/Wayland/cursor config only;quirks.c:20,78compositor quirks are benign). No base64/hex blobs (≥120-char literals searched).Exec/spawn sites (all
execvp/execvpe, no shell —spawn.c:82)slave.c:385→301$SHELL/ configshellterminal.c:201,226utmp-helper(fixed args)terminal.c:3745bell.command(fixed args)terminal.c:3756foot_exe(fixed)input.c:309url-mode.c:79,129url.launch+${url}notify.c:572${title} ${body}…main.c:518/bin/sh -c ""(fixed)Injection surface is limited to the argv of user-configured helpers. Two notes:
notify.c:55-82): the icon payload of an OSC 99 notification is written to/tmp/foot-notification-icon-XXXXXXviamkostemp(mode 0600, unlinked afterwards). This is an escape-sequence-driven write of attacker-controlled content; the path is not attacker-controlled. Risk: low (content write only, no execution, restrictive mode, cleaned up).server.c:527-560,client.c:357-382): thefootclient→footserverAF_UNIX socket has noSO_PEERCREDcheck and no explicitchmod; permissions are umask-dependent. The fallback path/tmp/foot.sock(server.c:566,client.c:378) is cross-user reachable if umask is permissive. The protocol allows spawning a new terminal as the server user with arbitrary argv/env and config overrides (includingsecurity osc52and notify/url/bell commands,server.c:321-330). It cannot inject input into or read the screen of existing terminals. kan-linux shipsfoot/footclientbut notfootserver, so the socket does not exist unless a user startsfootservermanually — the risk is latent. Recommendation: if footserver is ever shipped/enabled, wrap it with a umask(0077) or add a peer-cred check (as Quickshell now does).1.3 Data Exfiltration — none
AF_UNIX(server.c:430,527,client.c:340) andwl_display_connect(wayland.c:1698). Nogetaddrinfo/curl/wget/inet_*.url-mode.c:56-129spawns the user-configured launcher (e.g. xdg-open) with${url}as argv; user gesture required..osc52 = OSC52_COPY_ENABLED(config.c:3320, write-only); the paste direction additionally requires an explicit opt-in (osc.c:201-202). Both directions carry a focus guard (osc.c:53-65,187-199) — an unfocused window rejects clipboard access with a warning. The write direction (paste-jacking: overwriting the user clipboard) remains enabled by terminal convention.terminal.c:193-226); the kan-linux build sets the utmp backend to none, so no login records are written.main.c:118), the notify icon tmp file (§1.2), the IPC socket. No state/cache/telemetry files.1.4 Escape-sequence capability table (foot)
--guard (config.c:3450)url.launchwith${url}term->cwd→ cwd of later spawnsosc.c:453-470)${window-title}argv1.5 Build-time notes (supply chain)
subprojects/*.wrapdeclares 3wrap-gitdependencies (fcft, tllist, wayland-protocols) on unpinned branches (master/main), fetched only when wrap downloads are permitted. The kan-linux build disables wrap downloads, so a missing dependency fails the build instead of silently reaching the network. Unpinned branch fetches are a supply-chain note for any future rebuild that re-enables wraps.Part 2: WezTerm
2.1 Keyboard Monitoring — clean
debug_key_eventsis default-off (#[dynamic(default)]→ false,config/src/config.rs:432). When explicitly enabled it logs key events / encoded bytes / composed text vialog::info!to the log sink (stderr or--log-file) only (keyevent.rs:294,441,615,735;term/src/terminalstate/keyboard.rs:49) — never to disk, clipboard, or network.wezterm recordis a user CLI subcommand (wezterm/src/main.rs:132) that writes asciicast output events only (asciicast.rs:129) — no keystroke recording.Key::Composedis sent to the pane (keyevent.rs:723-736).enable_title_reporting, default off (config/src/config.rs:262-267). Kitty keyboard query/push/pop reports mode flags only, gated byenable_kitty_keyboard, default false (performer.rs:524-570).performer.rs:792QuerySelection(_) => {}) — stricter than foot.2.2 Backdoors — none found
Ruled out: hidden triggers, hardcoded credentials/keys,
ptrace, non-standarddlopen(only EGL/GL loaders,window/src/egl.rs:443), obfuscated payloads. Thesentry/opentelemetrystring hits are nerd-font glyph names inwezterm-char-props/src/nerdfonts_data.rs(false positives, re-verified). Sensitive-file access is confined to wezterm-ssh's OpenSSH-compatible~/.ssh/{config,known_hosts,identity*}(wezterm-ssh/src/config.rs:465-594).No escape sequence executes commands or triggers the plugin git-clone path.
Escape-sequence capability table (wezterm)
performer.rs:792)performer.rs:793-798)File=(non-inline)~/Downloads, no prompt (iterm.rs:11-14)/\stripped (rsplit),./../:rejected (download.rs:8-21); NUL names fail atopen;create_newblocks overwrite; hidden/unicode filenames stay inside Downloadsmod.rs:3173-3205) or user key action (mod.rs:3156)mod.rs:1407-1457)performer.rs:908-935)Spawn/exec + Lua surface
All
Command::newsites adjudicated:$SHELLprobe (mux/src/domain.rs:406);xdg-open/gio/… on click only (wezterm-open-url/src/lib.rs:8-32) — no HTTP is ever issued by WezTerm itself.serve_command(client.rs:463,759); wezterm-sshProxyCommandviash -c(sessioninner.rs:335-355) — standard OpenSSH semantics, user-trusted~/.ssh/config.wezterm.spawn/open_with(lua-api-crates/spawn-funcs/src/lib.rs:32,55). Lua runs the full stdlib (Lua::new(),config/src/lua.rs:212;os.execute/io.popen/loadare not removed) — expected: config = user code.wezterm.plugin.require(url)performs a libgit2clone_recurse(lua-api-crates/plugin/src/lib.rs:163-180) only from explicit Lua; the URL scheme is not restricted (plugin/src/lib.rs:53-63) — anything libgit2 accepts (incl. ssh/file) is reachable from user config. No escape-sequence path to it. Third-party plugin supply chain is the user's responsibility.2.3 Data Exfiltration — one egress, disabled by distro default
update.rs:59GET https://api.github.com/repos/wezterm/wezterm/releases/latest, UAwezterm/wezterm-<ver>, no bodycheck_for_updates; default iscfg!(not(feature = "distro-defaults"))(config/src/config.rs:1626-1627), i.e. on upstream, off when the distro feature is enabled. The kan-linux build enablesdistro-defaults→ default off (verified in build configuration; no build paths recorded here per reporting policy)wezterm-clientTcpStream::connect(client.rs:1013)TcpListener(ossl.rs:176)ossl.rs:169)reqwestinwezterm-char-props/codegen,sync-color-schemeshttphits)No telemetry, no crash reporting, no update pings besides the gated checker. Build-time: cargo fetches crates.io dependencies (no vendored registry in-tree) — a supply-chain note against the "offline-buildable" goal;
build.rsperforms no network access (version stamping reads local git metadata only).2.4 mux / SSH trust boundary
umask(0o077)(umask/src/lib.rs:26), directory ownership/mode checks rejecting group/other write plus sticky bit (wezterm-mux-server-impl/src/local.rs:48-95) → same-user only.skip_permissions_checkmust be explicitly enabled.pki.rs:87-97,ossl.rs:169).codec/src/lib.rs:452-501):SendKeyDown/WriteToPane/SendPasteinject input,GetLines/GetPaneRenderChangesread the screen,SpawnV2/SplitPanespawn processes,SetClipboardwrites the clipboard. Trust = OS user / certificate holder. Recorded as design, not a finding.Part 3: Deltas vs the Prior Audit (2026-11-01)
.osc52 = OSC52_COPY_ENABLED(config.c:3320) + focus guards/tmpfallback cross-user under loose umask (latent — footserver not shipped)/tmp(0600, unlinked)distro-defaultsPart 4: Risk Findings and Recommendations
4.1 [LOW] foot IPC socket hardening (latent)
footserver's AF_UNIX socket lacksSO_PEERCREDand explicit permissions; the/tmp/foot.sockfallback is cross-user reachable under a permissive umask, and the protocol can spawn terminals with arbitrary argv/env/config overrides as the server user. Not shipped in kan-linux today (onlyfoot/footclient). If footserver is ever enabled: applyumask(0077)/chmod, or add a peer-cred UID check (pattern reference: Quickshell'ssrc/ipc/ipc.cpp).4.2 [MEDIUM] Clipboard write via OSC 52 (both terminals, by design)
A program running inside either terminal can overwrite the user's clipboard without confirmation (paste-jacking). foot has a focus guard (unfocused windows are rejected); wezterm has none. Foot's read direction is already disabled. Optional hardening: set foot
security OSC52=disabledand/or configure wezterm to disable OSC 52 entirely if clipboard writes from terminal content are not needed.4.3 [MEDIUM] Automatic file/notification side effects from escape sequences
File=auto-writes attacker-controlled content to~/Downloads(filename sanitized; content not executed).--) and may drop an icon file in/tmp.These are terminal-design capabilities (iTerm2 file transfer, desktop notifications), not backdoors. Residual risk is social engineering (filenames) and argv injection into a user-configured helper. If untrusted output is regularly displayed (e.g.
curl | less-style workflows over raw TTY), consider disabling OSC 1337 in wezterm and OSC 99 in foot.4.4 [LOW] Build-time supply chain
4.5 [INFO] Notes
ime.c:99,116); release builds compile this out.Part 5: Residual Risks (out of scope)
Part 6: Methodology (reproducibility)
All reactions