T09 · Insecure Skill Coding Practices
- Location
scripts/tasks_ops.py:29- Finding
Unsafe Deserialization of a Persistent OAuth Token
- Content
View full analysis
Vulnerability Details
File Location:
scripts/tasks_ops.py, lines 29-31
Vulnerability Type: Unsafe Python pickle deserialization
Risk Level: Highpython if TOKEN_FILE.exists(): with open(TOKEN_FILE, 'rb') as token: creds = pickle.load(token)Technical Analysis
The authentication routine deserializes
~/.google-tasks-token.pickleusingpickle.load(). Python pickle data is executable serialization: specially constructed reduction instructions can invoke attacker-selected Python callables during deserialization. Consequently, pickle must not be used to load data whose integrity cannot be guaranteed.The token is read from a predictable path in the user's home directory. The implementation does not verify that the file is a regular file, reject symbolic links, validate its owner or permissions, or cryptographically authenticate its contents. Merely reaching
pickle.load()is sufficient to execute a malicious payload; the object does not need to represent valid Google credentials.Attack Path
- An attacker obtains the ability to create or modify
~/.google-tasks-token.pickle, such as through another compromised process running as the user, an insecure restoration process, or incorrectly configured home-directory permissions. - The attacker writes a crafted pickle whose deserialization method invokes an attacker-selected Python callable.
- The user invokes the Skill's script or any function that calls
get_tasks_service(). authenticate()detects the token file and passes it topickle.load().- The payload executes before credential validity is checked.
This path requires prior write access to the token location or an equivalent filesystem manipulation capability; the repository does not itself provide that access.
Impact Assessment
Successful exploitation provides arbitrary code execution with the operating-system privileges of the user running the Skill. T ...[truncated 306 chars]
- An attacker obtains the ability to create or modify
- Remediation
View remediation
Remediation Suggestions
- Replace pickle persistence with a non-executable format. Serialize only the credential fields required by
google.oauth2.credentials.Credentials, preferably using its supported JSON serialization facilities, and reconstruct credentials explicitly from validated fields. - Create the token file with owner-only permissions, such as mode
0600, and ensure its parent directory is not writable by other users. - Before reading, reject symbolic links and non-regular files and verify expected ownership and restrictive permissions.
- Write updates atomically through a securely created temporary file in the same protected directory, set restrictive permissions, and then replace the destination.
- Treat the existing pickle file as untrusted during migration. Do not deserialize it automatically; require reauthentication or use a separately reviewed one-time migration process.
- Replace pickle persistence with a non-executable format. Serialize only the credential fields required by
