Skip to content

Require operator token for gRPC pause and resume#5

Merged
homerquan merged 1 commit into
mainfrom
codex/propose-fix-for-grpc-vulnerability
May 18, 2026
Merged

Require operator token for gRPC pause and resume#5
homerquan merged 1 commit into
mainfrom
codex/propose-fix-for-grpc-vulnerability

Conversation

@homerquan

Copy link
Copy Markdown
Collaborator

Motivation

  • The PauseJob and ResumeJob gRPC RPCs previously allowed unauthenticated clients to change job lifecycle state, creating an availability/control vulnerability.
  • The change adds a minimal operator-auth guard to ensure only callers possessing an operator token can invoke these state-changing RPCs.

Description

  • Add MirrorNeuron.Grpc.Auth which reads MN_GRPC_OPERATOR_TOKEN and provides authorize_operator!/1 and authorized?/2 to validate bearer or MirrorNeuron-specific token headers with a constant-time compare.
  • Gate PauseJob and ResumeJob handlers by calling MirrorNeuron.Grpc.Auth.authorize_operator!(stream) before invoking MirrorNeuron.pause/1 or MirrorNeuron.resume/1.
  • Update README.md to document the new MN_GRPC_OPERATOR_TOKEN configuration key.
  • Add focused unit tests in tests/unit/grpc/auth_test.exs that exercise header extraction (including adapter/http request headers) and token matching behavior.

Testing

  • Ran mix format --check-formatted, which succeeded.
  • Ran the new tests directly with elixir -r lib/mirror_neuron_grpc/auth.ex -e 'ExUnit.start()' tests/unit/grpc/auth_test.exs, and they completed with 0 failures.
  • mix test could not be run to completion in this environment because Hex/dependency fetches failed (network/proxy prevented mix local.hex / dependency installation).

Codex Task

@homerquan homerquan merged commit c4b024d into main May 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant