Skip to Content
Bryfo Docsv0.2.1

Bidirectional PII Engine & Defense-in-Depth Security

7-validator PII masking, Magpie tool loop, netguard anti-SSRF/anti-rebinding, SandboxMediaCSP, and KeyRing cryptography.

Bidirectional AI Privacy Pipeline (internal/privacy)

  1. 7 Deterministic Validators + User Overlay: Detects EMAIL, PHONE, GB 11643-1999 checksum ID_CARD, Luhn BANK_CARD, context-gated OTP, SECRET credentials (API tokens, JWTs, DB URIs, PEM keys), and IP, layered with append-only UserPrivacyOverlay rules.
  2. Encrypted Session Maps & 6-Round Tool Loop: Token mappings persist inside AES-256-GCM encrypted Valkey keys (privacy:sess:*). During multi-step tool calling, Bryfo executes UnmaskJSON locally for database queries and MaskJSON before returning tool results to the model, rehydrating final SSE tokens via digit-boundary-guarded StreamUnmasker.

Socket-Level SSRF & Media Sandboxing

  • netguard.NewSafeDialContext: Pre-resolves DNS, blocks loopback, RFC 1918, CGNAT (100.64.0.0/10), link-local / cloud metadata (169.254.169.254, fd00:ec2::254), IPv6 ULA (fc00::/7), and multicast CIDRs, dials the validated literal IP directly to defeat DNS rebinding, and re-validates up to 3 HTTP redirects. User BYOK endpoints unconditionally enforce ForcePublicOnly: true.
  • SandboxMediaCSP & PDF.js Canvas: Attachments, BIMI icons, and HTML receipts emit Content-Security-Policy: sandbox; default-src 'none'; img-src 'self' data:; style-src 'unsafe-inline' and X-Content-Type-Options: nosniff. SVG, HTML, XML, JS, and PDF force Content-Disposition: attachment (RFC 5987), while PDFs preview inside a Web Worker <canvas>.

Cryptography, Auth & Immutable Audit Logs

  • Argon2id + AES-256-GCM KeyRing: Passwords hash with Argon2id; third-party credentials encrypt with versioned CREDENTIALS_ENCRYPTION_KEYS and rotate online via bryfo rotate-keys.
  • TOTP Replay Guard & Trusted Proxies: Stages pending TOTP secrets in Valkey (10m), blocks 6-digit code replay in totp:used (120s), parses X-Forwarded-For right-to-left only from TRUSTED_PROXIES, and protects security_audit_logs with PostgreSQL DELETE/TRUNCATE triggers.

On this page