Skip to content

fix(backend): tighten service-creation input validation#612

Merged
kaiweijw merged 2 commits intomainfrom
fix/service-creation-validation
May 4, 2026
Merged

fix(backend): tighten service-creation input validation#612
kaiweijw merged 2 commits intomainfrom
fix/service-creation-validation

Conversation

@kaiweijw
Copy link
Copy Markdown
Collaborator

@kaiweijw kaiweijw commented May 4, 2026

Summary

  • [Bug] [CLI Wizard] Hosted custom services allow unsafe or ambiguous endpoint URLs #597 (SSRF / ambiguous URL): Add validate_user_endpoint_url(url, hosted_mode, field) that always rejects query / fragment / userinfo / non-http(s) / over-2048-char URLs, and additionally rejects loopback / private / link-local / CGNAT / cloud-metadata targets via DNS resolution when running in production. Wired into POST /keys (catalog override + custom HTTP), PUT /keys/{id}, and PUT /endpoints/{id}. Skipped when the route is node-managed (the URL goes to the node agent, never to NyxID's outbound HTTP client).
  • [Bug] [CLI Wizard] Header-auth custom service can be created with an empty auth key name #598 (empty auth_key_name): Extend the existing body-only check to cover header, query, and path methods as well (the proxy needs a non-empty key name for all four to inject the credential into a named field). Centralized the rule in auth_method_requires_key_name / auth_key_name_required_message helpers and applied it in create_user_service, update_user_service, validate_update_inputs, admin POST /services, and unified_key_service::create_key (the last one rejects before any partial endpoint / api-key rows are written, avoiding orphans).

closes #597
closes #598

Notes for reviewers

  • The strict (hosted-mode) URL guard delegates to the existing validate_public_http_url helper, which already does the DNS-resolution / IP-class checks and is tested.
  • create_key gained a new hosted_mode: bool parameter populated from state.config.is_production(). In-tree tests pass false (so they continue exercising the lax dev path).
  • The auth_key_name check now uses .trim().is_empty(), so a whitespace-only auth_key_name: " " is rejected too.

Test plan

@kaiweijw kaiweijw merged commit 94344e6 into main May 4, 2026
10 checks passed
@kaiweijw kaiweijw deleted the fix/service-creation-validation branch May 4, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant