The vulnerability is a path traversal issue within the Entire CLI, stemming from the use of unvalidated identifiers, primarily SessionID, to construct filesystem paths for reading and writing files. These identifiers could be influenced by an attacker with push access to the entire/checkpoints/v1 branch in a shared repository.
The analysis of the provided patches reveals several key functions that were directly involved in the vulnerability. The core issue was that data from checkpoint metadata, which is considered untrusted, was used to build file paths without sufficient sanitization. This allowed for arbitrary file writes, directory listings, and file deletions.
-
Arbitrary File Write: Functions like resolveTranscriptPath, ManualCommitStrategy.RestoreLogsOnly, and captureTranscript were used in the session resume and checkpoint rewind commands. They took a SessionID and used it to construct a path to write transcript or log data. A malicious SessionID like ../../../../home/user/.bashrc could cause these functions to overwrite critical system files, leading to remote code execution on the victim's machine.
-
Arbitrary Directory Creation/Listing: Functions like ManualCommitStrategy.Rewind and GetNextCheckpointSequence were vulnerable to path traversal when creating or reading directories. This could lead to information disclosure or writing files outside the intended repository structure.
-
Arbitrary File Deletion: Functions like StateStore.Clear used the SessionID in a filepath.Glob pattern. A malicious SessionID containing glob metacharacters (e.g., *) could cause the deletion of unintended files, leading to a denial-of-service attack by wiping all session states.
The patches address these issues by adding strict validation at the "choke points" where untrusted data enters a function that performs a filesystem operation. The validation.ValidateSessionID function was enhanced to reject path separators, traversal sequences (. and ..), absolute paths, and glob metacharacters. Additionally, for defense-in-depth, several file operations were moved to use os.Root to provide kernel-level containment within a specific directory.