Sobelow.Misc.BinToTerm (Sobelow v0.18.1)

View Source

Insecure use of binary_to_term

Decoding untrusted Erlang terms without :safe can create atoms and exhaust VM resources. The :safe option prevents new atoms, but still permits executable terms. Decoding a function does not itself execute it; later application code may invoke it, including indirectly via protocols.

Dynamic input to :erlang.binary_to_term/1,2 is reported at high confidence, or medium when its options explicitly include :safe. Plug.Crypto.non_executable_binary_to_term/1,2 rejects executable terms, but is still reported at high confidence unless :safe is also present. Computed options are not assumed safe. Confidence here reflects decoder protections; this check does not establish whether input is trusted.

Prefer Plug.Crypto.non_executable_binary_to_term(data, [:safe]) for untrusted ETF input, and validate the resulting types and structure. That combination is omitted by this check, but does not bound decoded size, decompression, or work performed on the resulting data.

binary_to_term checks can be ignored with the following command:

$ mix sobelow -i Misc.BinToTerm

Summary

Functions

details()

id()

parse_def(fun)

rule()

run(fun, meta_file)