beads/cmd
Harry Miller 7ea14b23d2
security: harden remote URL validation at config parse time (#3210)
Add strict security validation for remote URLs and remote names to prevent
injection attacks when multi-remote support lands.

Changes:
- Add ValidateRemoteURL() with control character rejection, CLI flag
  injection prevention, scheme allowlist, and per-scheme structural
  validation (host/path requirements)
- Add ValidateRemoteName() aligned with existing peer-name policy
  (letter-start, alphanumeric + hyphen/underscore, max 64 chars)
- Add MatchesRemotePattern() and ValidateRemoteURLWithPatterns() for
  enterprise lockdown via federation.allowed-remote-patterns config
- Move config validation from simple IsRemoteURL() classifier to strict
  ValidateRemoteURL() security boundary
- Add defense-in-depth validation in AddCLIRemote/RemoveCLIRemote
- Add validation at clone entry points (cache.Ensure, bootstrap)
- Tighten SCP-style URL regex to exclude control characters in path
- Add comprehensive test coverage for null bytes, control chars,
  newline injection, CLI flag injection, scheme validation, structural
  validation, remote name edge cases, and pattern matching

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-13 09:58:50 -07:00
..
bd security: harden remote URL validation at config parse time (#3210) 2026-04-13 09:58:50 -07:00