Skip to content

[Security] serve() defaults to an unauthenticated 0.0.0.0 listener; audio/video calibration fetches are unbounded #3970

Closed

Description

@Qubitium

Summary

model.serve() defaults to an open network listener, and audio/video calibration URLs do not get the fetch hardening already added for images. Audited at a16977e.

Findings

1. serve() binds 0.0.0.0 with no authentication and no request limits (Medium, CWE-1188/770)

  • Defaults: utils/openai_server.py:35 sets DEFAULT_HOST = "0.0.0.0", and models/base.py:3168 defines serve(host="0.0.0.0", port=80, api_key=None). Without a key, /v1/chat/completions is open to the network. The only mitigation is a UserWarning (openai_server.py:424-446).
  • No request limits: OpenAiRequest (218-226) does not bound max_tokens, n (passed to num_return_sequences when temperature > 0), message size, or body size. One request can pin the GPU or OOM the host.
  • No Host-header validation: DNS rebinding from a browser can reach a localhost-bound server. The client then appears as loopback, which also permits /shutdown when no key is set.
  • Fix:
    • Default to 127.0.0.1, or refuse non-loopback binds without api_key.
    • Cap max_tokens, n and the body size.
    • Validate the Host header with TrustedHost middleware.

2. Audio/video calibration URLs bypass the bounded image fetcher (Low-Medium, CWE-400/918)

  • Audio/video (utils/audio.py:86-110):
  • Image (utils/image.py):
    • Line 147 calls requests.get with redirects followed and no private or link-local address filtering, which allows blind SSRF to targets such as 169.254.169.254.
    • Lines 468-476 open arbitrary local paths and file:// URLs without the max_pixels check.
  • Fix:
    • Route audio/video fetches through the same bounded worker used for images.
    • Pass protocol_whitelist to ffmpeg/PyAV.
    • Apply max_pixels to local images.
    • Optionally block private and link-local destinations.
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions