Skip to content

🔒 [P1] Add input validation and size limits to server API #132

Closed

Description

@ajianaz

Problem

The server API (uteke-serve) and core library accept arbitrarily large content with no validation:

  • remember() and import() accept unlimited content size
  • import() reads entire file/stdin into a single String (unbounded)
  • Namespace strings, tags, and metadata have no sanitization (no length limits, no path traversal checks)
  • No input validation exists anywhere in the codebase

Security Impact

  • DoS: Single huge memory could exhaust RAM/disk
  • Path traversal: Crafted namespace/tag could write outside intended directory
  • Data corruption: Malformed metadata could break SQLite queries

Proposed Fix

  1. Content size limits: Max 1MB per memory, max 100MB for import (batch)
  2. Length limits: Namespace max 128 chars, tags max 64 chars each, max 50 tags per memory
  3. Character validation: Namespace/tags alphanumeric + hyphen/underscore only
  4. Metadata validation: Max 10KB, max depth 5 levels
  5. Streaming import: Read import file line-by-line instead of all-at-once

Acceptance Criteria

  • remember() rejects content > 1MB with clear error
  • import() streams file, rejects individual lines > 1MB
  • Namespace/tag validation enforced with clear error messages
  • Metadata size and depth limited
  • Tests for all validation boundaries
  • Server endpoints enforce same limits

Effort: ~1-2 days

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority:highscope:corescope:integrationsecurity

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions