Skip to content

fix: restrict /force-election to localhost callers - #71

Merged
micahkendall merged 2 commits into
mainfrom
codex/fix-unauthenticated-/force-election-vulnerability
May 5, 2026
Merged

fix: restrict /force-election to localhost callers#71
micahkendall merged 2 commits into
mainfrom
codex/fix-unauthenticated-/force-election-vulnerability

Conversation

@micahkendall

Copy link
Copy Markdown
Member

Motivation

  • The health server exposed an unauthenticated POST /force-election endpoint bound to 0.0.0.0 that could invoke assume_leadership with an attacker-chosen term and destabilize Raft availability.

Description

  • Add ConnectInfo<SocketAddr> and import SocketAddr so the handler can inspect the caller's socket address.
  • Use app.into_make_service_with_connect_info::<SocketAddr>() when serving the Axum router to populate connection info for handlers.
  • Modify force_election to reject non-loopback callers with 403 FORBIDDEN and a warning log while preserving existing behavior for local callers.
  • Keep all existing request/response semantics and call into raft_client.assume_leadership(req.term) for allowed requests.

Testing

  • Ran cargo check against the workspace and it succeeded.

Codex Task

@micahkendall
micahkendall merged commit ba3f550 into main May 5, 2026
8 checks passed
@micahkendall
micahkendall deleted the codex/fix-unauthenticated-/force-election-vulnerability branch May 5, 2026 00:18
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.

2 participants