diff --git a/.credo.exs b/.credo.exs index 70c94369..a849a04d 100644 --- a/.credo.exs +++ b/.credo.exs @@ -182,12 +182,12 @@ |> String.replace_trailing(".ex", "_test.exs") end ]}, - # {Jump.CredoChecks.ForbiddenFunction, - # [ - # functions: [ - # {:erlang, :binary_to_term, "Use Plug.Crypto.non_executable_binary_to_term/2 instead."} - # ] - # ]}, + {Jump.CredoChecks.ForbiddenFunction, + [ + functions: [ + {:erlang, :binary_to_term, "Use Plug.Crypto.non_executable_binary_to_term/2 instead."} + ] + ]}, {Jump.CredoChecks.LiveViewFormCanBeRehydrated}, {Jump.CredoChecks.UndeclaredExternalResource}, {Jump.CredoChecks.PreferChangeOverUpDownMigrations, [start_after: "20250101000000"]}, diff --git a/lib/snmpkit/snmp_lib/cache.ex b/lib/snmpkit/snmp_lib/cache.ex index c4f4017d..6742c049 100644 --- a/lib/snmpkit/snmp_lib/cache.ex +++ b/lib/snmpkit/snmp_lib/cache.ex @@ -584,10 +584,10 @@ defmodule SnmpKit.SnmpLib.Cache do end defp decompress_value(compressed_value) do - # Use safe: true to prevent arbitrary code execution via malicious cached terms + # Use safe deserialization to prevent arbitrary code execution via malicious cached terms compressed_value |> :zlib.uncompress() - |> :erlang.binary_to_term([:safe]) + |> Plug.Crypto.non_executable_binary_to_term([:safe]) end # Pattern matching and invalidation diff --git a/lib/snmpkit/snmp_lib/mib/compiler.ex b/lib/snmpkit/snmp_lib/mib/compiler.ex index ece5dd9e..5ab0d309 100644 --- a/lib/snmpkit/snmp_lib/mib/compiler.ex +++ b/lib/snmpkit/snmp_lib/mib/compiler.ex @@ -215,8 +215,8 @@ defmodule SnmpKit.SnmpLib.MIB.Compiler do def load_compiled(compiled_path) do case File.read(compiled_path) do {:ok, binary_data} -> - # Use safe: true to prevent arbitrary code execution via malicious terms - case :erlang.binary_to_term(binary_data, [:safe]) do + # Use safe deserialization to prevent arbitrary code execution via malicious terms + case Plug.Crypto.non_executable_binary_to_term(binary_data, [:safe]) do %{__type__: :compiled_mib} = compiled -> {:ok, compiled}