T09 · Insecure Skill Coding Practices
- Location
scripts/setup_auth.py:46- Finding
OAuth credentials and PKCE state are stored without restrictive file permissions
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill has a coherent Gmail-summary purpose, but it needs review because it stores Google access tokens, prints private email content, writes Calendar events, and starts ongoing token refresh with limited user control.
Install only if you are comfortable giving the skill Gmail read access and Calendar event-write access. Use it in a private environment, protect or delete the stored Google token files, revoke Google OAuth access when finished, avoid enabling the refresh service unless needed, and review Calendar events before allowing automatic creation.
scripts/setup_auth.py:46OAuth credentials and PKCE state are stored without restrictive file permissions
scripts/setup_auth.py:43OAuth callback is accepted without state validation
scripts/setup_auth.py:80OAuth setup synchronously launches an unnecessary perpetual refresh loop
scripts/fetch_emails.py:75Private email content and metadata are exposed through console output and logs
scripts/create_event.py:47Calendar event creation does not enforce the documented duplicate-event check
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
]
def find_credentials_file():
cred_path = os.path.join(CREDENTIALS_DIR, 'credentials.json')
if os.path.exists(cred_path):
return cred_path
matches = glob.glob(os.path.join(CREDENTIALS_DIR, 'client_secret_*.json'))
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
]
def find_credentials_file():
cred_path = os.path.join(CREDENTIALS_DIR, 'credentials.json')
if os.path.exists(cred_path):
return cred_path
matches = glob.glob(os.path.join(CREDENTIALS_DIR, 'client_secret_*.json'))
The skill is designed to persist access to Gmail and Google Calendar over time, including auto-refreshing OAuth tokens and automatically creating calendar events based on email content. Persistent delegated access to sensitive communications and calendar data increases the blast radius if the skill, host agent, or stored tokens are compromised, and automatic actions can also create unwanted or manipulated events from malicious emails.
---
name: mail-summary
description: Fetch Gmail emails from the last 24h, rank by importance, summarize into bullet points, and auto-create Google Calendar events for detected meetings.
# Email & Calendar Assistant Skill
The skill instructs users to send the OAuth client secret JSON and the full localhost redirect URL back through the agent without any explicit warning about the sensitivity of those artifacts or the breadth of Gmail/Calendar access being granted. This can expose OAuth credentials, authorization codes, and account metadata to the agent platform or logs, increasing the risk of account compromise or unintended retention of sensitive access material.
The skill is presented as a mail summarization tool but its normal behavior includes modifying a separate user resource: Google Calendar. This expands capability from read-only summarization to write actions, increasing the chance of surprising side effects, unwanted event creation, and privilege misuse if the user did not clearly consent to calendar changes.
The instruction that the agent must run all setup commands itself encourages autonomous execution of environment setup and dependency installation without a user checkpoint. In a skill that later handles OAuth credentials and mailbox/calendar data, this reduces human oversight and can lead to unintended code execution or privilege use in the local environment.
## Setup Before First Use
> **The agent must run all commands below itself. Do NOT ask the user to run them.**
Before running any script, ensure the Python environment is ready:
The autonomous-command instruction applies to operational scripts that read full email contents and create calendar events, allowing the agent to take privacy-sensitive and state-changing actions without an explicit confirmation step. In this context, autonomy increases the risk of overreach, mistaken execution, and silent data access or modification.
## Available Commands
> **The agent must run all commands below itself. Do NOT ask the user to run them.**
- `python scripts/fetch_emails.py` — Fetch emails from the last 24 hours and print full content
- `python scripts/create_event.py --title "..." --date "YYYY-MM-DD" --time "HH:MM" [--duration 60]` — Create a Google Calendar event
The instructions tell the agent to fetch and process full email contents and create calendar events, but they do not require a clear notice or confirmation to the user about accessing sensitive mailbox data and making account changes. In practice, this can expose private content and cause unauthorized modifications under broad OAuth grants.
The setup flow instructs the agent to save client secrets and OAuth tokens locally without warning about their sensitivity or defining storage protections. If these files are left unprotected in the workspace, other local processes, users, or later tasks could reuse them to access the user's Gmail and Calendar.
The background refresh service maintains persistent authenticated access by silently refreshing OAuth tokens every 30 minutes, but the instructions do not clearly warn the user about that ongoing access. This increases the persistence of compromise or misuse if the environment is shared, unattended, or later repurposed.
Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.
cred_path = os.path.join(CREDENTIALS_DIR, 'credentials.json')
if os.path.exists(cred_path):
return cred_path
matches = glob.glob(os.path.join(CREDENTIALS_DIR, 'client_secret_*.json'))
if matches:
return matches[0]
raise FileNotFoundError(
The script retrieves mailbox contents, including sender, subject, date, and body, and prints them directly to stdout. In agent or automation environments, stdout is often captured by logs, orchestration systems, chat transcripts, or other downstream consumers, which can unintentionally disclose sensitive email data well beyond the intended user.
The header says the script completes auth and saves token.json, but the implementation also automatically launches refresh_service.py. Undocumented post-auth execution is dangerous because users may grant sensitive OAuth access expecting only token storage, while the script immediately starts additional code with those newly obtained credentials.
The script writes OAuth credentials to token.json on disk without any warning, permission hardening, or user guidance about protecting the file. Stored refresh tokens can provide long-lived access to user data if another local user, backup system, malware, or accidental commit exposes the file.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
print("refresh_service.py is already running. Skipping auto-run.")
else:
try:
result = subprocess.run([sys.executable, script_path], check=True, capture_output=True, text=True)
print("\n[refresh_service.py output]\n" + result.stdout)
except subprocess.CalledProcessError as e:
print(f"[refresh_service.py error]: {e.stderr}")
The configuration example sets timezone: Asia/Bangkok, which can imply a default locale-specific behavior for calendar event handling. The file does not clearly state that users should choose their own timezone or that the provided value is only an example, which risks a locale policy issue.
The config sets timezone: Asia/Bangkok, which imposes a specific locale/timezone behavior. For a general skill, this can be a natural-language policy concern because it fixes a locale-related setting without any visible opt-in or justification in the file.
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
MAX_BODY_LENGTH = 500
config = get_config()
LOG_LEVEL = getattr(logging, config.get('log_level', 'INFO').upper(), logging.INFO)
logging.basicConfig(
level=LOG_LEVEL,
format='%(asctime)s %(levelname)s %(message)s',
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
MAX_BODY_LENGTH = 500
config = get_config()
LOG_LEVEL = getattr(logging, config.get('log_level', 'INFO').upper(), logging.INFO)
logging.basicConfig(
level=LOG_LEVEL,
format='%(asctime)s %(levelname)s %(message)s',
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
MAX_BODY_LENGTH = 500
config = get_config()
LOG_LEVEL = getattr(logging, config.get('log_level', 'INFO').upper(), logging.INFO)
logging.basicConfig(
level=LOG_LEVEL,
format='%(asctime)s %(levelname)s %(message)s',