bug: Health tracking could temporarily get stuck if a remote's signing key expires during a backoff period #2318

Open
opened 2026-10-03 19:54:50 +00:00 by nex · 1 comment
Owner

What is the bug?

Continuwuity's remote health tracking intercepts any federation request that is made to a remote that may be unhealthy (in backoff). It resets this status under any of two conditions:

  1. We successfully make a successful request to the unhealthy server after the backoff period has elapsed
  2. The unhealthy server sends an authenticated server-to-server request

However, the universal request interception is a detriment here. If a server is in a backoff period at the time of making an authenticated federation request, AND the latest copy of the signing key we had for it expired BEFORE the request was made, the attempt to fetch fresh signing keys from the remote will fail, as it will be intercepted by health tracking.

This does not result in a lockup or anything, but does mean that such remotes will have to wait out the entire backoff period before being able to federate with us again, rather than breaking the backoff period early by making a successful request

Steps to reproduce

  1. Send a successful request to b.example from a.example, signed with a key that expires in 30 seconds
  2. Take b.example offline
  3. Attempt to fetch data from b.example on a.example (e.g. fetching profiles). This causes a.example to actively back off from b.example
  4. Bring b.example back online after a few minutes (to ensure enough of a backoff window has accrued on a.example)
  5. Attempt to fetch a profile on a.example from b.example
  6. a.example will attempt to fetch a fresh key set for b.example, but the request will be bounced by health tracking
  7. The request from B to A fails (this may also cause B to back off on A!)

Server name and version

N/A (d83da6ada7)

Additional context

Lines 136 to 169 in d83da6a
let key = services
.server_keys
.get_single_verify_key(&output.origin, &output.key, min_valid_ts)
.await
.ok_or_else(|| {
err!(Request(Unauthorized(debug_warn!(
origin=%output.origin,
"Unable to acquire your signing key (ID: {})",
output.key
))))
})?;
let keys: PubKeys = [(output.key.to_string(), key.key)].into();
let keys: PubKeyMap = [(output.origin.as_str().into(), keys)].into();
match output.verify_http_request(request, destination, &keys) {
| Ok(()) => {
if services
.moderation
.is_remote_server_forbidden(&output.origin)
{
return Err!(Request(Forbidden(
"You are blocked from federating with this server."
)));
}
// Ping the server as healthy
if services.federation.mark_healthy(&output.origin) {
services
.sending
.flush_servers([output.origin.clone()].stream())
.await
.ok();
}

### What is the bug? Continuwuity's remote health tracking intercepts any federation request that is made to a remote that may be unhealthy (in backoff). It resets this status under any of two conditions: 1. We successfully make a successful request to the unhealthy server after the backoff period has elapsed 2. The unhealthy server sends an authenticated server-to-server request However, the universal request interception is a detriment here. If a server is in a backoff period at the time of making an authenticated federation request, AND the latest copy of the signing key we had for it expired BEFORE the request was made, the attempt to fetch fresh signing keys from the remote will *fail*, as it will be intercepted by health tracking. This does not result in a lockup or anything, but does mean that such remotes will have to wait out the *entire* backoff period before being able to federate with us again, rather than breaking the backoff period early by making a successful request ### Steps to reproduce 1. Send a successful request to `b.example` from `a.example`, signed with a key that expires in 30 seconds 2. Take `b.example` offline 3. Attempt to fetch data from `b.example` on `a.example` (e.g. fetching profiles). This causes `a.example` to actively back off from `b.example` 4. Bring `b.example` back online after a few minutes (to ensure enough of a backoff window has accrued on `a.example`) 5. Attempt to fetch a profile on `a.example` from `b.example` 6. `a.example` will attempt to fetch a fresh key set for `b.example`, but the request will be bounced by health tracking 7. The request from B to A fails (this may also cause B to back off on A!) ### Server name and version N/A (d83da6ada74c6d85e1e8779fd64b043170e7ec15) ### Additional context https://forgejo.ellis.link/continuwuation/continuwuity/src/commit/d83da6ada74c6d85e1e8779fd64b043170e7ec15/src/api/router/auth.rs#L136-L169
nex self-assigned this 2026-10-03 19:54:50 +00:00
Author
Owner

speak of the devil: chaos-ex.chat just migrated from Synapse to Continuwuity, and found that no servers were willing to federate with them due to the need to acquire the new signing key, but being unable to due to the backoff accrued during the migration period.

speak of the devil: chaos-ex.chat just migrated from Synapse to Continuwuity, and found that no servers were willing to federate with them due to the need to acquire the new signing key, but being unable to due to the backoff accrued during the migration period.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
continuwuation/continuwuity#2318
No description provided.