The vulnerability lies in the way Keras handles the extraction of tar archives, specifically through the keras.utils.get_file API. The root cause is the use of tarfile.extractall() without proper safeguards against path traversal attacks. The provided patch addresses this issue in two key locations.
First, in keras/src/utils/file_utils.py, the extract_archive function, which is called by get_file, was modified. Previously, it used a custom function filter_safe_paths to sanitize archive members, but this was found to be insufficient. The patch replaces this logic with a call to a new, more secure function, extract_open_archive. This new function leverages the filter='data' parameter in tarfile.extractall for Python versions where it's available (3.12+), which provides a robust defense against path traversal.
Second, a similar vulnerability was found and fixed in keras/src/saving/saving_lib.py. The __init__ method of the ArchiveReader class also called extractall() directly without any filtering. This has been replaced with a call to the same secure extract_open_archive function.
Therefore, any runtime profile during the exploitation of this vulnerability would show calls to keras.utils.file_utils.extract_archive or keras.saving.saving_lib.ArchiveReader.__init__ as these are the functions that contained the unsafe extraction logic.