T09 · Insecure Skill Coding Practices
- Location
scripts/slides.py:21- Finding
OAuth Refresh Token Exported to a Predictable Persistent Temporary File
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This Google Slides helper is mostly purpose-focused, but it needs review because it handles Google OAuth tokens unsafely and asks for broader Google account access than Slides work requires.
Review before installing. Use only with an account you explicitly choose, avoid the documented broad re-auth command, and revoke/reissue any token if /tmp/gog_slides_token.json may already exist. The batch command can make broad or destructive changes to a presentation, and comment resolution writes to Drive comment threads.
scripts/slides.py:21OAuth Refresh Token Exported to a Predictable Persistent Temporary File
SKILL.md:17Authentication Instructions Request Unrelated Google Service Permissions
The declared purpose focuses on creating, editing, reading, and exporting Slides, but the skill also includes comment listing and comment resolution/reply operations through Drive comment resources. This expands the effective access surface to collaboration metadata and communications that a user may not anticipate, increasing the risk of unauthorized data access or modification.
The script directly accesses stored OAuth client credentials and combines them with exported refresh-token material to obtain active Google API access. In a skill context, that means the code has credential-handling capability that could expose or misuse sensitive authentication artifacts if the host or surrounding workflow is compromised.
import subprocess
import argparse
GOG_CREDS = os.path.expanduser("~/.config/gogcli/credentials.json")
TOKEN_TMP = "/tmp/gog_slides_token.json"
ACCOUNT = os.environ.get("GOG_ACCOUNT", "david@hml.tech")
The skill exposes shell, environment, and network-capable behavior but does not declare any explicit tool scope or permission boundaries. That makes it easier for an agent or operator to invoke broader capabilities than users may reasonably expect, especially given the ability to authenticate, export files, and call local scripts.
The skill hard-codes a specific email account identity, which can cause actions to run against an unintended account without user selection. In a multi-account or shared environment, this could lead to unauthorized access, data modification, or exports from the wrong user's Google workspace.
The re-auth instruction requests broad Google service access across gmail, calendar, drive, docs, sheets, contacts, tasks, and people, even though the skill is for Slides. Requesting unnecessary scopes without a clear warning increases blast radius if tokens are misused and may grant access to unrelated private account data.
Guidance to set GOG_ACCOUNT to a specific identity creates persistent default-account behavior without user opt-in. That makes accidental use of the wrong account more likely across future commands, especially for read/write actions and token-backed API access.
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
Google Slides API helper - uses gog's stored OAuth credentials.
Usage:
python3 slides.py create "My Presentation"
python3 slides.py info <presentationId>
python3 slides.py add-slide <presentationId> --title "Slide Title" --body "Bullet 1\nBullet 2"
python3 slides.py batch <presentationId> requests.json
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
from google.oauth2.credentials import Credentials
from google.auth.transport.requests import Request
result = subprocess.run(
["gog", "auth", "tokens", "export", ACCOUNT, "--out", TOKEN_TMP, "--overwrite"],
capture_output=True, text=True
)
The script exports OAuth token material to a predictable file in /tmp, which is an unsafe location for sensitive credentials on multi-user systems. Even if file permissions are usually restrictive, using a static world-discoverable path increases the chance of token exposure, race conditions, or accidental reuse by other processes.
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
from google.oauth2.credentials import Credentials
from google.auth.transport.requests import Request
result = subprocess.run(
["gog", "auth", "tokens", "export", ACCOUNT, "--out", TOKEN_TMP, "--overwrite"],
capture_output=True, text=True
)
The skill claims to focus on Google Slides creation, editing, reading, and export, but it also exposes Drive comment listing and comment resolution capabilities. That mismatch expands the authority surface beyond the advertised scope, which can surprise calling agents and enable unintended access to discussion metadata and workflow actions.
The generic batch endpoint accepts arbitrary JSON requests and forwards them directly to the Slides API, allowing many more mutations than the narrower advertised operations like add/update slides. In an agent setting, this is dangerous because it creates an unbounded write primitive that can restructure, delete, or alter presentations in unexpected ways.
This function performs arbitrary JSON-driven write operations against a presentation without any guardrails, confirmation, or user-facing disclosure of the breadth of possible changes. In an agent-executed context, that raises the risk of silent destructive or policy-violating edits when untrusted input is mapped into the request file.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def cmd_export(args):
"""Export presentation to PDF or PPTX using gog."""
out = args.out or f"/tmp/{args.presentation_id}.{args.format}"
result = subprocess.run(
["gog", "slides", "export", args.presentation_id,
"--format", args.format, "--out", out],
capture_output=True, text=True
The markdown documents exporting presentations to /tmp/deck.pdf and /tmp/deck.pptx, which writes files to the local filesystem. The skill description does not include any warning that it will create or overwrite local output files or advise users to verify the destination path.