Skip to content

[BUG][Medium]- Reachable run endpoint can spend provider quota without caller limits #96

Open

Description

@arthurianresolve

Summary

The CLI defaults to loopback, but an operator can bind the HTTP server to a reachable address or forward it. Its /run route has no caller authentication or admission limit, and accepted requests execute with an unlimited interpreter budget. Repeated requests can consume the operator's model provider quota and reduce availability.

Affected code

Suggested resolution

  • Add an operator configurable caller authorization and per caller rate or concurrency limit for exposed service use.
  • Apply finite per request LM call, token, and deadline budgets before model execution.

Acceptance criteria

  • Unauthenticated or over quota callers cannot trigger model calls on an exposed deployment.
  • Accepted requests have bounded model use and return a controlled error when limits are reached.

Related issues

#69 covers LM retry and configuration; it does not limit who may invoke the HTTP service or how much provider quota one caller may spend.

Validation performed

Static source review of upstream main at 72b247e2bddc7337f923461fb27b4127c7d104f3. No runtime exploit or deployed service test was performed.

Tracking

  • Finding ID: csf_a68d058eb6655eefa587ec0b
  • Fingerprint: codex-security/v1:sha256:1bdbb9ac1a9868d7631651a9131730fe85719417450779d5a44b57dec1867132

AI disclosure

OpenAI Codex assisted with the static source review and organization of this issue. No code change is included.

Activity

  1. Mattbusel commented on Nov 15, 2026

    @Mattbusel

    serve passes Budget::unlimited() in both run_handler and run_traced, but Budget already has max_lm_calls, max_tokens and deadline, so most of this issue can be fixed without a new dependency. One thing to watch with the deadline: if serve builds the Budget once at startup, the absolute Instant expires a minute after boot and every later request fails. Keep the limits in App as plain values (say --max-lm-calls, --max-tokens, --timeout, with the timeout as a Duration) and build the Budget per request in both call sites, with deadline: Some(Instant::now() + timeout). Then map RunError::Budget to a 429 (or 503) in run_error, since right now everything except RunError::Input comes back as a 500, and the issue asks for a controlled error when limits are hit. With that, calls and the deadline are hard limits. max_tokens stays soft, because interp.rs checks it against tokens already spent before the next call, so a single call can go past it.

    For who can call /run and how often, a --token flag (or env var) checked against the bearer header handles auth. A tokio::sync::Semaphore in App caps runs in flight (503 when try_acquire fails), and if you want per-caller limits, a small HashMap counter keyed by the token is enough. The interpreter, router, /schema, /program and /healthz stay as they are. I wrote tokio-prompt-orchestrator, which has a rate limiter and bulkhead for this, but it pulls in far more than a CLI needs and the above covers the issue. Happy to open a PR with whatever flag names and defaults you prefer.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions