T09 · Insecure Skill Coding Practices
- Location
scripts/lib/session.py:50- Finding
Authentication Cookies Stored in Plaintext Without Restrictive File Permissions
- Content
View full analysis
Vulnerability Details
File Location:
scripts/lib/session.py:50-54
Vulnerability Type: Plaintext storage of reusable authentication credentials
Risk Level: MediumVulnerable Code
python def save_cookies(self): logging.info(f"Saving cookies to {self.cookies_path}...") cookies = self.context.cookies() with open(self.cookies_path, 'w', encoding='utf-8') as f: json.dump(cookies, f, indent=4)Technical Analysis
The Skill exports all cookies from the active Playwright browser context and writes them directly to
data/cookies.jsonas plaintext. TikTok session cookies are reusable authentication credentials and may allow a party possessing them to assume the authenticated browser session without knowing the account password.The file is created with Python's default file-creation behavior. The code does not enforce restrictive permissions, verify ownership, encrypt the contents, or reject an existing file with unsafe permissions. The file is also located inside the project directory, increasing the possibility of exposure through repository commits, backups, artifact packaging, or access by other local processes.
Attack Path
- A user supplies valid TikTok authentication cookies and runs the Skill.
- The Skill authenticates a Playwright browser context with those cookies.
- At the end of the run,
save_cookies()exports the complete browser cookie set. - The credentials are written in plaintext to
data/cookies.jsonusing default filesystem permissions. - An unauthorized local process, another user permitted by those filesystem settings, an insecure backup, or an accidental repository publication obtains the file.
- The exposed cookies are imported into another browser context.
- If the session remains valid and TikTok does not require additional verification, the attacker can impersonate the authenticated user.
Impact Assessment
Successful exploi ...[truncated 496 chars]
- Remediation
View remediation
Remediation Suggestions
- Store cookies outside the project and source-control directories.
- Create the credential file with owner-only permissions, such as mode
0600on POSIX systems. - Verify file ownership and permissions before reading or overwriting an existing cookie file.
- Use an operating-system credential manager or encrypted secret store rather than a plaintext JSON file where practical.
- Write credentials atomically through a securely created temporary file, set restrictive permissions, and then replace the destination.
- Add
data/cookies.jsonand generated credential files to repository ignore and artifact exclusion rules. - Restrict imported cookies to explicitly approved TikTok domains.
- Document how users can revoke active TikTok sessions if the cookie file is exposed.
