summaryrefslogtreecommitdiff
path: root/internal/federation/authenticate.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-02-06 12:59:37 +0100
committerLibravatar GitHub <noreply@github.com>2024-02-06 12:59:37 +0100
commitb6fe8e7a5b68c5d12b23056b6654157c739c7376 (patch)
tree6a30d3e67ddba70608e5cb0d25bb759877a3bb1c /internal/federation/authenticate.go
parent[feature] serdes for moved/also_known_as (#2600) (diff)
downloadgotosocial-b6fe8e7a5b68c5d12b23056b6654157c739c7376.tar.xz
[bugfix] Ensure activities sender always = activities actor (#2608)
Diffstat (limited to 'internal/federation/authenticate.go')
-rw-r--r--internal/federation/authenticate.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/federation/authenticate.go b/internal/federation/authenticate.go
index 6899e5ad3..59281fa65 100644
--- a/internal/federation/authenticate.go
+++ b/internal/federation/authenticate.go
@@ -214,6 +214,17 @@ func (f *Federator) AuthenticateFederatedRequest(ctx context.Context, requestedU
err := gtserror.Newf("error dereferencing account %s: %w", pubKeyAuth.OwnerURI, err)
return nil, gtserror.NewErrorInternalError(err)
}
+
+ // Catch a possible (but very rare) race condition where
+ // we've fetched a key, then fetched the Actor who owns the
+ // key, but the Key of the Actor has changed in the meantime.
+ if !pubKeyAuth.Owner.PublicKey.Equal(pubKeyAuth.FetchedPubKey) {
+ err := gtserror.Newf(
+ "key mismatch: fetched key %s does not match pubkey of fetched Actor %s",
+ pubKeyID, pubKeyAuth.Owner.URI,
+ )
+ return nil, gtserror.NewErrorUnauthorized(err)
+ }
}
if !pubKeyAuth.Owner.SuspendedAt.IsZero() {