mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2025-04-12 14:04:08 +00:00
Merge branch 'defuse-binary' into 'develop'
Draft: Fix RCE via erlang.binary_to_term See merge request pleroma/pleroma!4203
This commit is contained in:
commit
ea0196a35e
4 changed files with 5 additions and 4 deletions
1
changelog.d/binary_to_term-rce.security
Normal file
1
changelog.d/binary_to_term-rce.security
Normal file
|
@ -0,0 +1 @@
|
|||
- Fix unsafe cast of database-stored configuration values that could lead to code execution
|
|
@ -66,7 +66,7 @@ defmodule Pleroma.Captcha do
|
|||
|
||||
with false <- is_nil(answer_data),
|
||||
{:ok, data} <- MessageEncryptor.decrypt(answer_data, secret, sign_secret),
|
||||
%{at: at, answer_data: answer_md5} <- :erlang.binary_to_term(data) do
|
||||
%{at: at, answer_data: answer_md5} <- Plug.Crypto.non_executable_binary_to_term(data) do
|
||||
{:ok, %{at: at, answer_data: answer_md5}}
|
||||
else
|
||||
_ -> {:error, :invalid_answer_data}
|
||||
|
|
|
@ -11,14 +11,14 @@ defmodule Pleroma.EctoType.Config.BinaryValue do
|
|||
if String.valid?(value) do
|
||||
{:ok, value}
|
||||
else
|
||||
{:ok, :erlang.binary_to_term(value)}
|
||||
{:ok, Plug.Crypto.non_executable_binary_to_term(value)}
|
||||
end
|
||||
end
|
||||
|
||||
def cast(value), do: {:ok, value}
|
||||
|
||||
def load(value) when is_binary(value) do
|
||||
{:ok, :erlang.binary_to_term(value)}
|
||||
{:ok, Plug.Crypto.non_executable_binary_to_term(value)}
|
||||
end
|
||||
|
||||
def dump(value) do
|
||||
|
|
|
@ -9,7 +9,7 @@ defmodule Pleroma.Workers.MailerWorker do
|
|||
def perform(%Job{args: %{"op" => "email", "encoded_email" => encoded_email, "config" => config}}) do
|
||||
encoded_email
|
||||
|> Base.decode64!()
|
||||
|> :erlang.binary_to_term()
|
||||
|> Plug.Crypto.non_executable_binary_to_term()
|
||||
|> Pleroma.Emails.Mailer.deliver(config)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue