T09 · Insecure Skill Coding Practices
- Location
scripts/upload.py:15- Finding
Arbitrary Code Execution Through Unsafe OAuth Token Deserialization
- Content
View full analysis
Vulnerability Details
File Location:
scripts/upload.py, lines 15-17
Vulnerability Type: Unsafe deserialization
Risk Level: HighVulnerable Code:
python if os.path.exists(token_file): with open(token_file, 'rb') as token: creds = pickle.load(token)Technical Analysis
The application deserializes the predictable relative file
token.pickleusing Python'spickle.load(). Pickle is an executable serialization format: specially constructed objects can invoke attacker-selected Python callables during deserialization.The script does not verify the token file's ownership, permissions, integrity, type, or resolved location before loading it. Because
token_fileis set to a relative path, the file is selected from the process's current working directory rather than a fixed, private credential directory.Attack Path
- An attacker obtains write access to the directory from which the skill will be executed, or otherwise causes the process to start in an attacker-controlled directory.
- The attacker creates a malicious
token.picklecontaining a pickle reduction payload that invokes an attacker-selected callable. - A user or agent invokes
scripts/upload.pyfrom that directory. os.path.exists(token_file)detects the malicious file.pickle.load(token)executes the embedded payload before OAuth validation or video upload occurs.
Impact Assessment
Successful exploitation provides arbitrary Python code execution with the operating-system privileges of the process running the skill. The attacker could read or modify files accessible to that account, steal environment variables and credentials, alter uploaded content, make network requests, or execute additional local processes. The precise scope is bounded by the host account's permissions and any applicable sandbox controls.
- Remediation
View remediation
Remediation Suggestions
- Eliminate pickle for credential persistence. Store authorized-user credentials in a non-executable format such as JSON and load them through Google's supported credential APIs.
- Store credentials under a fixed, user-private configuration directory rather than the current working directory.
- Create the credential directory with owner-only permissions and reject credential files that are symbolic links, are not owned by the expected user, or are writable by other users.
- If legacy pickle migration is unavoidable, perform migration only after strict ownership and permission validation, then immediately write the credential in a safe format and delete the pickle.
- Treat any existing
token.picklefile as potentially unsafe and do not deserialize files from shared or untrusted directories.
