Skip to content

[BUG] terminal.input 命令含 [DEBUG] console.log,每次击键泄漏明文输入内容 #15

Description

@pallyoung

问题描述

packages/server/src/commands/terminal.ts 第 180 行的 console.log('[DEBUG] terminal.input command:', {...}) 遗留在生产代码中。

该日志在每次用户击键时触发,并将 bufferPreview(输入内容前 50 字节)打印到 stdout,可能泄漏密码、sudo token 等敏感信息。

影响

  • 安全风险:终端输入(含密码)明文写入服务器日志
  • 性能:高频热路径(每次击键)同步写 console

相关代码

terminalId: args.terminalId,
sessionId,
activity: args.activity,
bufferSize: buffer.length,
bufferPreview: buffer.toString('utf-8').substring(0, 50),
});
if (sessionId) {
ctx.sessionMgr.sendInput(sessionId, buffer, args.activity, args.submittedText);
return;
}

修复建议

删除该 console.log,或替换为受 traceTerminal 开关控制的条件日志(参考 xterm-host.tsx 中 TERMINAL_TRACE_STORAGE_KEY 的实现方式)。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions