Skip to content

[Bug]: Local provider warning requires allowPrivateNetwork but the option is unavailable #175

Description

@lidge-jun

Summary

A provider configured with a localhost baseUrl cannot be saved or used because OpenCodex reports:

provider 9rtr baseUrl points to a localhost destination; set allowPrivateNetwork:true only for intentionally local/self-hosted providers

The message instructs the user to enable allowPrivateNetwork: true, but the provider dashboard has no such option. Adding the field manually to the provider configuration also does not make the configuration usable, so the warning currently points to an unavailable escape hatch.

Expected behavior:

  • The dashboard exposes an explicit, clearly warned opt-in for intentionally local/self-hosted providers; or
  • The supported config schema accepts and persists allowPrivateNetwork: true, with the error message naming the exact config location.

Reproduction

  1. Run OpenCodex and open the dashboard.
  2. Edit provider 9rtr.
  3. Set its baseUrl to a redacted local endpoint such as http://localhost:<port>/v1.
  4. Save or validate the provider.
  5. Observe the allowPrivateNetwork:true error.
  6. Check the provider form: no corresponding setting is available.
  7. Try adding allowPrivateNetwork: true manually to the provider config: it is not usable through the current config path.

Logs and screenshots

provider 9rtr baseUrl points to a localhost destination; set allowPrivateNetwork:true only for intentionally local/self-hosted providers

Additional runtime/config-path evidence will be attached after local log inspection.

Area

GUI dashboard

Version

  • Installed CLI: opencodex 2.7.27
  • Local checkout: 25f21128 on dev

OS

macOS 27.0 (26A5378n)

Config shape

{
  "provider": "9rtr",
  "baseUrl": "http://localhost:<port>/v1",
  "allowPrivateNetwork": true
}

The endpoint and credentials are redacted.

Checks

  • I searched existing issues and docs first.
  • I removed secrets, tokens, and personal data from logs and screenshots.

Activity

  1. lidge-jun commented on Jul 20, 2026

    @lidge-jun
    OwnerAuthor

    Local RCA on opencodex 2.7.27 / 25f21128:

    Confirmed cause

    This is a GUI/API integration gap around the SSRF hardening, not an upstream connectivity failure.

    1. The backend flag is real and is provider-scoped:

      • src/config.ts:290-295 accepts providers.<name>.allowPrivateNetwork.
      • src/lib/destination-policy.ts:113-120 bypasses the private/local destination rejection when that exact field is true.
      • src/server/management-api.ts:506-513 even returns the persisted value.
    2. The Add Provider GUI cannot send it:

      • gui/src/provider-payload.ts:1-8 has no form field for it.
      • gui/src/provider-payload.ts:27-52 has no payload property or builder branch for it.
      • Therefore a custom localhost provider always reaches POST /api/providers without the required opt-in.
    3. The apparent manual fallback in the classic dashboard is nonfunctional:

      • The visible JSON editor saves with PUT /api/config at gui/src/pages/Providers.tsx:310-324.
      • The server unconditionally returns 405 for that endpoint at src/server/management-api.ts:225-226.
      • The UI reduces that response to a generic “save failed”, hiding the actual 405 message.
    4. Existing-provider PATCH cannot set it either:

      • The field mask in src/server/management-api.ts:600-650 does not include allowPrivateNetwork.
      • A flag-only PATCH reaches src/server/management-api.ts:652 and returns “no recognized fields to update”.

    Live non-mutating probes

    POST /api/providers (custom localhost provider, no flag)
    HTTP 400
    {"error":"provider issue-175-local-probe baseUrl points to a localhost destination; set allowPrivateNetwork:true only for intentionally local/self-hosted providers"}
    
    PUT /api/config
    HTTP 405
    {"error":"Full config PUT is disabled. Use /api/providers POST for provider changes."}
    
    PATCH /api/providers?name=zenmux
    {"allowPrivateNetwork":true}
    HTTP 400
    {"error":"no recognized fields to update"}
    

    The rejected probe did not persist, and the existing provider was unchanged.

    Verification

    bun test tests/server-auth.test.ts --test-name-pattern 'private-network destinations'
    
    2 pass
    54 filtered out
    0 fail
    

    The passing tests at tests/server-auth.test.ts:664-721 prove the backend rejects the same request without the flag and accepts/persists it when the POST payload includes the flag. That rules out the config schema as the cause.

    Logging gap

    ~/.opencodex/service.log contains none of the validation errors above and was not modified by the probes. These management API 4xx responses are returned directly to the browser, so “check the service log” currently gives no evidence for this failure.

    Suggested acceptance criteria

    • Add an explicit, warned “Allow local/private network” opt-in to the custom provider form.
    • Include allowPrivateNetwork in the POST payload and existing-provider PATCH field mask.
    • Surface the server response body on JSON-editor save failures, or remove/replace the editor because full config PUT is intentionally disabled.
    • Add GUI payload tests covering localhost both without and with explicit opt-in.
  2. lidge-jun commented on Jul 20, 2026

    @lidge-jun
    OwnerAuthor

    Additional supported-path check:

    ocx provider add issue-175-cli-probe \
      --adapter openai-chat \
      --base-url http://localhost:1/v1 \
      --allow-private-network \
      --json
    
    Unknown flag(s): --allow-private-network
    Usage: ocx provider add <name> [--adapter <adapter>] [--base-url <url>] [--api-key <key>] [--default-model <model>] [--set-default] [--force] [--json] [--sync]
    

    The rejected CLI probe made no config change. A repository search also finds no user-facing documentation for either allowPrivateNetwork or an --allow-private-network flag.

    So the supported input surfaces are currently closed in all four places:

    • Add Provider form omits the field.
    • Existing-provider PATCH rejects it as unrecognized.
    • Classic JSON editor calls the intentionally disabled full-config PUT.
    • CLI has no equivalent flag.

    The only current manual workaround is editing the on-disk provider object at ~/.opencodex/config.json -> providers.<name>.allowPrivateNetwork and restarting the proxy, because the running server loads the file at startup and does not watch it for changes.

  3. lidge-jun commented on Jul 21, 2026

    @lidge-jun
    OwnerAuthor

    Fixed on dev (commit f2fa0c2). The allowPrivateNetwork checkbox is now exposed in the provider dashboard for built-in presets (not just custom/local providers), with the existing security warning displayed next to the opt-in. Will ship in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions