Skip to content

Security: danethomas/agentic-knowledge-store

Security

docs/SECURITY.md

SECURITY.md

Security policies, authentication patterns, and secret management for <repo_name>.

Agents read this before building anything that touches auth, user data, or external APIs. Security mistakes are the hardest to undo.


Security Principles

  1. Defense in depth — Never rely on a single security control
  2. Least privilege — Grant minimum necessary access
  3. Secure by default — New features should be locked down; explicitly open access
  4. Fail closed — When in doubt, deny access

Authentication

Approach

<auth_approach> (e.g. session-based, JWT, OAuth2, API tokens)

Implementation

  • Library/framework: <auth_library> (e.g. Devise, NextAuth, Passport, custom)
  • Session storage: <session_store> (e.g. cookie, database, Redis)
  • Token format: <token_format> (e.g. signed cookies, JWT, opaque tokens)
  • Multi-factor: <mfa_status> (e.g. supported via TOTP, not yet implemented)

Session management

  • Session timeout: <timeout>
  • Remember me: <approach>
  • Concurrent sessions: <policy> (e.g. allowed, one-at-a-time)

Authorization

Approach

<authz_approach> (e.g. policy-based, RBAC, ABAC)

Implementation

  • Library: <authz_library> (e.g. Pundit, CanCanCan, CASL, custom middleware)
  • Policy location: <policy_dir>

Rules

  • Every controller action must check authorization — no exceptions
  • Scope all queries by tenant — never allow cross-tenant data access
  • Default deny — if no policy exists, access is denied

Roles

Role Capabilities
<role> <what_they_can_do>
<role> <what_they_can_do>
<role> <what_they_can_do>

Secret Management

Where secrets live

  • Development: <dev_secrets> (e.g. .env file, Rails credentials, local vault)
  • CI: <ci_secrets> (e.g. GitHub Secrets, environment variables)
  • Production: <prod_secrets> (e.g. environment variables, AWS SSM, Vault)

Rules

  • Never commit secrets — not in code, not in config, not in comments
  • Never log secrets — mask sensitive values in log output
  • Rotate compromised secrets immediately — don't wait for the next deploy
  • Use environment variables for runtime secrets, not config files

Required environment variables

Variable Purpose Where to get it
<VAR> <purpose> <source>
<VAR> <purpose> <source>

Data Protection

Sensitive data

Data type Storage Encryption Retention
Passwords Hashed (bcrypt/argon2) At rest Until account deletion
API tokens Hashed At rest Until revoked
PII Database <encryption_approach> <retention_policy>
Payment info <storage> <encryption> <retention>

Data access rules

  • Log access to sensitive data (audit trail)
  • Minimize PII in logs — never log full names, emails, or IDs together
  • Anonymize data in non-production environments
  • Support data deletion requests (GDPR, CCPA)

Input Validation

Rules

  • Validate all input at the boundary — controllers, API handlers, form processors
  • Whitelist, don't blacklist — define what's allowed, reject everything else
  • Validate type, length, format, and range
  • Sanitize output — escape HTML, parameterize SQL, encode URLs

Common attack vectors

Attack Prevention
SQL injection Parameterized queries (never string interpolation)
XSS Output encoding, CSP headers, sanitize user HTML
CSRF Anti-CSRF tokens on all state-changing requests
Mass assignment Strong parameter filtering / allowlists
Path traversal Validate and sanitize file paths
SSRF Allowlist external URLs, don't fetch user-provided URLs blindly

API Security

Authentication

All API endpoints require authentication:

Authorization: Bearer <token>

Rate limiting

  • <rate_limit_approach> (e.g. Rack::Attack, express-rate-limit, API gateway)
  • Limits: <limits> (e.g. 100 req/min per user, 1000 req/min per IP)

CORS

  • Allowed origins: <origins>
  • Credentials: <yes_or_no>

Dependency Security

  • Audit regularly: <audit_command> (e.g. npm audit, bundle audit, pip audit)
  • Pin major versions — avoid surprise breaking changes
  • Review new dependencies — check maintenance status, download count, known vulnerabilities
  • Automated scanning: <scanning_tool> (e.g. Dependabot, Snyk, Renovate)

Reporting Vulnerabilities

If you discover a security vulnerability:

  1. Do NOT open a public issue
  2. Email <security_email> or use <reporting_mechanism>
  3. Include: description, reproduction steps, potential impact
  4. We aim to respond within <response_time>

How to Customize This File

  1. Fill in auth/authz implementation details — agents need to know which libraries to use
  2. List all required environment variables — missing secrets cause confusing failures
  3. Document rate limits and CORS — these are common sources of "it works locally but not in production"
  4. Add real code examples for your framework's auth patterns

There aren't any published security advisories