Bug description
The heatmap exporter in profiling.sampling reads source files named in a profile unconditionally via Path(filename).read_text(). It does not check whether the path is a regular file or whether the file size is reasonable.
When replaying a binary profile, a filename pointing to a device file (e.g. /dev/zero) causes unbounded memory growth. An oversized file has the same effect.
The fix adds an is_file() guard and a 10 MB size cap before reading, consistent with the binary reader hardening in gh-152718.
CPython versions tested on
main
Operating systems tested on
macOS
Linked PRs
Bug description
The heatmap exporter in
profiling.samplingreads source files named in a profile unconditionally viaPath(filename).read_text(). It does not check whether the path is a regular file or whether the file size is reasonable.When replaying a binary profile, a filename pointing to a device file (e.g.
/dev/zero) causes unbounded memory growth. An oversized file has the same effect.The fix adds an
is_file()guard and a 10 MB size cap before reading, consistent with the binary reader hardening in gh-152718.CPython versions tested on
main
Operating systems tested on
macOS
Linked PRs