Skip to content

Commit 2c79509

Browse files
feldlanodan
authored andcommitted
Resolve information disclosure vulnerability through emoji pack archive download endpoint
The pack name has been sanitized so an attacker cannot upload a media file called pack.json with their own handcrafted list of emoji files as arbitrary files on the filesystem and then call the emoji pack archive download endpoint with a pack name crafted to the location of the media file they uploaded which tricks Pleroma into generating a zip file of the target files the attacker wants to download. The attack only works if the Pleroma instance does not have the AnonymizeFilename upload filter enabled, which is currently the default. Reported by: [email protected]
1 parent 819fccb commit 2c79509

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Emoji pack loader sanitizes pack names

lib/pleroma/emoji/pack.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ defmodule Pleroma.Emoji.Pack do
285285

286286
@spec load_pack(String.t()) :: {:ok, t()} | {:error, :file.posix()}
287287
def load_pack(name) do
288+
name = Path.basename(name)
288289
pack_file = Path.join([emoji_path(), name, "pack.json"])
289290

290291
with {:ok, _} <- File.stat(pack_file),

test/pleroma/emoji/pack_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,8 @@ defmodule Pleroma.Emoji.PackTest do
9090

9191
assert updated_pack.files_count == 1
9292
end
93+
94+
test "load_pack/1 ignores path traversal in a forged pack name", %{pack: pack} do
95+
assert {:ok, ^pack} = Pack.load_pack("../../../../../dump_pack")
96+
end
9397
end

0 commit comments

Comments
 (0)