Skip to content

Security

John Williams edited this page Mar 6, 2026 · 1 revision

Security

Vulnerability Reporting

If you discover a security vulnerability, please report it responsibly:

  1. Do NOT open a public issue
  2. Email: See SECURITY.md
  3. Include: description, reproduction steps, impact assessment

Security Features

Write Safety — CEP Protocol

All Google Ads write operations follow the Confirm → Execute → Post-check protocol:

  1. Confirm: Agent describes the change, shows preview, asks for explicit user approval
  2. Execute: Only runs with confirmed: true — never auto-executes
  3. Post-check: Pre-write snapshot is compared against post-write state

CORS Restrictions

  • No wildcard origins — all endpoints validate against an allowlist
  • Allowlist: googleadsagent.ai, www.googleadsagent.ai, *.pages.dev, localhost:8788
  • Middleware enforces CORS at the gateway level

Rate Limiting

Per-endpoint rate limits enforced in _middleware.js:

Endpoint Limit
/api/brain 30 req/min
/api/gads 40 req/min
/api/auth 20 req/min
/api/crux 20 req/min
Other APIs 30 req/min

Encryption

What Algorithm Where
OAuth tokens (stored) AES-256-GCM auth.js, notifications.js
BYOK API keys (client) AES-256-GCM Browser sessionStorage
Session tokens crypto.randomUUID() Server-generated

Input Validation

  • GAQL injection prevention: Date range values whitelisted
  • Path traversal: Report keys validated (blocks .., /, \)
  • URL validation: SSRF protection blocks private/internal addresses in webhooks
  • XSS prevention: HTML/SVG escaping on user-controlled chart inputs

Authentication

  • Google OAuth 2.0: SSO via Google with encrypted token storage
  • Session fixation prevention: Server generates session IDs (never accepts client-provided)
  • Open redirect protection: Return URLs validated against path allowlist
  • Sensitive data in redirects: No email/name in redirect parameters

Security Headers

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=()
Content-Security-Policy: [strict policy with explicit allowlists]

Credential Management

For the Python Agent (Path A)

  • Store credentials in .env file (gitignored)
  • Never commit credentials to version control
  • Use environment variables in production
  • Rotate refresh tokens if compromised

For Buddy (Path C — Cloudflare)

  • OAuth tokens encrypted with AES-256-GCM at rest
  • BYOK keys encrypted client-side before storage
  • Cloudflare Secrets for server-side API keys
  • Session IDs are server-generated UUIDs

Known Security Considerations

Item Risk Mitigation
Google Ads write access High CEP protocol, pre-write snapshots, rollback log
API key exposure High AES-256-GCM encryption, gitignore, Cloudflare Secrets
CORS Medium Origin allowlist, no wildcards
Rate limits Medium Per-endpoint limits, IP-based
XSS in charts Low HTML/SVG escaping
Hardcoded emails Low Operational only, no secrets

Clone this wiki locally