[backend/federation] Reject activities with mismatching activity & actor id hosts

This commit is contained in:
Laura Hausmann 2024-02-26 22:34:55 +01:00
parent 489941adcc
commit c30dac0210
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -50,6 +50,9 @@ public class ActivityHandlerService(
if (resolvedActor.Id != authFetchUserId && authFetchUserId != null) if (resolvedActor.Id != authFetchUserId && authFetchUserId != null)
throw GracefulException throw GracefulException
.UnprocessableEntity($"Authorized fetch user id {authFetchUserId} doesn't match resolved actor id {resolvedActor.Id}"); .UnprocessableEntity($"Authorized fetch user id {authFetchUserId} doesn't match resolved actor id {resolvedActor.Id}");
if (new Uri(activity.Actor.Id).Host != new Uri(activity.Id).Host)
throw GracefulException
.UnprocessableEntity($"Activity identifier ({activity.Actor.Id}) host doesn't match actor identifier ({activity.Id}) host");
if (resolvedActor.Host == null || resolvedActor.Uri == null) if (resolvedActor.Host == null || resolvedActor.Uri == null)
throw new Exception("resolvedActor.Host and resolvedActor.Uri must not be null at this stage"); throw new Exception("resolvedActor.Host and resolvedActor.Uri must not be null at this stage");