79% vs 51%: independent neobanks lag on app security. Read the report

Deep Dive

Deep Dive

Flop Pagination Cursor RCE in Elixir Apps (CVE-2026-130411)

Flop decodes pagination cursors into Erlang terms and accepts structs, letting a crafted cursor call a function in an Elixir app; fixed in 0.29.2.

TL;DR

  • Flop turns the after and before page parameters into Erlang terms, and its sanitizer accepts structs, so a crafted cursor can reach a function call inside the application's virtual machine. The Erlang Ecosystem Foundation published CVE-2026-130411 on 2026-11-24.
  • Elixir and Phoenix applications that pass request parameters to Flop with cursor pagination enabled are exposed. The demonstrated chain also needs Ecto, DBConnection and an order field of Ecto type :naive_datetime.
  • The EEF rates the flaw CVSS v4.0 9.2 Critical. No exploitation is known, and the CVE is not in CISA KEV as of 2026-11-28.
  • Upgrade to 0.26.7, 0.27.3, 0.28.1 or 0.29.2. If you cannot, disable cursor pagination; see "How do I fix it?".

Am I affected?

An application is exposed when it passes client-controlled parameters to Flop and leaves cursor pagination enabled, which is the default. All of these conditions must hold for the published chain:

  • The application passes request parameters to Flop, for example with Flop.validate_and_run/3 or Flop.validate/2, and accepts the after or before cursor parameter.
  • Cursor pagination is allowed. Flop allows every pagination type by default, including :first and :last.
  • The application has Ecto and DBConnection loaded, which the published gadget chain needs.
  • The order field used for the cursor has the Ecto type :naive_datetime, the type used in the published chain.
  • The atoms the gadget names, such as Ecto.Query.DynamicExpr and DBConnection.Stream, exist in the running VM. They do when the application uses those libraries.

The flaw does not need authentication or user interaction. The cursor is a request parameter, so anyone who can reach the endpoint can send one. The published chain ends in a function call, not a prebuilt command, so the practical impact depends on the modules and arguments the application has loaded.

Branch Affected versions Fixed version
0.29.x 0.29.0 to 0.29.1 0.29.2
0.28.x 0.28.0 0.28.1
0.27.x 0.27.0 to 0.27.2 0.27.3
0.26.x and earlier 0.8.0 to 0.26.6 0.26.7

Flop records 45,442 downloads in the last week and 3,295,721 all-time on Hex, checked on 2026-11-28. Its GitHub repository has 820 stars.

Cursor pagination shipped in 0.8.0, which is where the affected range starts. Releases before 0.8.0 do not have the vulnerable code.

Check the resolved version in every lockfile, then the version the application has loaded:

grep -r '"flop"' --include=mix.lock .
mix deps | grep flop
mix run -e 'IO.puts(Application.spec(:flop, :vsn))'

The first command covers an umbrella project with several lockfiles. The second prints the version Mix resolved. The third prints the version the running BEAM virtual machine loaded, which is the one that matters at request time.

How do I fix it?

Upgrade Flop to the fixed release for the branch you run, then confirm the lockfile and the running application use it.

  1. Raise the requirement in mix.exs if it pins an exact version. Use the fixed release for your branch, for example {:flop, "~> 0.29.2"} or {:flop, "~> 0.26.7"}.
  2. Update the dependency and rebuild: mix deps.update flop, then mix deps.get and mix compile.
  3. Confirm the resolved version with mix deps | grep flop, then deploy the rebuilt release. Updating a dependency in a built release does not change the running node until you deploy it.

If you cannot upgrade now, disable cursor pagination. Set it globally in the application environment:

# config/config.exs
config :flop, pagination_types: [:page, :offset]

Or pass the option to the calls that accept untrusted parameters:

Flop.validate_and_run(Post, params,
  for: Post,
  pagination_types: [:page, :offset]
)

The workaround removes the after and before path through Flop.validate_and_run/3. It does not change Flop.Cursor.decode/2, so any code that calls that function directly on untrusted input stays exposed until you upgrade. Page and offset pagination continue to work.

What is the root cause?

Flop.Cursor.decode/2 accepts structs because a struct is a map, and the decoder only rejects functions, process identifiers (PIDs), ports and references.

