Skip to content

feat(distributed): enforce registration token for worker file transfer#10183

Merged
mudler merged 1 commit into
masterfrom
harden/f-002-file-transfer-auth
Jun 5, 2026
Merged

feat(distributed): enforce registration token for worker file transfer#10183
mudler merged 1 commit into
masterfrom
harden/f-002-file-transfer-auth

Conversation

@richiejp
Copy link
Copy Markdown
Collaborator

@richiejp richiejp commented Jun 5, 2026

Description

If no registration token is set then anyone on the local network can access the worker. This is fine if it's intential, but accidentally failing to set the token is not reported anywhere. So this adds a warning and a setting that causes startup to fail if no token is set.

Notes for Reviewers

The worker HTTP file-transfer server is authenticated by the registration
token via checkBearerToken, which fails open on an empty token: every
/v1/files, /v1/files-list and /v1/backend-logs request is then served
unauthenticated, granting read/write to the worker's models/staging/data
directories. The fail-open was also silent (the only auth log sat on the
unreachable reject branch), and the worker process never runs
DistributedConfig.Validate(), so the existing frontend warning did not
cover the component that exposes the server.

Mirror the NatsRequireAuth pattern: keep anonymous as the default but make
it loud and opt-in enforceable.

  • Log a prominent warning when the file-transfer server starts tokenless.
  • Add LOCALAI_REGISTRATION_REQUIRE_AUTH: DistributedConfig.Validate() errors
    on an empty token (frontend) and the worker refuses to start (fail-fast,
    before registration), so production can fail closed. Also satisfies the
    F-003 suggestion to fail Validate() on distributed + empty token.
  • Add LOCALAI_DISTRIBUTED_REQUIRE_AUTH umbrella switch implying both
    RegistrationRequireAuth and NatsRequireAuth — one production knob locking
    down the registration/file-transfer layer and the NATS bus together; the
    granular flags remain available as single-layer overrides. Wired into the
    frontend, supervisor worker, and agent worker (vLLM worker has neither a
    NATS connection nor a file-transfer server, so it is left untouched).
  • Document in distributed-mode.md (warning callout + flag tables).

Assisted-by: Claude:claude-opus-4-8 [Claude Code]
Signed-off-by: Richard Palethorpe io@richiejp.com

Signed commits

  • Yes, I signed my commits.

The worker HTTP file-transfer server is authenticated by the registration
token via checkBearerToken, which fails open on an empty token: every
/v1/files, /v1/files-list and /v1/backend-logs request is then served
unauthenticated, granting read/write to the worker's models/staging/data
directories. The fail-open was also silent (the only auth log sat on the
unreachable reject branch), and the worker process never runs
DistributedConfig.Validate(), so the existing frontend warning did not
cover the component that exposes the server.

Mirror the NatsRequireAuth pattern: keep anonymous as the default but make
it loud and opt-in enforceable.

- Log a prominent warning when the file-transfer server starts tokenless.
- Add LOCALAI_REGISTRATION_REQUIRE_AUTH: DistributedConfig.Validate() errors
  on an empty token (frontend) and the worker refuses to start (fail-fast,
  before registration), so production can fail closed. Also satisfies the
  F-003 suggestion to fail Validate() on distributed + empty token.
- Add LOCALAI_DISTRIBUTED_REQUIRE_AUTH umbrella switch implying both
  RegistrationRequireAuth and NatsRequireAuth — one production knob locking
  down the registration/file-transfer layer and the NATS bus together; the
  granular flags remain available as single-layer overrides. Wired into the
  frontend, supervisor worker, and agent worker (vLLM worker has neither a
  NATS connection nor a file-transfer server, so it is left untouched).
- Document in distributed-mode.md (warning callout + flag tables).

Assisted-by: Claude:claude-opus-4-8 [Claude Code]
Signed-off-by: Richard Palethorpe <io@richiejp.com>
@mudler mudler merged commit 7338571 into master Jun 5, 2026
58 checks passed
@mudler mudler deleted the harden/f-002-file-transfer-auth branch June 5, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants