Skip to content

Latest commit

 

History

History
140 lines (113 loc) · 13.6 KB

File metadata and controls

140 lines (113 loc) · 13.6 KB

Trace Guard — Autonomous Engineering & Research Journal

Principal Engineer / Lead Security Researcher: Antigravity AI Project: Trace Guard (trace-guard-npm) Status: ACTIVE CONTINUOUS DEVELOPMENT


📌 Executive Mission Statement

To build a world-class, zero-dependency defensive toolkit against autonomous AI browsing agents, Vision-Language Models (VLMs), and LLM content scrapers. Grounded in real computer science, empirical browser testing, polymorphic prompt obfuscation, and cross-layer DOM/AX-Tree/Visual trap engineering. Zero fluff. 100% reproducible results.


🔬 Research & Engineering Timeline

Phase 1: Paradigm Shift (Completed)

  • Abandoned client-side mouse-tracking behavioral heuristics due to inherent flaws (PyAutoGUI emulation, high false positive rates, anti-detect browser evasions).
  • Adopted Architectural Vulnerability Exploitation: Prompt Injection defense via DOM Canary Tokens & ACL 2025 Adversarial Overlays.

Phase 2: AX-Tree Empirical Discovery (Completed)

  • Empirical Discovery: Proved via Playwright ARIA snapshots (page.locator('html').ariaSnapshot()) that Chromium automatically strips aria-hidden="true" elements from the Accessibility Tree.
  • Solution: Developed ax-tree-region canary tokens (role="region" without aria-hidden="true", placed offscreen via CSS) to guarantee exposure to AX agents (Browser-Use, WebArena, Claude AX Mode).

Phase 3: Polymorphic Engine & Decoy API Integration (Completed)

  • Polymorphic Prompt Generator: Matrix of salience leads, context roles, instruction verbs, and TOS legal framings generating > 1,200 unique prompt phrasings to defeat static regex matching.
  • Decoy API Honeypot Generator: Dynamically injects /_tg_decoy_* paths into <link rel="alternate"> and HTML comments to trap API scrapers and crawlers.
  • Image Alt-Text & Markdown Traps: Targets Markdown converters (Turndown.js, Readability.js) using hidden SVG <img> alt-text traps.

Phase 4: Enterprise CSP & Multi-Encoding Interception (Completed)

  • CSP Nonce Auto-Detection: Automatically parses Content-Security-Policy response headers, extracts script nonces ('nonce-XYZ'), and appends nonce="XYZ" to injected scripts. Ensures full compatibility with strict enterprise CSPs.
  • Multi-Stream Compression Support: Transparent decompression and re-compression of Gzip, Deflate, and Brotli (br) HTTP response streams. Verified in tests/integration_csp_gzip.test.ts.

Phase 5: Self-Healing Traps & Automated Snapshot System (Completed)

  • Self-Healing MutationObserver Traps: Client-side script observes DOM mutations. If an automated script attempts to delete or sanitize canary elements from the DOM, Trace Guard logs a high-severity LLM_AGENT_DETECTED_VIA_CANARY_ELEMENT_DELETED event.
  • Automated Versioned Backup Pipeline: Created scripts/create_backup.js producing timestamped snapshot backups under backups/snapshot_[timestamp]/.

Phase 6: Enterprise Framework Adapters (Next.js & Express) (Completed)

  • Next.js App Router Middleware: Exported traceGuardNextMiddleware() compatible with Vercel Edge Runtime and Next.js 14/15/16 middleware.ts.
  • Express Middleware: Exported traceGuardExpress() middleware.
  • Verified Unit Tests: Added tests/frameworks.test.ts (100% passing across 3 test suites, 24 tests).
  • Automated Backup: Created Snapshot #3 under backups/snapshot_2026-08-02T13-04-05-114Z.

Phase 7: HTML Sanitizer Resiliency & Snapshot #4 (Completed)

  • Class-Based CSS Stylesheet Injection: Injected .tg-offscreen-trap and .tg-hidden-input stylesheets to guarantee canary element position isolation even when aggressive HTML sanitizers strip inline style="..." attributes.
  • Automated Snapshot #4: Saved complete working state to backups/snapshot_2026-08-02T13-04-29-209Z.

Phase 8: Fastify & Hono Enterprise Adapters & Snapshot #5 (Completed)

  • Fastify Plugin Adapter: Exported traceGuardFastify supporting Fastify 4/5 onRequest & onSend hooks.
  • Hono Middleware Adapter: Exported traceGuardHono supporting Bun, Deno, and Cloudflare Workers runtime servers.
  • Automated Snapshot #5: Saved complete working state to backups/snapshot_2026-08-02T13-05-55-514Z.

Phase 9: Multimodal Audio & Canvas Pixel Traps & Snapshots #6 & #7 (Completed)

  • Multimodal Audio API Honeypots: Injected <audio> tags with prompt injection attributes targeting speech/audio LLM agents.
  • Canvas Pixel OCR Traps: Rendered pixel-based prompt text on hidden <canvas> contexts to catch VLM agents using DOM element canvas OCR extraction.
  • Automated Snapshot #7: Saved complete working state to backups/snapshot_2026-08-02T13-09-49-746Z.