Flop is an Elixir library for filtering, ordering and pagination with Ecto. Cursor pagination encodes the last row's order values as an Erlang term, adds Base64, and puts the result in the after or before parameter.

The decoder in lib/flop/cursor.ex at 0.29.1 does this:

def decode(cursor, opts \\ []) when is_binary(cursor) do
  with :ok <- validate_size(cursor, opts),
       {:ok, binary} <- Base.url_decode64(cursor),
       :ok <- validate_uncompressed(binary),
       {:ok, term} <- safe_binary_to_term(binary) do
    sanitize(term)
    if is_map(term) && term |> Map.keys() |> Enum.all?(&is_atom/1),
      do: {:ok, term},
      else: :error
  end
rescue
  _e in RuntimeError -> :error
end

defp safe_binary_to_term(term) do
  {:ok, :erlang.binary_to_term(term, [:safe])}
rescue
  _e in ArgumentError -> :error
end

defp sanitize(term)
     when is_atom(term) or is_number(term) or is_binary(term) do
  term
end

defp sanitize([]), do: []
defp sanitize([h | t]), do: [sanitize(h) | sanitize(t)]

defp sanitize(%{} = term) do
  :maps.fold(
    fn key, value, acc ->
      sanitize(key)
      sanitize(value)
      acc
    end,
    term,
    term
  )
end

defp sanitize(term) when is_tuple(term) do
  term
  |> Tuple.to_list()
  |> sanitize()
end

defp sanitize(_) do
  raise "invalid cursor value"
end

The [:safe] option stops binary_to_term from creating new atoms and from returning functions, PIDs, ports and references. It does not stop maps or structs.

The sanitize/1 clauses walk lists, tuples and maps. For a map, :maps.fold/3 calls sanitize/1 on each key and value for its side effect, then returns the original term as the accumulator. Nothing checks the :__struct__ key that marks a struct, so a map that carries it passes unchanged. The same list clause also accepts an improper list, a second gap the fix closes.

After decoding, Flop casts each cursor value against the Ecto type of its order field. For a :naive_datetime field, the cast accepts a DateTime struct and does not check the type of the struct's fields. A DateTime whose year field holds another struct therefore passes validation.

How is it exploited?

  1. Build a map for the order field, inserted_at, whose value is a DateTime struct with an Ecto.Query.DynamicExpr struct in its year field.
  2. Give the DynamicExpr a binding field that holds a DBConnection.Stream. Put the function call in the stream's :log option, as {:proc_lib, :init_p, [[], IO, :inspect, [:hi]]}.
  3. Encode the map with :erlang.term_to_binary/1, then Base64 with Base.url_encode64/1, and send it as the after parameter.
  4. Flop decodes the term, accepts the nested structs, and casts the DateTime against the :naive_datetime order field.
  5. Ecto passes the value as a pinned query parameter. cast_param/3 fails and builds an Ecto.Query.CastError, which inspects the value.
  6. Inspecting the DateTime raises on the non-integer year. The resulting Inspect.Error inspects the function arguments, including the nested Ecto.Query.DynamicExpr.
  7. The Inspect implementation of Ecto.Query.DynamicExpr maps over its binding. That binding is a DBConnection.Stream, whose Enumerable implementation calls DBConnection.reduce/3.
  8. DBConnection.log/5 applies the {module, function, arguments} tuple in the :log option, with the log entry as the first argument. With {:proc_lib, :init_p, ...}, :proc_lib.init_p/5 calls the chosen function with the chosen arguments.

The published proof of concept (PoC) builds this value and sends it through Flop.validate_and_run!/3:

datetime = %DateTime{
  year: %Ecto.Query.DynamicExpr{
    binding: %DBConnection.Stream{
      conn: %DBConnection{},
      query: %Postgrex.Result{},
      params: [],
      opts: [log: {:proc_lib, :init_p, [[], IO, :inspect, [:hi]]}]
    }
  }
}

The PoC uses IO.inspect(:hi), so the process prints :hi before the cast error. The EEF record describes the result as code execution on the server. Turning the call into a useful action depends on which functions and arguments exist in the VM.

How does the attack flow?

One Base64 cursor travels from the after parameter through Flop's decoder and Ecto's error inspection to a function call in the application's VM.

