You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document provides a security assurance case for Open Code Review (OCR), justifying that security requirements are met through secure design principles and countermeasures against common implementation weaknesses.
Threat Model
System Description
OCR is a CLI tool that:
Reads git diff output from a local repository.
Sends code diffs to a configured LLM provider (OpenAI, Anthropic, etc.) via HTTPS.
Receives review comments from the LLM and presents them to the user.
Optionally serves a local web viewer for browsing review session history.
Actors
Actor
Trust Level
Local user
Trusted — invokes the CLI with full control over configuration
LLM provider API
Semi-trusted — responses are validated before use
Git repository
Semi-trusted — diffs may contain adversarial content
CGO_ENABLED=0 eliminates C library attack surface. The CLI requires no elevated permissions. No network listeners except the opt-in viewer.
Fail-safe defaults
API keys must be explicitly provided via environment variables. The viewer binds to localhost by default; non-loopback hosts require explicit allowlisting.
Complete mediation
Every viewer HTTP request is checked against the host allowlist (internal/viewer/hostguard.go). Every file path from agent tools is validated against the repository root (internal/tool/filereader.go:98, internal/pathutil/path.go).
Economy of mechanism
External process execution is limited to git with hardcoded subcommands — no shell invocation, no arbitrary command execution.
Open design
Fully open-source (Apache-2.0). Security relies on TLS, not obscurity.
Separation of privilege
API authentication (keys) is separated from configuration (files). The viewer's host guard is a distinct middleware layer.
Least common mechanism
Each review session writes to its own JSONL file. No shared state between sessions.
Psychological acceptability
Security defaults (HTTPS, localhost binding, host allowlist) require no user configuration. Overrides (OCR_VIEWER_ALLOWED_HOSTS) are explicit and documented.
API keys are read exclusively from environment variables, never embedded in code or config files, never logged.
Mitigated
A05:2021 Security Misconfiguration
Secure defaults: localhost-only viewer, HTTPS-only API calls, CGO_ENABLED=0. The go vet and govulncheck tools run in CI.
Mitigated
A06:2021 Vulnerable Components (CWE-1104)
Dependabot monitors Go modules and GitHub Actions. govulncheck runs on every push/PR. Dependencies are locked via go.sum.
Mitigated
A08:2021 Software Integrity
Release binaries include SHA-256 checksums. Release tags are cryptographically signed (SSH). CGO_ENABLED=0 produces static binaries with no external shared library dependencies.
Mitigated
A09:2021 Logging Failures
API keys and sensitive headers are excluded from all log output and telemetry.
Mitigated
A10:2021 SSRF
The CLI only makes outbound requests to user-configured LLM API endpoints. The viewer does not make outbound requests.
Not applicable
CWE-416 Use After Free / CWE-787 Out-of-bounds Write
Go is a memory-safe language. CGO_ENABLED=0 eliminates C memory risks. Race detector (-race) runs in CI.