Require operator token for gRPC pause and resume#7
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 574a6ac2d2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| def pause_job(request, _stream) do | ||
| def pause_job(request, stream) do | ||
| MirrorNeuron.Grpc.Auth.authorize_operator!(stream) |
There was a problem hiding this comment.
Protect all destructive gRPC controls with the token
When MN_GRPC_OPERATOR_TOKEN is set and the gRPC listener is reachable, this guard only protects PauseJob/ResumeJob; in the same server CancelJob and ClearJobs still call MirrorNeuron.cancel/1 and Monitor.clear_jobs/0 without authorize_operator!/1, and ClusterServer.remove_node/1 is likewise unguarded. Those RPCs are at least as destructive as pause/resume, so the new token gives operators a false sense that control RPCs are protected while unauthenticated clients can still cancel or delete job state.
Useful? React with 👍 / 👎.
Motivation
PauseJobandResumeJobgRPC RPCs previously allowed unauthenticated clients to change job lifecycle state, creating an availability/control vulnerability.Description
MirrorNeuron.Grpc.Authwhich readsMN_GRPC_OPERATOR_TOKENand providesauthorize_operator!/1andauthorized?/2to validate bearer or MirrorNeuron-specific token headers with a constant-time compare.PauseJobandResumeJobhandlers by callingMirrorNeuron.Grpc.Auth.authorize_operator!(stream)before invokingMirrorNeuron.pause/1orMirrorNeuron.resume/1.README.mdto document the newMN_GRPC_OPERATOR_TOKENconfiguration key.tests/unit/grpc/auth_test.exsthat exercise header extraction (including adapter/http request headers) and token matching behavior.Testing
mix format --check-formatted, which succeeded.elixir -r lib/mirror_neuron_grpc/auth.ex -e 'ExUnit.start()' tests/unit/grpc/auth_test.exs, and they completed with0 failures.mix testcould not be run to completion in this environment because Hex/dependency fetches failed (network/proxy preventedmix local.hex/ dependency installation).Codex Task