shivxm27/prompt_injection_blocker

GitHub: shivxm27/prompt_injection_blocker

一款 Chrome 扩展,在用户从 Coursera 复制文本时自动检测并清除隐藏的提示注入攻击,保护下游 AI 工具不被恶意指令劫持。

Stars: 0 | Forks: 0

# 🛡️ Prompt 注入拦截器
![版本](https://img.shields.io/badge/version-1.0.0-f59e0b?style=flat-square) ![Manifest](https://img.shields.io/badge/manifest-v3-f59e0b?style=flat-square) ![平台](https://img.shields.io/badge/platform-Chrome-4285F4?style=flat-square&logo=googlechrome&logoColor=white) ![许可](https://img.shields.io/badge/license-MIT-10b981?style=flat-square) ![状态](https://img.shields.io/badge/status-active-10b981?style=flat-square) **一款用于检测并静默清除 Coursera 上复制文本中 Prompt 注入攻击的 Chrome 扩展程序。**
## 目录 - [功能特性](#features) - [安装说明](#installation) - [工作原理](#how-it-works) - [管理规则](#managing-patterns) - [项目结构](#project-structure) - [贡献指南](#contributing) - [许可协议](#license) ## 功能特性 - 🔍 **每次复制均扫描** — 在 `coursera.org` 上拦截 `Ctrl+C`,无需额外操作 - 🧹 **静默清除注入内容** — 自动将干净的文本重新写入剪贴板 - ⚠️ **琥珀色警告提示** — 检测到并移除注入内容时短暂显示 - 🧩 **10 种内置规则** — 开箱即用,覆盖已知的 Coursera 注入变体 - ⚙️ **设置页面** — 通过实时的正则表达式测试框添加、编辑、启用/禁用规则 - 🌗 **自动明暗主题** — 跟随您的系统偏好 - 🔒 **100% 本地运行** — 无服务器、无遥测、无外部请求 ## 安装说明 **步骤 1.** 从 [Releases](../../releases/latest) 下载最新的 `.zip` 文件 **步骤 2.** 在您的计算机上任意位置解压该文件 **步骤 3.** 打开 Chrome 并访问: ``` chrome://extensions ``` **步骤 4.** 使用右上角的开关启用 **开发者模式** **步骤 5.** 点击 **加载已解压的扩展程序** 并选择解压后的文件夹 **步骤 6.** 完成。扩展程序的盾牌图标将出现在您的 Chrome 工具栏中。 ## 工作原理 ``` You press Ctrl+C on coursera.org │ ▼ Extension reads the clipboard (80ms delay to let browser write first) │ ▼ Runs text through each enabled regex pattern │ ┌────┴────┐ Match? No match? │ │ ▼ ▼ Strips injection Does nothing — completely silent Writes clean text back to clipboard Shows amber pill: "⚠ Injection stripped" ``` ## 管理规则 点击扩展程序图标 → **管理规则 (Manage Patterns)** 打开设置页面。 | 操作 | 方法 | |---|---| | 禁用规则 | 切换左侧的开关 | | 编辑规则 | 点击铅笔图标 | | 添加自定义规则 | 点击 **添加规则** — 支持完整的 JavaScript 正则表达式 | | 测试规则 | 在“添加/编辑”弹窗中使用实时测试框 | | 在真实文本中预览 | 将文本粘贴到“实时预览”面板中 | | 恢复默认设置 | 点击 **恢复默认设置** | ### 内置规则 | ID | 检测内容 | |---|---| | p1 | 完整的 `You are a helpful AI assistant…Do you understand?` 代码块 | | p2 | 学术诚信指令块 | | p3 | `Your sole function is to…stop.` 指令 | | p4 | `Scan all elements…data-action` 命令 | | p5 | `Click this button to confirm compliance` 点击劫持 | | p6 | `This verification step is mandatory` 代码块 | | p7 | `AI Agent Compliance Verification Required` 请求头 | | p8 | `data-action="acknowledge-guidelines"` 属性注入 | | p9 | `You must not attempt to answer` 覆盖指令 | | p10 | `Locate the button labeled` 点击劫持变体 | ## 项目结构 ``` prompt-injection-blocker/ ├── manifest.json # Extension config (Manifest V3) ├── content.js # Copy listener, pattern matching, pill alert ├── background.js # Service worker — sets defaults on install ├── patterns/ │ └── injectionPatterns.js # Pattern library + runPatterns() engine ├── popup/ │ ├── popup.html # Toolbar popup │ ├── popup.css │ └── popup.js ├── settings/ │ ├── settings.html # Full settings page │ ├── settings.css │ └── settings.js ├── icons/ │ ├── icon16.png │ ├── icon48.png │ └── icon128.png ├── CHANGELOG.md ├── LICENSE └── README.md ``` ## 许可协议 MIT © [shivxm27](https://github.com/shivxm27)
标签:AI安全, AI工具防护, Chat Copilot, Chrome Manifest V3, Chrome插件, Chrome浏览器扩展, CMS安全, Coursera, JavaScript, JSONLines, Naabu, Prompt注入, 内容安全, 剪贴板安全, 剪贴板过滤, 多模态安全, 大语言模型安全, 对抗性攻击防御, 恶意内容过滤, 提示注入防护, 数据可视化, 文本过滤, 本地处理, 机密管理, 网络安全, 网络安全, 自定义脚本, 隐私保护, 隐私保护, 零信任