[Feature] 为 AI 请求增加本地脱敏层,降低本地/服务器敏感信息外发风险

Open
#1,827 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
dart, flutter
Domain
ai, security

Research direction

Locate the AI request construction and response rendering code in the Dart/Flutter codebase; the issue suggests inserting a PrivacyFilter or LocalRedactor at those points. Start by exploring the AI chat/agent module to understand request and streaming flow. Done means suspected sensitive content is replaced with placeholders before send and restored per session, with a configurable switch and rules.

Written by the indexing model from the issue text.

Description

feature

背景

Server Box 常接触 SSH 密钥、Token、服务器地址、数据库连接串、环境变量、命令输出等敏感信息。启用 AI 对话 / Agent 后,这些内容可能作为上下文发送到外部 AI 端点,但目前缺少客户端侧本地脱敏机制,敏感信息外发风险不可控。

实例

在 Server Box 1.0.1844 中使用 AI 功能时遇到拒绝服务,排查发现请求触发了上游泄漏保护:

leak protection blocked request: matched gitleaks rule generic-api-key

generic-api-key 是通用规则,可能误判,但这次拦截也说明:AI 出站内容中确实存在形似密钥的片段,而客户端没有发送前脱敏手段。若换成真实密钥或服务器配置,同样可能被发送出去。

期望行为

· 请求发出前,本地将疑似敏感内容替换为占位符,如 PII_API_KEY_1、PII_HOST_2。
· 响应展示时按会话映射还原,或提供可配置的脱敏展示。
· 后续轮次重新脱敏,避免真实敏感内容出设备。
· 提供开关和规则配置,默认保守开启,支持自定义正则、白名单和排除项。
· 流式响应需缓冲跨 chunk 的占位符并正确还原。
· 日志不记录原文,仅记录脱敏统计和规则命中类型。

建议实现

采用纯 Dart 客户端本地脱敏层,不引入外部 Go/Python 网关进程,保证 iOS/Android/桌面端可用:

  1. 抽象 PrivacyFilter / LocalRedactor,插入 AI 请求构造前和响应渲染前。
  2. 请求前对用户输入、历史上下文、工具调用参数、命令输出做规则匹配和占位符替换。
  3. 响应后按会话级映射还原;流式响应缓冲可能被拆分的占位符。
  4. 内置规则包括 generic-api-key、常见 Token、私钥、数据库连接串、服务器地址/主机名等,支持自定义正则。
  5. 可参考 Dart/Flutter 本地脱敏库(如 redact)或实现轻量规则引擎。

环境

· Server Box 版本:1.0.1844
· 平台:iOS / Android / macOS / Linux / Windows
· AI 端点:OpenAI 兼容 / 自定义
· 是否流式:是 / 否
· 错误信息:leak protection blocked request: matched gitleaks rule generic-api-key

Dominant language
Dart
Stars
8.9k
Forks
573
Avg merge
6h 53m
Merged PRs (30d)
133

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lollipopkit/flutter_server_box

All issues in lollipopkit/flutter_server_box

Similar issues

More Dart issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.