T09 · Insecure Skill Coding Practices
- Location
scripts/upload.py:14- Finding
Unsafe Deserialization of an Attacker-Replaceable OAuth Token File
- Content
View full analysis
Vulnerability Details
File Location:
scripts/upload.py, lines 14-18
Vulnerability Type: Python pickle deserialization of an untrusted local file
Risk Level: Highpython token_file = 'token.pickle' if os.path.exists(token_file): with open(token_file, 'rb') as token: creds = pickle.load(token)Technical Analysis
The script loads
token.pickleusingpickle.load(). Python pickle data is executable serialization: specially constructed pickle opcodes can invoke arbitrary Python callables during deserialization. Consequently, a pickle file must never be treated as untrusted data.The token path is a fixed relative path, so it resolves against the process's current working directory rather than a validated, private application-state directory. An attacker who can create or replace
token.picklein that directory can cause arbitrary code to execute before the script validates the credential or uploads a video.Attack Path
- An attacker obtains write access to the directory from which the upload script will be invoked, or otherwise causes a crafted
token.pickleto appear there. - The attacker constructs a malicious pickle whose deserialization invokes an operating-system command or arbitrary Python callable.
- A user or Agent invokes
scripts/upload.py. - The script finds the attacker-controlled
token.pickle. pickle.load(token)executes the embedded payload immediately.- The payload operates with the same identity and permissions as the Agent or user running the skill.
Impact Assessment
Successful exploitation provides arbitrary code execution with the privileges of the upload process. Depending on the host's permissions, the attacker could read or modify accessible files, steal OAuth credentials and other local secrets, invoke available tools, alter subsequent skill behavior, or make network requests. The vulnerability does not independently grant ...[truncated 122 chars]
- An attacker obtains write access to the directory from which the upload script will be invoked, or otherwise causes a crafted
- Remediation
View remediation
Remediation Suggestions
- Eliminate pickle-based credential storage. Serialize credentials as non-executable JSON and reconstruct them using the supported Google authentication API, such as
google.oauth2.credentials.Credentials.from_authorized_user_file(). - Store state in a dedicated per-user application directory rather than the current working directory.
- Create the state directory with owner-only permissions, such as mode
0700on supported platforms. - Open the token file defensively, reject symbolic links, and require it to be a regular file owned by the expected user.
- Validate the parsed credential structure before use.
- Use atomic file replacement when updating credentials so interrupted writes cannot leave corrupt state.
- If legacy pickle migration is necessary, perform it only through a separate, explicitly trusted migration process; do not automatically load arbitrary existing pickle files.
- Eliminate pickle-based credential storage. Serialize credentials as non-executable JSON and reconstruct them using the supported Google authentication API, such as
