Skip to content

feat(security): OWASP AI Agent Security 2026 gap analysis (#1650)#1796

Merged
bug-ops merged 2 commits intomainfrom
security-owasp-ai-agent-securi
Mar 14, 2026
Merged

feat(security): OWASP AI Agent Security 2026 gap analysis (#1650)#1796
bug-ops merged 2 commits intomainfrom
security-owasp-ai-agent-securi

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 14, 2026

Summary

Closes #1650. Implements three security controls from the OWASP AI Agent Security Cheat Sheet (2026 edition):

  • PiiFilter — regex scrubber (email, phone, SSN, credit card) applied to tool outputs before LLM context and debug dumps. Custom patterns compiled with size_limit/dfa_size_limit to prevent ReDoS. Opt-in via [security.pii_filter].
  • MemoryWriteValidator — validates content size, forbidden patterns, and entity name PII before memory_save writes and graph extraction. Uses a PostExtractValidator callback inside the async spawn closure so zeph-memory remains free of security policy coupling. Enabled by default.
  • ToolRateLimiter — sliding-window per-category rate limiter (Shell, Web, Memory, Mcp, Other) with circuit breaker. check_batch() atomically reserves slots for parallel dispatch to prevent batch-bypass. Opt-in via [security.rate_limit].

Changes

  • crates/zeph-core/src/sanitizer/pii.rs — new PiiFilter
  • crates/zeph-core/src/sanitizer/memory_validation.rs — new MemoryWriteValidator
  • crates/zeph-core/src/agent/rate_limiter.rs — new ToolRateLimiter
  • native.rs — wires all three into tool execution pipeline; increments memory_validation_failures metric
  • init.rsstep_security() wizard step for pii_filter and rate_limiter
  • config/default.toml[security.pii_filter], [security.memory_validation], [security.rate_limit] sections
  • metrics.rsmemory_validation_failures counter

Known Limitations (documented)

  • Legacy tool execution path (non-native providers) bypasses rate limiter (tracked as follow-up)
  • PII filter runs after ContentSanitizer truncation — partial patterns near truncation boundary may pass through

Test Plan

  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace --features full -- -D warnings — clean
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 5681/5681 passed (31 new tests)

Three security controls from the OWASP AI Agent Security Cheat Sheet:

- PiiFilter: regex scrubber (email, phone, SSN, credit card) applied to
  tool outputs before LLM context and debug dumps. Custom patterns
  compiled with size/DFA limits to prevent ReDoS. Opt-in via
  [security.pii_filter] config.

- MemoryWriteValidator: validates content size, forbidden patterns, and
  entity name PII before memory_save writes and graph extraction. Uses a
  PostExtractValidator callback in the async spawn closure to keep
  zeph-memory free of security policy. Enabled by default.

- ToolRateLimiter: sliding-window per-category rate limiter (Shell, Web,
  Memory, Mcp, Other) with circuit breaker. check_batch() atomically
  reserves slots for parallel tool dispatch to prevent batch bypass.
  Opt-in via [security.rate_limit] config.

Integration: native.rs wires all three into the tool execution pipeline.
--init wizard adds step_security() for pii_filter and rate_limiter.
--migrate-config auto-adds new sections from embedded default.toml.
memory_validation_failures metric incremented on rejection.

31 new unit tests across all three modules (5650 -> 5681 total).
@github-actions github-actions bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes core zeph-core crate enhancement New feature or request size/XL Extra large PR (500+ lines) labels Mar 14, 2026
- Keep PostExtractValidator using ExtractorResult alias for
  graph::extractor::ExtractionResult (pre-upsert type for validation)
- Update extract_and_store return type to semantic::graph::ExtractionResult
  (main's change adding entity_ids for A-MEM note linking)
- Fix validation-failure early return to ExtractionResult::default()
- Merge CHANGELOG entries from both branches
@bug-ops bug-ops enabled auto-merge (squash) March 14, 2026 22:43
@bug-ops bug-ops merged commit 2795992 into main Mar 14, 2026
15 checks passed
@bug-ops bug-ops deleted the security-owasp-ai-agent-securi branch March 14, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request memory zeph-memory crate (SQLite) rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: OWASP AI Agent Security Cheat Sheet 2026 gap analysis

1 participant