T09 · Insecure Skill Coding Practices
- Location
scripts/yt_playlist.py:30- Finding
Unsafe Deserialization of Cached OAuth Credentials
- Content
View full analysis
Vulnerability Details
File Location:
scripts/yt_playlist.py:30-32; duplicated inyt_playlist.py:30-32
Vulnerability Type: Unsafe Python pickle deserialization
Risk Level: HighVulnerable Code:
python if TOKEN_FILE.exists(): with open(TOKEN_FILE, 'rb') as token: creds = pickle.load(token)Technical Analysis
The application loads
token.picklewithpickle.load()without establishing its integrity or provenance. Python pickle data can contain reducer instructions that invoke arbitrary callables during deserialization. Consequently, loading a maliciously modified token file can execute code before the resulting object is used as an OAuth credential.The token has a predictable location in the project root:
python SKILL_DIR = Path(__file__).parent.parent TOKEN_FILE = SKILL_DIR / "token.pickle"The same vulnerable implementation exists in both Python files. Exploitation requires an attacker or compromised process to have permission to create or replace the token file. This does not create a new privilege boundary by itself, but it converts file-write access into code execution in the context of the user running the Skill.
Attack Path
- The attacker obtains write access to the project root or otherwise replaces
token.pickle. - The attacker creates a crafted pickle whose deserialization reducer invokes an arbitrary command or Python callable.
- The user or Agent invokes any supported command that calls
get_authenticated_service(). - The program opens the attacker-controlled file and executes
pickle.load(token). - The embedded reducer executes with the local privileges and environment of the Skill process.
Impact Assessment
Successful exploitation permits arbitrary code execution with the privileges of the user running the Skill. The attacker could read or modify files accessible to that account, access process environment data, steal OAuth m ...[truncated 179 chars]
- The attacker obtains write access to the project root or otherwise replaces
- Remediation
View remediation
Remediation Suggestions
- Eliminate pickle for credential persistence.
- Serialize credentials as non-executable JSON and reconstruct them through supported Google authentication APIs, such as
google.oauth2.credentials.Credentials.from_authorized_user_file(). - Store OAuth material in a dedicated user-private configuration directory rather than the project root.
- Create credential files with restrictive permissions, such as mode
0600on POSIX systems. - Reject token files with unsafe ownership, unexpected permissions, symbolic links, or an unexpected file type.
- If migration from existing pickle files is necessary, do not automatically deserialize them. Require users to authenticate again and delete the legacy files.
- Apply the same correction to both duplicated implementations to prevent users from invoking an unfixed copy.
