activitypub: fix possibility of spoofing by containing remote objects to the same...
authorWilliam Pitcock <nenolod@dereferenced.org>
Sat, 1 Sep 2018 23:20:02 +0000 (23:20 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sat, 1 Sep 2018 23:20:02 +0000 (23:20 +0000)
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/transmogrifier.ex

index e6c2dc9cff4a0d021f4bad5cd1892b27d79760cc..81c11dd766b94060b4f946950aedaaa169d1caf5 100644 (file)
@@ -747,6 +747,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
              "actor" => data["attributedTo"],
              "object" => data
            },
+           :ok <- Transmogrifier.contain_origin(id, params),
            {:ok, activity} <- Transmogrifier.handle_incoming(params) do
         {:ok, Object.normalize(activity.data["object"])}
       else
index 1367bc7e3b276d6a4bca2f15267a8f4cf255f3de..b75422fc64ca74b86c3568f6e8795af1083ebc48 100644 (file)
@@ -30,6 +30,20 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     actor["id"]
   end
 
+  @doc """
+  Checks that an imported AP object's actor matches the domain it came from.
+  """
+  def contain_origin(id, %{"actor" => actor}) do
+    id_uri = URI.parse(id)
+    actor_uri = URI.parse(actor)
+
+    if id_uri.host == actor_uri.host do
+      :ok
+    else
+      :error
+    end
+  end
+
   @doc """
   Modifies an incoming AP object (mastodon format) to our internal format.
   """