flowchart LR A["after or before
Base64 Erlang term"] --> B["Flop.Cursor.decode/2
binary_to_term :safe"] B --> C["sanitize/1
accepts structs"] C --> D["Ecto cast fails
CastError inspects value"] D --> E["DynamicExpr Inspect
maps over binding"] E --> F["DBConnection.Stream
reduce runs :log"] F --> G["Chosen function runs
in the app VM"]

What can an attacker do?

A successful request calls an exported function of a loaded module with attacker-chosen arguments, inside the application's VM. The EEF rates the flaw CVSS v4.0 9.2 Critical, with the vector CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N. It rates the impact on confidentiality, integrity and availability as High for the vulnerable system.

All of these conditions apply:

  • The attacker can reach an endpoint that passes the after or before parameter to Flop.
  • Cursor pagination is enabled.
  • Ecto and DBConnection are loaded.
  • The order field has the Ecto type :naive_datetime for the demonstrated chain.
  • The module, function and argument atoms the attacker names already exist in the VM.

The PoC only demonstrates IO.inspect(:hi), so its visible effect is a printed value. A reachable function that writes files, runs commands, reads secrets or changes data would turn the call into that action. The [:safe] option prevents the attacker from creating new atoms or loading new modules, so the gadget must use what the application already has.

The CVE record does not claim that every Ecto type is exploitable. It describes the :naive_datetime chain, and the fix covers the decoder for every type.

Why does the fix work?

Release 0.29.2 rejects any decoded map that carries :__struct__, rejects improper lists, and stops encoding structs. The cast then validates each cursor value instead of letting Ecto inspect a bad one.

-  defp sanitize([h | t]), do: [sanitize(h) | sanitize(t)]
+  defp sanitize([h | t]) when is_list(t), do: [sanitize(h) | sanitize(t)]
+
+  defp sanitize(term) when is_map_key(term, :__struct__) do
+    raise "invalid cursor value"
+  end

   defp sanitize(%{} = term) do

The new clause runs before the general map clause, so a struct raises and decode/2 returns :error. The list clause now rejects an improper list instead of walking it.

Encoding also changed:

   def encode(key) do
-    Base.url_encode64(:erlang.term_to_binary(key, minor_version: 2))
+    key
+    |> to_plain()
+    |> :erlang.term_to_binary(minor_version: 2)
+    |> Base.url_encode64()
   end

to_plain/1 converts Date, DateTime, Duration, NaiveDateTime and Time values to ISO 8601 strings, Decimal values to strings, and other structs to maps of their fields. A legitimate cursor no longer carries a struct, and an old cursor that does is rejected.

The query path now casts each value before Ecto sees it:

-      cursor_value = Map.get(decoded_cursor, field)
-      {direction, field, cursor_value, field_info}
+      value = Map.get(decoded_cursor, field)
+
+      {direction, field, cast_cursor_value!(field_info, value, cursor),
+       field_info}

cast_cursor_value!/3 calls Flop.Validation.cast_cursor_value/2 and raises Flop.InvalidCursorError when the cast fails. The malformed value never reaches the Ecto error path that inspects it.

The fix is complete for this gadget: no struct survives decoding, so the nested DynamicExpr never reaches Ecto. It is a breaking change for cursors created before 0.29.2 that contained structs. The changelog says those cursors are rejected, and a custom Ecto type that returns a struct must accept a map in cast/1 or use cursor_value_func.

How do I check if I was compromised?

Start with the application logs, because the gadget fires while Ecto builds a cast error. Search for the struct names that appear in the inspected value:

grep -E 'Ecto\.Query\.CastError|Ecto\.Query\.DynamicExpr|DBConnection\.Stream' log/*.log
grep -Eo '(after|before)=[A-Za-z0-9_%=-]{40,}' log/access.log

A CastError whose inspected value contains DynamicExpr or DBConnection.Stream is a strong lead. Long Base64 values in after or before are also worth checking: a Flop cursor is an Erlang external term, and Base64 of the term usually starts with g3Q. Legitimate cursors have the same shape, so a hit is a lead, not proof.

No indicators of compromise have been published. Check which version each service runs, and treat a service that runs an affected release with cursor pagination enabled as exposed. An attempt that failed before the function call may leave only the cast error, and one that succeeded may leave nothing specific.

Timeline

The vulnerable decoder shipped in 2020 and the fix shipped on one day in 2026.

Six years from the cursor decoder to the fixed releases
Figure 1: From the introduction of cursor pagination on 2020-08-06 to the fixed releases and CVE publication on 2026-11-24. Source: Flop commits and Hex release dates, checked November 28, 2026

  • 2020-08-06: The cursor pagination code, including Flop.Cursor.decode/2, is introduced in commit 4535794.
  • 2026-11-24: The four fix commits merge between 10:30 and 13:37 UTC.
  • 2026-11-24: Hex publishes 0.29.2 at 14:51 UTC, 0.28.1 at 14:55, 0.27.3 at 14:55 and 0.26.7 at 14:56.
  • 2026-11-24: The EEF publishes CVE-2026-130411 at 14:58 UTC.

FAQ

Does this affect every Flop application?

No. It needs an endpoint that passes after or before to Flop with cursor pagination enabled. The published chain also needs Ecto, DBConnection and a :naive_datetime order field. An application that only uses page or offset pagination does not reach the decoder through Flop.

Is it exploited in the wild?

No public exploitation report exists as of 2026-11-28, and the CVE is not in CISA KEV. The EEF published a proof of concept and a technical analysis with the record.

Does disabling cursor pagination fix it?

It removes the reachable path through Flop.validate_and_run/3, which is the path the PoC uses. It does not fix Flop.Cursor.decode/2 itself, so upgrade if any code calls that function on untrusted input.

Why is the score 9.2 Critical when the PoC only prints a value?

The score rates the demonstrated function call and its potential effect on confidentiality, integrity and availability. The PoC stops at IO.inspect(:hi) to prove the call. A reachable function with a stronger effect would do more.

Will old cursors keep working after the upgrade?

Cursors that contain structs are rejected. Date, time and decimal values are now encoded as strings, and other structs as maps, so cursor pagination keeps working when the Ecto type can cast those values. A custom type that cannot must accept a map in cast/1 or use cursor_value_func.

Which fixed release should I install?

The latest patch on your branch: 0.29.2, 0.28.1, 0.27.3 or 0.26.7. All four carry the same reject-structs fix.

Find vulnerable Flop versions with Ostorlab

Ostorlab's software composition analysis and SBOM tooling inventories the Elixir dependencies in your applications, so you can find the services that still resolve an affected Flop release: https://www.ostorlab.co/product/sca_sbom

References

  • Erlang Ecosystem Foundation, "CVE-2026-130411: Code execution through deserialization of pagination cursors in flop", https://cna.erlef.org/cves/CVE-2026-130411.html (checked November 28, 2026)
  • CVE record for CVE-2026-130411, https://www.cve.org/CVERecord?id=CVE-2026-130411 (checked November 28, 2026)
  • OSV record EEF-CVE-2026-130411, https://osv.dev/vulnerability/EEF-CVE-2026-130411 (checked November 28, 2026)
  • Flop fix commit 6382b93, https://github.com/woylie/flop/commit/6382b932ce85872b5dcce78e45731dc9ce3be438 (checked November 28, 2026)
  • Flop fix commit 82e9399, https://github.com/woylie/flop/commit/82e9399a9db6798bbb3bc976969e5aa0f3b0f7a7 (checked November 28, 2026)
  • Flop fix commit 93fabac, https://github.com/woylie/flop/commit/93fabace5c9cc419fc638d657828feec71b6a6ab (checked November 28, 2026)
  • Flop fix commit bfd9ee2, https://github.com/woylie/flop/commit/bfd9ee23db39b9df6233d085606c19b27b586100 (checked November 28, 2026)
  • Flop introducing commit 4535794, https://github.com/woylie/flop/commit/4535794baa135c8cccca7bb1ada4b64c91afc81d (checked November 28, 2026)
  • Flop package on Hex, including weekly and all-time downloads, https://hex.pm/packages/flop (checked November 28, 2026)
  • Flop 0.29.2 release, https://hex.pm/api/packages/flop/releases/0.29.2 (checked November 28, 2026)
  • Flop repository, https://github.com/woylie/flop (checked November 28, 2026)
  • CISA, Known Exploited Vulnerabilities catalog, https://www.cisa.gov/known-exploited-vulnerabilities-catalog (checked November 28, 2026)

Free scan

Scan your own app for free

or book a demo

Keep reading

Related articles

Browse the blog