Skip to content

fix(erlpack): reject unsafe terms in untrusted payloads - #15

Merged
smocherla-brex merged 1 commit into
elixir-2025from
fix/erlpack-safe-decoding
Oct 19, 2026
Merged

smocherla-brex merged 1 commit into
elixir-2025from
fix/erlpack-safe-decoding

Conversation

@smocherla-brex

Copy link
Copy Markdown

Context

Backport the protection for GHSA-grp7-v8xh-rj7h to elixir-2025. The current Erlpack decoder accepts new atoms and executable terms from message bodies.

What Changed

  • Decode with binary_to_term/2 and [:safe] to prevent new atoms.
  • Recursively reject functions, pids, ports, and references in tuples, map keys/values, structs, and list heads/tails. Unlike the upstream traversal, handle improper lists explicitly.
  • Document that incoming atoms must already exist on the receiver. Applications must load message modules before decoding; callers sending runtime handles or functions will now be rejected.

Adapted from the upstream fix.

Validation

  • Local Elixir 1.18.5 / OTP 25: the five new codec tests produced three failures on base 107ec659ce3de687db071635f7fbe3fb8b17f192 (new atoms, runtime terms, nested functions accepted), then passed with this patch. See test/grpc/codec/erlpack_test.exs for the exact cases.
  • mix test: 5 doctests, 72 tests, 0 failures, including existing gRPC integration tests.
  • Formatting checks for both changed files and git diff --check passed.

Older CI runtime combinations and downstream Brex service compatibility have not been verified locally. This PR does not update downstream lockfiles or deploy the fix.

@smocherla-brex
smocherla-brex marked this pull request as ready for review October 19, 2026 16:06

@bjhaid bjhaid left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THanks!

@greptile-apps

greptile-apps Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Disclaimer: This comment was generated by AI. Please give it feedback using 👍 / 👎 emoji to help it learn

RetriggerView in GreptileConfidence Score: 5/5

[Critical impact] The PR appears safe to merge.

Summary

Hardens GRPC.Codec.Erlpack.decode/2 against unsafe incoming terms.

  • Erlpack decoding rejects new atoms and nested runtime handles.

smocherla-brex explicitly identifies rejection of new atoms and runtime handles as intentional. The module documentation explains the requirement to load message modules before decoding.

Reviews (1) · Last reviewed commit: "fix(erlpack): reject unsafe terms in unt..." · Reviewed by Greptile

@smocherla-brex
smocherla-brex merged commit 1afc714 into elixir-2025 Oct 19, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants