aup-learning-cloud icon indicating copy to clipboard operation
aup-learning-cloud copied to clipboard

Restrict ValidateRepo API to allowed git providers

Open kerwtsai-amd opened this issue 8 months ago • 1 comments

Summary

ValidateRepoHandler accepts arbitrary user-supplied URLs and performs remote validation (including dulwich ls_remote) without applying the same provider whitelist checks used by the spawner path.

Why this matters

This broad URL reachability can be abused for SSRF-style probing/internal network access attempts from the hub context.

Current behavior

  • ValidateRepoHandler validates arbitrary URL input.
  • It can attempt outbound requests to non-approved hosts.
  • Spawner path has whitelist checks, but validation API does not enforce equivalent constraints.

Expected behavior

Repository validation should enforce scheme and hostname restrictions identical (or stricter) to spawn-time validation.

Proposed fix

  • Require http/https scheme.
  • Enforce host whitelist via gitClone.allowedProviders (same matching rule as spawner).
  • Return clear 4xx responses for disallowed hosts.
  • Add tests for allowed/disallowed host cases.

Acceptance criteria

  • Validation API rejects non-whitelisted providers with 4xx.
  • Allowed providers continue to validate normally.
  • Tests cover whitelist enforcement.

kerwtsai-amd avatar Apr 01 '26 17:04 kerwtsai-amd

A fix is now open in PR #62.\n\nThis adds shared repository URL validation/sanitization and enforces the configured allowed git providers before remote validation runs, so disallowed hosts are rejected locally instead of reaching downstream validation paths.

MioYuuIH avatar Apr 10 '26 05:04 MioYuuIH