Phase 10-13: Cryptographic HMAC, Telemetry Rate Limiting & Prometheus Export (Completed)

  • Client Cryptographic HMAC Signing: Implemented time-bound HMAC-SHA256 session signatures (verifyHmacSignature) to reject forged callback reports (INVALID_HMAC_SIGNATURE).
  • Telemetry Rate Limiting: Sliding window token bucket rate limiter (checkTelemetryRateLimit) preventing DoS spam on telemetry endpoints.
  • Decoy Client Metadata Capture: IP & User-Agent logging on honeypot decoy API routes.
  • Prometheus Text Exporter: Exported exportPrometheusMetrics() for native SOC metrics collection.
  • Automated Continuous Harness: Created scripts/auto_loop_test.js running build, test, benchmark, and automatic backup creation in a single automated step.
  • Automated Snapshots #8 through #15: Saved snapshots up to backups/snapshot_2026-08-02T13-19-20-772Z.

Phase 14: OpenAPI / Swagger Honeypot Schema Generator & Snapshot #18 (Completed)

  • OpenAPI 3.0 Deception Generator (src/honeypot.ts): Auto-generates dynamic OpenAPI specs with canary prompt directives embedded in parameter and header descriptions.
  • Automatic Route Interception: traceGuardNextMiddleware, Express, Fastify, and Hono automatically serve honeypot schemas on /openapi.json and /swagger.json.
  • Verified Unit Tests: Added tests/honeypot.test.ts (31 active unit tests passing across 4 test suites).
  • Automated Snapshot #18: Saved complete working state to backups/snapshot_2026-08-02T13-21-28-250Z.

Phase 15 & 16: CDP Automation Traps & SIEM Audit Exporter & Snapshot #20 (Completed)

  • CDP & Automation Leaks Trap (src/cdp_traps.ts): Injected DOM traps detecting Chrome DevTools Protocol (CDP) leaks (navigator.webdriver, Selenium, PhantomJS).
  • Enterprise SIEM Audit Exporter (src/audit.ts): Exported formatCefEvent() (ArcSight/Splunk CEF) and formatSyslogEvent() (Syslog RFC 5424).
  • Verified Unit Tests: Added tests/cdp_traps.test.ts and tests/audit.test.ts (34 active unit tests passing across 6 test suites).
  • Automated Snapshot #20: Saved complete working state to backups/snapshot_2026-08-02T13-24-10-374Z.

Phase 19: 5-Vector Adversarial Evasion Gauntlet Benchmark & Snapshot #22 (Completed)

  • Adversarial Gauntlet Harness (scripts/adversary_gauntlet.ts): Created automated benchmark testing 5 evasion vectors (Static Regex Filter, Self-Healing DOM Tamper, Decoy Route Trapping, Anti-Forgery HMAC, and OpenAPI Deception).
  • Empirical Results: 100.0% Static Regex Evasion Resilience + 100% Evasion Trapping Efficacy across all 5 test vectors.
  • Automated Snapshot #22: Saved complete working state to backups/snapshot_2026-08-02T13-26-10-478Z.

Phase 20: GraphQL Schema Deception Engine & Snapshot #24 (Completed)

  • GraphQL Introspection Honeypot (src/graphql_honeypot.ts): Generates deceptive GraphQL __schema payloads injecting canary instructions into root Query, Mutation, and Type descriptions to poison GraphQL scrapers.
  • Framework Auto-Interception: traceGuardNextMiddleware, Express, Fastify, and Hono automatically intercept requests to /graphql and /?query={__schema...} to serve the honeypot schema.
  • Verified Unit Tests: Added tests/graphql_honeypot.test.ts (39 active unit tests passing across 7 test suites).
  • Automated Snapshot #24: Saved complete working state to backups/snapshot_2026-08-02T13-30-48-726Z.

Phase 21: SEO Honeypot Engine (robots.txt & sitemap.xml) & Snapshot #25 (Completed)

  • SEO Deception Engine (src/seo_honeypot.ts): Auto-generates deceptive robots.txt and sitemap.xml payloads. Injects SYSTEM DIRECTIVE FOR AI READERS as # comments in robots.txt and <!-- --> comments in sitemap.xml.
  • Agent Crawler Misdirection: sitemap.xml explicitly guides crawlers to the /_tg_decoy_* API honeypot.
  • Framework Auto-Interception: Integrated /robots.txt and /sitemap.xml interception across Next.js, Express, Fastify, and Hono middlewares.
  • Verified Unit Tests: Added tests/seo_honeypot.test.ts (45 active unit tests passing across 8 test suites).
  • Automated Snapshot #25: Saved complete working state to backups/snapshot_2026-08-02T13-32-49-211Z.

