{"affected":[{"ranges":[{"events":[{"introduced":"9622ab2132e2501ee5769357a914dcc6635e515c"},{"fixed":"322b04488d9445c7258abce3e7f3bc79aa7c45d8"}],"repo":"https://github.com/erlang/otp","type":"GIT"}]}],"aliases":["GHSA-2pqq-qr2r-wgcc","CVE-2026-125658"],"credits":[{"name":"Sam Baud","type":"FINDER"},{"name":"Sam Baud","type":"REPORTER"},{"name":"Jonatan Männchen / EEF","type":"COORDINATOR"}],"database_specific":{"capec_ids":["CAPEC-153"],"cpe_ids":["cpe:2.3:a:erlang:erlang\\/otp:*:*:*:*:*:*:*:*"],"cwe_ids":["CWE-416"]},"details":"## Summary\n\nUse After Free vulnerability in Erlang/OTP erts allows an attacker who can create a file system entry with a chosen name to hang or abort the Erlang VM on macOS.\n\nOn macOS, the VM decodes file names with `do_utf8_to_list_normalize` in `erts/emulator/beam/erl_unicode.c`. When a name starts with a combining mark, such as U+0301, `cleanup_norm` builds the first list cells but does not return its advanced heap pointer. The caller then releases the heap words that hold those cells, and the returned list refers to released process heap memory that the next allocation overwrites. `file:list_dir/1`, `file:list_dir_all/1`, `file:del_dir_r/1` and `filelib:wildcard/1` on a directory that contains such a name do not return, and the VM does not stop on SIGTERM. `file:read_link/1` on a symbolic link with such a target aborts the VM with `size_object: bad tag`. Only loss of availability was demonstrated.\n\nThis issue affects OTP from OTP 17.0 before OTP 27.3.4.20, OTP 28.5.0.9, and OTP 29.1.3, corresponding to erts from 6.0 before 15.2.7.15, 16.4.0.8, and 17.1.2.\n\n## Details\n\n**1. Decoder entry**\n\n`prim_file:list_dir/1` and `prim_file:read_link/1` decode each native name with `prim_file:internal_native2name/1`. Its implementation, `prim_file_internal_native2name_1` in `erts/emulator/beam/erl_unicode.c`, calls `do_utf8_to_list_normalize` when the file name encoding is `ERL_FILENAME_UTF8_MAC`. `erts_init_sys_common_misc` selects that encoding only on macOS.\n\n**2. Missing heap pointer write-back**\n\n`do_utf8_to_list_normalize` reserves `2 * num` heap words with `HAlloc`, reads the name from its end, and keeps code points that can compose (U+0300 and above) in `savepoints`. If saved points remain when it reaches the start of the name, it calls `cleanup_norm(&hp, savepoints, numpoints, &ret)` and then `HRelease(p, hp_end, hp)`. `cleanup_norm` copies `*hpp` to a local `hp`, builds one cons cell per saved point, and writes back only `*retp`. The caller's `hp` still points below the new cells, so `HRelease` returns them to the process heap. `handle_potential_norm` has the same structure and does write `*hpp = hp`.\n\n**3. Effect**\n\nThe returned list starts in released heap memory. The next allocation of the process overwrites the cells. `erlang:display/1` shows a header word in place of the first code point. When the term is copied, for example in the reply of the file server, `size_object_x` either loops without end on a cyclic term or aborts the VM with `size_object: bad tag`.\n\n## Proof of concept\n\n1. On macOS, create a directory with one file whose name starts with U+0301: `mkdir d && printf x > \"d/$(printf '\\314\\201b')\"`.\n2. Run `erl -noshell -eval 'io:format(\"~w~n\", [file:list_dir(\"d\")]), halt().'`. The command prints nothing and does not return. The VM does not stop on SIGTERM. The expected output is `{ok,[[769,98]]}`.\n3. Run `erl -noshell -eval 'erlang:display(prim_file:internal_native2name(<<204,129,$b>>)), halt().'`. The output starts with `[<cp/header:0x00000000000000c0>`. The expected output is `[769,98]`.\n4. Create a symbolic link with the same name as its target (`ln -s \"$(printf '\\314\\201b')\" link`) and call `file:read_link(\"link\")`. The VM aborts with `size_object: bad tag for 0x80`.\n\n## Impact\n\nAn attacker who can create a file, directory or symbolic link target with a chosen name in a location that an Erlang node on macOS reads can make the VM hang or abort. The hung VM does not stop on SIGTERM.\n\n## Workarounds\n\nStart the VM with the `+fnl` flag, for example through `ERL_FLAGS`. The VM then does not decode or normalize file names. This changes the result of file name functions for names outside ASCII: the VM returns each byte of the name as one Latin-1 character.\n\n## Configurations\n\nThe node runs on macOS with the default `utf8` file name encoding, and reads a directory listing or a symbolic link target that contains a name an attacker chose. Linux and other platforms do not normalize file names and are not affected.","id":"EEF-CVE-2026-125658","modified":"2026-11-24T15:28:22.287589Z","published":"2026-11-24T15:28:21.735Z","references":[{"type":"ADVISORY","url":"https://github.com/erlang/otp/security/advisories/GHSA-2pqq-qr2r-wgcc"},{"type":"WEB","url":"https://cna.erlef.org/cves/CVE-2026-125658.html"},{"type":"WEB","url":"https://www.erlang.org/doc/system/versions.html#order-of-versions"},{"type":"WEB","url":"https://github.com/erlang/otp/commit/9622ab2132e2501ee5769357a914dcc6635e515c"},{"type":"FIX","url":"https://github.com/erlang/otp/commit/322b04488d9445c7258abce3e7f3bc79aa7c45d8"}],"related":[],"schema_version":"1.8.0","severity":[{"score":"CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","source":"CNA","type":"CVSS_V4"}],"summary":"Use after free in erts file name normalization on macOS","upstream":[]}