GHSA-f42x-p2mx-hm8r Penelope unsafe tar extraction allows arbitrary local file write via crafted session archive
SummaryPenelope versions prior to 0.19.3 extracted tar archives received from remote sessions without validating archive member paths. When using the affected Unix download path, a malicious or compromised remote session could return a crafted tar archive containing path traversal entries, such as `../`, causing files to be written outside the intended download directory on the Penelope operator's machine.The impact is limited to files writable by the user running Penelope. In some cases, this arbitrary file write could be chained to operator-side code execution if the attacker can overwrite a file that Penelope or the user later executes, such as `~/.penelope/peneloperc`. The issue has been fixed in version 0.19.3 by rejecting unsafe archive paths during extraction.Affected conditionsThe issue requires the operator to use the Main Menu `download` command to download files from a malicious or compromised remote session that can influence the tar archive returned to Penelope. The Python agent download path is not affected in the same way because it does not rely on the remote `tar` command.The vulnerable behavior is related to Python's historical `tarfile` extraction defaults. In Python versions before 3.14, `TarFile.extractall()` did not use the safer `data` extraction filter by default, so applications extracting untrusted tar archives needed to explicitly provide a safe extraction filter or perform their own path validation.Python 3.14 changes the default extraction behavior to use the `data` filter, which rejects dangerous archive features such as absolute paths and paths outside the destination directory. Penelope 0.19.3 now performs explicit validation/rejection of unsafe archive paths so the fix does not depend on the Python runtime version.DetailsThe vulnerable code is in the Unix `download()` implementation.Penelope creates a local download directory:Later, it opens a tar archive received from the remote session:Then it extracts all members without validating archive paths:Because member names are trusted, a malicious tar archive can contain paths such as:This escapes the intended `local_download_folder` and writes to an arbitrary path writable by the Penelope operator.The same extraction block also suppresses Python's `DeprecationWarning` around unsafe tar extraction:The file-write impact can be chained with Penelope's rc loading behavior:By default, `options.basedir` is `~/.penelope`, so the executed rc file is:Since session downloads are stored under `~/.penelope/sessions/<session>/downloads`, a crafted tar member can traverse upward and plant or replace `~/.penelope/peneloperc`. The planted Python code executes when Penelope starts again or when the operator runs `reload`.PoCThe following reproduces the issue locally by simulating a malicious remote endpoint. The fake `tar` binary is placed first in `PATH` for the test shell, so when Penelope asks the remote session to run `tar`, the remote session returns a crafted archive with path traversal entries.Start Penelope in Terminal 1:Prepare the fake remote `tar` in Terminal 2:Connect the local test shell back to Penelope in Terminal 2:In Terminal 1, inside Penelope, trigger the vulnerable download:Verify in Terminal 3 that files were written outside the intended download directory:Expected output includes:In Terminal 1, inside Penelope, execute the planted rc line:Verify in Terminal 3 that `peneloperc` executed:Expected output:Cleanup:ImpactA malicious remote session can write arbitrary files on the Penelope operator's machine, limited to the permissions of the user running Penelope.For a non-root operator, this may be chained to operator-side code execution only if the attacker can overwrite a user-writable file that Penelope or the user later executes, such as:For a root operator, the impact is higher because root-writable files may be overwritten.Suggested FixValidate every archive member before extraction by resolving the final destination path and rejecting paths outside the intended download directory. Reject symlink and hardlink members. On supported Python versions, `filter="data"` can be used as an additional safeguard.
CVSS v3.1 score: 5.9