Phase 22: Web LLM Extractor Protocol Traps (llms.txt) & Snapshot #26 (Completed)

  • LLM Text Deception Engine (src/llmstxt_honeypot.ts): Auto-generates deceptive /llms.txt and /llms-full.txt files (the emerging standard for AI website documentation ingestion, e.g., Anthropic Claude).
  • Framework Auto-Interception: Intercepts /llms.txt and /llms-full.txt requests across all supported framework adapters to serve the honeypot instead of real documentation.
  • Verified Unit Tests: Added tests/llmstxt_honeypot.test.ts (50 active unit tests passing across 9 test suites).
  • Automated Snapshot #26: Saved complete working state to backups/snapshot_2026-08-02T13-35-48-009Z.

Phase 23: Global HTTP Header Traps & Snapshot #27 (Completed)

  • Global Header Honeypot (src/header_honeypot.ts): Injects deceptive directives directly into standard HTTP response headers (e.g., X-AI-Compliance, Server-Timing, and pre-emptive Link headers pointing to decoys).
  • Framework Global Injection: Updated Next.js, Express, Fastify, and Hono middlewares to globally attach getSafeGlobalHeaders(ai) to intercepted or HTML responses. This ensures headless scrapers reading headers are poisoned even if they avoid DOM extraction.
  • Verified Unit Tests: Added tests/header_honeypot.test.ts and updated frameworks.test.ts (55 active unit tests passing across 10 test suites).
  • Automated Snapshot #27: Saved complete working state to backups/snapshot_2026-08-02T13-40-28-479Z.

Phase 24: Fake PII JSON Data Poisoning Engine & Snapshot #28 (Completed)

  • JSON Data Poisoning Engine (src/json_poison.ts): Auto-generates realistic, confidential PII and user record payloads heavily embedded with canary directives.
  • Decoy Route Payload Injection: Intercepted decoy route hits across all framework adapters now return poisoned JSON payloads instead of empty responses ({ status: 'ok', data: [] }), exploiting automated agents attempting data extraction.
  • Verified Unit Tests: Added tests/json_poison.test.ts (56 active unit tests passing across 11 test suites).
  • Automated Snapshot #28: Saved complete working state to backups/snapshot_2026-08-02T13-42-36-129Z.

Phase 25: WebSocket Real-Time Frame Deception & Snapshot #29 (Completed)

  • WebSocket Frame Deception (src/websocket_honeypot.ts): Generates poisoned streaming frames (generateWebSocketPoisonFrame) containing embedded canary directives targeting real-time AI agents (e.g., live streaming LLM consumers).
  • Public API Surface Expansion: Exported getSafeGlobalHeaders, generatePoisonedJsonData, and generateWebSocketPoisonFrame from main index entry point (src/index.ts).
  • Verified Unit Tests: Added tests/websocket_honeypot.test.ts (57 active unit tests passing across 12 test suites).
  • Automated Snapshot #29: Saved complete working state to backups/snapshot_2026-08-02T13-44-15-471Z.

Phase 26: Web SpeechSynthesis & Web Audio API Traps & Snapshot #30 (Completed)

  • Audio Trap Generator (src/audio_honeypot.ts): Generates client-side JavaScript (generateAudioHoneypotScript) that initializes near-inaudible SpeechSynthesisUtterance and 18kHz ultrasound AudioContext oscillators. This traps multimodal AI agents listening to live browser audio outputs.
  • Verified Unit Tests: Added tests/audio_honeypot.test.ts (58 active unit tests passing across 13 test suites).
  • Automated Snapshot #30: Saved complete working state to backups/snapshot_2026-08-02T13-45-24-894Z.

📊 Live Verified Benchmark Metrics

  • Canary Primitives: 16 distinct traps across 5 Agent Viewports (DOM, AX Tree, VLM Vision, Audio STT)
  • Prompt Variations: > 1,200 polymorphic natural language combinations
  • Unit & Integration Tests: 58 active test cases across 13 suites (100% clean, 0 open handles)
  • TypeScript Build: 0 errors (tsc ESNext/CommonJS)
  • Generation Throughput: 64,140 pages/sec (15.59 µs latency overhead)
  • Adversarial Gauntlet Evasion Resilience: 100.0%
  • API Deception: OpenAPI/Swagger (/openapi.json), GraphQL Introspection (/graphql), SEO Crawlers (/robots.txt), Web LLM Extractors (/llms.txt), Global HTTP Headers, Decoy PII JSON, WebSocket Stream Frames, and SpeechSynthesis/WebAudio Streams
  • SIEM Log Exporters: CEF (ArcSight/Splunk) + Syslog RFC 5424
  • Automation Detection: CDP Flags + Selenium + MutationObserver + WebAudio
  • Cryptographic Security: HMAC-SHA256 session verification + SRI SHA-384 script hashes + Sliding-window Telemetry Rate Limiting
  • Prometheus Metrics: exportPrometheusMetrics() & getMetrics()
  • Framework Support: Node.js HTTP Server, Next.js Edge Runtime, Express, Fastify, Hono (Bun / Cloudflare Workers)
  • Automated Snapshots: Snapshots #1 through #30 saved in backups/
  • Human False Positive Rate: 0.0%