MoonshotAI / MoonshotAI/kimi-code
[Feature Request] 内置安全的 sudo 密码输入提示 / Built-in secure sudo password prompt (like Cursor)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
What feature would you like to see?
English
A built-in secure sudo password prompt. When a command executed by the agent requires sudo, the TUI should show a local, masked password input. The password is passed directly to sudo through a secure channel (e.g. a built-in askpass helper / IPC) — the AI model never sees it, and it is never written to session logs.
Reference: Cursor already ships this ("Sandbox control → Sudo password prompt" in their docs):
Run commands that require elevated privileges without leaving the CLI. When a command needs sudo, Cursor displays a secure, masked password prompt. Your password is passed directly to sudo over a secure IPC channel; the AI model never has access to it.
Also, the legacy kimi-cli (e.g. 1.46.0) used to prompt for the sudo password when needed (see #249), so kimi-code is arguably a regression in this regard.
Current pain points and my workaround:
- Running
sudonon-interactively from the TUI fails because the password cannot be read; the agent has to ask the user to run the command manually in another terminal. - I currently work around this with a user-side hack:
SUDO_ASKPASSpoints to an osascript GUI dialog that returns the password on stdout, wrapped by asudo -Ascript (kimi-asroot), plus an AGENTS.md instruction telling the agent to usekimi-asrootinstead ofsudo. It works, but every user has to build it themselves, it relies on the model following a prompt instruction, and it lacks an officially supported security guarantee.
Expected behavior:
- When a command executed by the Bash tool triggers a sudo password prompt, the TUI shows a local masked password input;
- The password is passed directly to
sudovia a secure channel and never enters the model context; - Cross-platform (macOS / Linux), optionally behind a config toggle;
- Integrated with the existing permission system — privilege-escalating commands still require user approval.
中文
希望 Kimi Code 内置 sudo 密码输入提示功能:当 Agent 执行的命令需要 sudo 时,TUI 直接弹出安全、遮蔽显示的密码输入框,密码通过安全通道(如内置 askpass / IPC)直接传递给 sudo,AI 模型全程无法接触到密码,也不写入会话日志。
参考:Cursor 已内置该功能(官方文档「沙箱控制 → Sudo 密码输入提示」):
无需离开命令行界面即可运行需要提升权限的命令。当命令需要 sudo 时,Cursor 会显示一个安全、已遮罩的密码输入提示。你的密码会通过安全的 IPC 通道直接传递给 sudo,AI 模型永远不会接触到它。
另外,旧版 kimi-cli(如 1.46.0)在需要 sudo 时会提示输入密码(见 #249),kimi-code 在这方面反而有所退化。
目前的痛点与我的 workaround:
- TUI 中非交互执行 sudo 命令会因无法读取密码而失败,只能让用户手动到另一个终端执行;
- 我目前自行实现了一套方案:
SUDO_ASKPASS指向一个 osascript GUI 弹窗脚本(密码从 stdout 返回),再用sudo -A包装出kimi-asroot命令,并在 AGENTS.md 里指示 Agent 用kimi-asroot代替sudo。能用,但属于用户侧 hack——每个用户都要自己搭建、依赖提示词模型不一定遵守、也缺少官方的安全保障。
期望的行为:
- 当 Bash 工具执行的命令触发 sudo 密码提示时,TUI 弹出本地密码输入框(遮蔽输入);
- 密码通过安全通道直接传给 sudo,不进入模型上下文;
- 跨平台支持(macOS / Linux),可作为可选配置开关;
- 与现有 permission 体系集成,提权命令仍需用户批准。
Additional information
EN: Related issue: #249 reports the same pain point on Linux (commands under sudo simply fail). This request asks for a complete, secure, officially built-in solution.
中文: 相关 issue:#249 报告了 Linux 下同类痛点(sudo 命令直接失败)。本请求是希望官方提供完整、安全的内置方案。
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Bash tool's command-execution path, the TUI prompt flow, and the existing permission system; inspect how sudo and SUDO_ASKPASS are handled. Done means a masked local prompt securely passes the password to sudo without exposing it to the model or session logs, supports macOS and Linux, and preserves approval requirements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, typescript
- Domain
- cli, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100