fix(security): scope API redirects and sanitize diagnostics - #53
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 12, 2026, 11:09 PM ET / September 13, 2026, 03:09 UTC. ClawSweeper reviewWhat this changesThe PR restricts authenticated API redirects to the original origin, redacts echoed API keys while preserving error causes, and sanitizes CLI parser diagnostics. Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this is useful security hardening absent from current main and v0.4.9. No blocking correctness defect was found, and collaborator-authored work is protected from automatic closure. Priority: P2 Review scores
Verification
How this fits togethergoplaces exposes Google Places and Routes through a Go library and CLI. Its shared HTTP client sends authenticated requests, while the CLI turns parsing and API failures into terminal diagnostics. flowchart TD
A[CLI arguments] --> B[Argument parser]
B --> C[Shared API client]
D[Endpoint and API key] --> C
C --> E{Redirect stays within origin?}
E -->|Yes| F[API response]
E -->|No| G[Redacted error]
B -->|Invalid arguments| H[Sanitized terminal diagnostic]
G --> H
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep credentials scoped to the configured origin, with the documented direct-endpoint migration for proxies and sanitized diagnostics that retain inspectable error causes. Do we have a high-confidence way to reproduce the issue? Yes: a controlled redirect between two origins, an upstream error echoing the configured key, and invalid CLI arguments containing controls exercise the identified paths. Current-main source supports these mechanisms; this review did not execute them. Is this the best way to solve the issue? Yes: the shared request boundary and existing terminal sanitizer are the narrowest owners, and the documented security restriction is consistent with VISION.md. AGENTS.md: not found in the target repository. Codex review notes: model internal, reasoning medium; reviewed against d7a83610f74e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
The standard HTTP client forwards custom
X-Goog-Api-Keyheaders across redirects, and upstream/transport errors can echo that key. Parser diagnostics also bypassed the CLI's terminal sanitizer. These are separate entry paths into the same credential and diagnostic boundaries.Apply a per-request redirect policy that preserves the caller's HTTP client, custom stop policy, and default ten-hop limit while rejecting changes of scheme, hostname, or effective port. Centralize request-error formatting to redact the configured key while retaining error causes for
errors.Is/errors.As; redact APIError bodies as well. Route parser diagnostics through the existing sanitizer. The client notes and Unreleased changelog document the security tightening.Regression tests first failed on the old code for cross-origin forwarding, API/transport/invalid-URL key exposure, and parser control sequences. They now pass alongside same-origin/default-port behavior, custom stop policies, redirect limits, and typed error propagation. Go 1.26.8 race tests, lint, and 91.8% coverage pass. Isolated Codex autoreview is scoped-clean at P0–P2.
Built-CLI proof uses two local synthetic HTTP servers:
[REDACTED]; HTTP status and exit 1 retainedThe full 21-case built-CLI comparison for all eight commands remains byte-identical to baseline (requests, output, exit codes), SHA-256
043a9aa35c7e9a159a75b42afed4e4d56bf606646ee1352e3a22e8af3185eefe. All fixture values are synthetic; no live Google credentials are used.