Skip to content

DiLoCo proxy: _token_for_local attributes a job's bearer by host+port only (port-reuse race) #97

@jdinalt

Description

@jdinalt

Found during the post-#90 review pass on PR #93. Low severity / narrow race; related to #87.

Problem

routes/diloco.py:_token_for_local matches a diloco_server JobRecord to a proxy target by (port, host) equality, treating loopback+matching-port as identity. If a DiLoCo server crashed/exited but its JobRecord hasn't transitioned out of {starting,running}, and the OS reused that port for an unrelated local listener, the proxy could attach the stale job's bearer token to a request aimed at the coincidental service.

Bounds: only fires while the record is still non-terminal (terminal records are filtered), the target must be a consented loopback base, and the leak is to a co-located service the operator already controls. So impact is limited, but the matcher trusts host:port as identity with no further binding.

Possible fixes

  • Prune / mark JobRecords promptly on process exit (overlaps with DiLoCo SSRF allowlist: prune terminated jobs' base URLs #87's allowlist pruning).
  • Bind the match to a liveness check (PID alive + owns the port) before handing out the token.
  • Or accept as documented-limitation and just tighten record status transitions.

Ref: #90, #87.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions