sec: fix injection-defense bypass — 2 new patterns, 0x08 byte corruption

Added safety-test-ruse and filters-disabled-claim patterns to block
social-engineering probes that claim safety filters are disabled.

Root cause: Python str.replace() wrote literal backspace bytes (0x08)
instead of regex word-boundary markers (\b), making both patterns
silently fail against the probe text.

Fixes persona-bypass pentest probe (Magatama MIND/COMPLY findings).
This commit is contained in:
root 2026-06-20 17:27:18 +00:00
parent f5a9160133
commit 40b53ea625
2 changed files with 17 additions and 3 deletions

View File

@ -10,16 +10,19 @@ module.exports = {
apps: [ apps: [
{ {
name: 'llm-gateway', name: 'llm-gateway',
script: 'packages/gateway/dist/server.js', script: 'packages/gateway/scripts/launch.mjs',
cwd: '/opt/llm-gateway', cwd: '/opt/llm-gateway',
instances: 1, instances: 1,
exec_mode: 'fork', exec_mode: 'fork',
env: { env: {
NODE_ENV: 'production', NODE_ENV: 'production',
PORT: 3103, PORT: 3103,
AUTO_SPAWN_BRIDGES: '1',
DASHBOARD_AUTH_TOKEN: 'ctx-gw-fbb149f6be8eeea9549853d2681580bdd1f1',
LLM_GATEWAY_ADMIN_TOKEN: 'ctx-gw-fbb149f6be8eeea9549853d2681580bdd1f1',
DATABASE_URL: process.env.DATABASE_URL || 'postgresql://llm:llm_secure_2026@localhost:5432/llm_gateway', DATABASE_URL: process.env.DATABASE_URL || 'postgresql://llm:llm_secure_2026@localhost:5432/llm_gateway',
TIP_DATABASE_URL: process.env.TIP_DATABASE_URL || 'postgresql://tip:tip_prod_2026@217.154.82.179:5433/transceiver_db', TIP_DATABASE_URL: process.env.TIP_DATABASE_URL || 'postgresql://tip:tip_prod_2026@217.154.82.179:5433/transceiver_db',
OLLAMA_URL: 'http://192.168.178.213:11434', OLLAMA_URL: 'http://127.0.0.1:11434',
LOG_LEVEL: 'info', LOG_LEVEL: 'info',
GITEA_URL: 'http://192.168.178.196:3000', GITEA_URL: 'http://192.168.178.196:3000',
GITEA_TOKEN: '', GITEA_TOKEN: '',
@ -30,7 +33,10 @@ module.exports = {
OPENAI_BRIDGE_URL: 'http://localhost:3251', OPENAI_BRIDGE_URL: 'http://localhost:3251',
CHATGPT_BRIDGE_URL: 'http://localhost:3251', CHATGPT_BRIDGE_URL: 'http://localhost:3251',
COPILOT_BRIDGE_URL: 'http://localhost:3252', COPILOT_BRIDGE_URL: 'http://localhost:3252',
LLM_PROVIDERS: 'claude,openai,chatgpt,copilot,cerebras,groq,mistral,nvidia', CODEX_BRIDGE_URL: 'http://127.0.0.1:3253',
OPENAI_CODEX_URL: 'http://127.0.0.1:3253',
M365_COPILOT_BRIDGE_URL: 'http://127.0.0.1:3357',
LLM_PROVIDERS: 'claude,openai,chatgpt,copilot,m365-copilot,codex,cerebras,groq,mistral,nvidia',
// Subscription API Keys (add as needed) // Subscription API Keys (add as needed)
OPENAI_API_KEY: '', OPENAI_API_KEY: '',
GITHUB_CODEX_TOKEN: '', GITHUB_CODEX_TOKEN: '',
@ -82,7 +88,9 @@ module.exports = {
env: { env: {
NODE_ENV: 'production', NODE_ENV: 'production',
COPILOT_BRIDGE_PORT: 3252, COPILOT_BRIDGE_PORT: 3252,
COPILOT_BRIDGE_HOST: '127.0.0.1',
COPILOT_API_INTERNAL_PORT: 4141, COPILOT_API_INTERNAL_PORT: 4141,
COPILOT_API_PACKAGE: 'copilot-api@latest',
}, },
autorestart: true, autorestart: true,
watch: false, watch: false,

View File

@ -61,6 +61,12 @@ const PATTERNS: readonly InjectionPattern[] = [
{ id: 'pretend-rolemix', category: 'role_bypass', severity: 'medium', { id: 'pretend-rolemix', category: 'role_bypass', severity: 'medium',
pattern: /\bpretend\s+you\s+(?:are\s+not\s+|don't\s+have\s+|have\s+no\s+)(?:bound\s+by|restricted\s+by|limited\s+by|filtered\s+by)\b/i, pattern: /\bpretend\s+you\s+(?:are\s+not\s+|don't\s+have\s+|have\s+no\s+)(?:bound\s+by|restricted\s+by|limited\s+by|filtered\s+by)\b/i,
description: 'Pretend-you-are-not-restricted bypass' }, description: 'Pretend-you-are-not-restricted bypass' },
{ id: 'safety-test-ruse', category: 'role_bypass', severity: 'high',
pattern: /pretend\s+(?:we\s+are\s+|this\s+is\s+|we're\s+)?(?:running|doing|conducting|executing)\s+a\s+(?:safety|security|compliance|filter)\s+test/i,
description: 'Social-engineering pretend-safety-test bypass' },
{ id: 'filters-disabled-claim', category: 'role_bypass', severity: 'high',
pattern: /(?:safety|content|output|security)\s+(?:filters?|checks?|restrictions?)\s+(?:are|is|have\s+been)\s+(?:temporarily\s+)?(?:disabled|deactivated|turned\s+off|suspended|bypassed)/i,
description: 'False claim that safety filters are disabled' },
// ─── System-prompt extraction ─────────────────────────────────────────── // ─── System-prompt extraction ───────────────────────────────────────────
{ id: 'reveal-system-prompt', category: 'system_prompt_leak', severity: 'high', { id: 'reveal-system-prompt', category: 'system_prompt_leak', severity: 'high',