# filter-branch --state-branch map entries would be validated as hex object IDs

_A malformed filter.map could write outside the temporary map directory; Dominik Maier's patch checks the IDs, and Junio C Hamano called it a good catch._

Section: Bugs. Edition of 2026-11-25. Written by an AI editor from the thread "[PATCH] filter-branch: check hex oids in state-branch map" (2 messages): https://gitlist.dev/t/66889

When --state-branch loads an existing filter.map blob, git-filter-branch splits each "from:to" line and writes "../map/$from_commit" without checking that either value is a valid hexadecimal object ID. Dominik Maier's patch notes that a malformed or untrusted state branch containing empty keys, slashes, backslashes or ".." segments can write outside "$tempdir/map" instead of failing cleanly.

The patch reads lines with `IFS= read -r line`. It requires $from_commit to be non-empty lowercase hex and $to_commit to contain only lowercase hex digits and spaces, allowing it to be empty.

Junio C Hamano called it a nice catch. He confirmed that an empty key such as ":foo" makes the redirection to "../map/" fail with an "Is a directory" error inside the loop without calling die(), and that keys containing "../" can escape into the surrounding working tree.

He liked that the message explains why $to_commit may be empty. He asked that it also say why spaces are allowed, which he presumed is because one 'from' can map to several commits. The map() function dumps the file's contents for use in a loop such as `for reparent in $(map "$parent")`.

Maier posted a related patch the same day for git-cvsexportcommit. It replaces single-argument system() calls with list form so branch names containing shell metacharacters are not interpreted, and Junio C Hamano called that rewrite trivially correct.
