WebFingerTest: Add test for more webfinger spoofing.
This commit is contained in:
parent
45af48520b
commit
f70d1a436b
1 changed files with 40 additions and 0 deletions
|
|
@ -254,6 +254,46 @@ defmodule Pleroma.Web.WebFingerTest do
|
||||||
assert {:error, _} = WebFinger.finger("graf@fba.ryona.agency")
|
assert {:error, _} = WebFinger.finger("graf@fba.ryona.agency")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "prevents forgeries even when the spoofed subject exists on the target domain" do
|
||||||
|
Tesla.Mock.mock(fn
|
||||||
|
%{url: url}
|
||||||
|
when url in [
|
||||||
|
"https://attacker.example/.well-known/host-meta",
|
||||||
|
"https://victim.example/.well-known/host-meta"
|
||||||
|
] ->
|
||||||
|
{:ok, %Tesla.Env{status: 404}}
|
||||||
|
|
||||||
|
%{
|
||||||
|
url:
|
||||||
|
"https://attacker.example/.well-known/webfinger?resource=acct:alice@attacker.example"
|
||||||
|
} ->
|
||||||
|
Tesla.Mock.json(%{
|
||||||
|
"subject" => "acct:alice@victim.example",
|
||||||
|
"links" => [
|
||||||
|
%{
|
||||||
|
"rel" => "self",
|
||||||
|
"type" => "application/activity+json",
|
||||||
|
"href" => "https://attacker.example/users/alice"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
%{url: "https://victim.example/.well-known/webfinger?resource=acct:alice@victim.example"} ->
|
||||||
|
Tesla.Mock.json(%{
|
||||||
|
"subject" => "acct:alice@victim.example",
|
||||||
|
"links" => [
|
||||||
|
%{
|
||||||
|
"rel" => "self",
|
||||||
|
"type" => "application/activity+json",
|
||||||
|
"href" => "https://victim.example/users/alice"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
end)
|
||||||
|
|
||||||
|
assert {:error, _} = WebFinger.finger("alice@attacker.example")
|
||||||
|
end
|
||||||
|
|
||||||
test "works for correctly set up split-domain instances implementing host-meta redirect" do
|
test "works for correctly set up split-domain instances implementing host-meta redirect" do
|
||||||
{:ok, _data} = WebFinger.finger("a@pleroma.example")
|
{:ok, _data} = WebFinger.finger("a@pleroma.example")
|
||||||
{:ok, _data} = WebFinger.finger("a@sub.pleroma.example")
|
{:ok, _data} = WebFinger.finger("a@sub.pleroma.example")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue