Back to skill

Security audit

Gmail OAuth Setup

Security checks for vulnerabilities and agentic risk

Overview

This Gmail OAuth helper is mostly purpose-aligned, but it needs review because it encourages broad Gmail access and persistent handling of sensitive OAuth secrets.

Review before installing. Use the least Gmail scope that fits your task, avoid putting GOG_KEYRING_PASSWORD in .bashrc, prefer a secure keyring or one-session secret, and be aware the helper briefly places a Gmail refresh token on disk during import. Also verify the gog CLI source/version before trusting it with OAuth credentials.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/gmail-auth.sh:56
Finding
OAuth Refresh Token Can Remain in a Temporary File## Vulnerability Details **File Location**: `scripts/gmail-auth.sh`, lines 56-75 **Vulnerability Type**: Incomplete cleanup of plaintext OAuth credentials **Risk Level**: Medium ### Vulnerable Code ```bash # Create token file for gog import token_file=$(mktemp) cat > "$token_file" << EOF { "email": "${email}", "client": "default", "refresh_token": "${refresh_token}", "scopes": ["${SCOPE}"] } EOF echo -e "${GREEN}Token exchange successful!${NC}" echo "" echo "Importing to gog..." if [[ -z "$GOG_KEYRING_PASSWORD" ]]; then echo -e "${YELLOW}Note: Set GOG_KEYRING_PASSWORD environment variable for non-interactive import${NC}" fi gog auth tokens import "$token_file" rm "$token_file" ``` ### Technical Analysis The script writes a Gmail OAuth refresh token in plaintext to a temporary file. Although `mktemp` normally creates a uniquely named file with restrictive permissions, cleanup occurs only after `gog auth tokens import` succeeds. The script enables `set -e`, so a nonzero exit from `gog`, an interruption, termination signal, system failure, or shell crash can end execution before `rm "$token_file"` is reached. The resulting file may remain in the temporary directory until an external cleanup process removes it. A Gmail refresh token is a long-lived credential. The configured `gmail.modify` scope permits broad mailbox access, including reading messages, sending mail, and modifying mailbox state. Consequently, residual plaintext storage is security-sensitive even if access is initially limited to the account that created the file. ### Attack Path 1. A user successfully completes the Google OAuth authorization flow. 2. The script exchanges the authorization code and receives a refresh token. 3. The refresh token is written to the file created by `mktemp`. 4. `gog auth tokens import` fails, the process is interrupted, or the host terminates before the explicit `rm` comma ...[truncated 1067 chars]
Remediation
## Remediation Suggestions Register cleanup immediately after creating the file so it occurs on normal exit, errors, and common termination signals: ```bash token_file=$(mktemp) chmod 600 "$token_file" cleanup() { rm -f -- "$token_file" } trap cleanup EXIT HUP INT TERM ``` Additional hardening measures: 1. Set `umask 077` near the beginning of the script before creating any credential-bearing files. 2. If supported by `gog`, import the token through standard input or a protected file descriptor rather than writing it to disk. 3. Validate that the temporary file is a regular file owned by the current user before writing to it. 4. Keep the cleanup trap active until import completes, then remove the file explicitly and clear the trap. 5. Avoid including temporary credential files in backups, crash reports, or diagnostic collections. 6. Consider overwriting the file before removal where the underlying storage environment makes that meaningful, while recognizing that secure overwriting is unreliable on journaling or copy-on-write filesystems.

T08 · Insecure Dependencies

Note
Location
SKILL.md:12
Finding
Unpinned Third-Party CLI Installation Instruction## Vulnerability Details **File Location**: `SKILL.md`, line 12 **Vulnerability Type**: Unpinned third-party dependency **Risk Level**: Low ### Vulnerable Code ```markdown - `gog` CLI installed (`brew install steipete/tap/gogcli`) ``` ### Technical Analysis The skill directs users to install `gogcli` from a third-party Homebrew tap without specifying a reviewed version, release digest, commit, or integrity verification procedure. The effective software installed can therefore change after the skill itself has been audited. The project does not contain the pre-scan-described `curl | bash` execution pattern: the documented installation command invokes Homebrew directly. Nevertheless, Homebrew still retrieves and executes package installation logic from an external source. Trust is transferred to the third-party tap, its maintainers, the upstream release artifacts, and the relevant distribution infrastructure. This is a supply-chain hardening issue rather than evidence that the current dependency is malicious. ### Attack Path 1. An attacker compromises the third-party tap, a maintainer account, upstream release infrastructure, or another component of the package distribution chain. 2. The attacker modifies the formula or referenced artifact for `gogcli`. 3. A user follows the documented unpinned installation command. 4. Homebrew resolves the current package definition rather than a version and artifact independently verified by this skill. 5. Malicious installation logic or a modified binary executes with the privileges of the user running Homebrew. 6. Because the CLI is subsequently entrusted with Gmail OAuth credentials and refresh tokens, a malicious version could capture those secrets or alter authentication behavior. ### Impact Assessment Compromise could result in arbitrary code execution under the installing user's account. The dependency is specifically used for OAuth credential and token management, so a ma ...[truncated 425 chars]
Remediation
## Remediation Suggestions 1. Document a specific reviewed `gogcli` release rather than implicitly accepting the latest release. 2. Provide the expected cryptographic digest or signature and instructions for verifying the downloaded artifact. 3. Where Homebrew cannot reliably pin the dependency, link to a versioned formula revision or provide a reproducible installation process. 4. Record the upstream project URL and expected publisher identity so users can detect similarly named or substituted packages. 5. Recommend reviewing the resolved Homebrew formula and artifact source before installation. 6. Advise users to perform installation without `sudo` and under a minimally privileged account. 7. Periodically update the pinned version only after reviewing the release and its integrity metadata.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (15)

Credential Access

High
Category
Privilege Escalation
Content
```bash
gog auth credentials /path/to/client_secret.json
gog auth keyring file  # Use file-based keyring for headless
export GOG_KEYRING_PASSWORD="your-password"  # Add to .bashrc
```
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
gog auth credentials /path/to/client_secret.json
gog auth keyring file  # Use file-based keyring for headless
export GOG_KEYRING_PASSWORD="your-password"  # Add to .bashrc
```

### 3. Run Auth Flow
Confidence
99% confidence
Finding
Persisting `GOG_KEYRING_PASSWORD` in shell configuration materially increases the chance of credential compromise because the password becomes a reusable secret stored in plaintext and automatically loaded into future sessions. An attacker with local access, process inspection, backups, or accidental file disclosure could recover it and unlock stored OAuth material.

Credential Access

High
Category
Privilege Escalation
Content
NC='\033[0m'

# Load credentials from gog config
GOG_CREDS="${HOME}/.config/gogcli/credentials.json"

if [[ ! -f "$GOG_CREDS" ]]; then
    echo -e "${RED}Error: No gog credentials found at $GOG_CREDS${NC}"
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
if [[ ! -f "$GOG_CREDS" ]]; then
    echo -e "${RED}Error: No gog credentials found at $GOG_CREDS${NC}"
    echo "Run: gog auth credentials /path/to/client_secret.json"
    exit 1
fi
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
if [[ ! -f "$GOG_CREDS" ]]; then
    echo -e "${RED}Error: No gog credentials found at $GOG_CREDS${NC}"
    echo "Run: gog auth credentials /path/to/client_secret.json"
    exit 1
fi
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

External Script Fetching

High
Category
Supply Chain
Content
echo -e "${YELLOW}Exchanging code for tokens...${NC}"
    
    response=$(curl -s -X POST https://oauth2.googleapis.com/token \
        -d "code=${code}" \
        -d "client_id=${CLIENT_ID}" \
        -d "client_secret=${CLIENT_SECRET}" \
Confidence
90% confidence
Finding
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Credential Access

High
Category
Privilege Escalation
Content
echo ""
        echo "Importing to gog..."
        
        if [[ -z "$GOG_KEYRING_PASSWORD" ]]; then
            echo -e "${YELLOW}Note: Set GOG_KEYRING_PASSWORD environment variable for non-interactive import${NC}"
        fi
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo ""
        echo "Importing to gog..."
        
        if [[ -z "$GOG_KEYRING_PASSWORD" ]]; then
            echo -e "${YELLOW}Note: Set GOG_KEYRING_PASSWORD environment variable for non-interactive import${NC}"
        fi
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
echo ""
        echo "Importing to gog..."
        
        if [[ -z "$GOG_KEYRING_PASSWORD" ]]; then
            echo -e "${YELLOW}Note: Set GOG_KEYRING_PASSWORD environment variable for non-interactive import${NC}"
        fi
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Lp3

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding
The skill documents use of shell commands and network-based OAuth flows but does not declare any explicit tool restrictions or permissions. In agent environments, missing scope declarations can cause the skill to run with broader-than-intended capabilities, increasing the chance of unintended credential handling or outbound access.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The skill recommends `gmail.modify` as the primary scope but does not clearly warn that this scope allows destructive actions such as deleting messages, changing labels, and modifying mailbox state. Users may authorize more privilege than necessary, violating least privilege and increasing the blast radius if tokens are stolen or misused.

Session Persistence

Medium
Category
Rogue Agent
Content
```bash
gog auth credentials /path/to/client_secret.json
gog auth keyring file  # Use file-based keyring for headless
export GOG_KEYRING_PASSWORD="your-password"  # Add to .bashrc
```

### 3. Run Auth Flow
Confidence
97% confidence
Finding
Adding the keyring password to `.bashrc` creates persistent session-level secret exposure beyond the immediate authentication task. This extends the lifetime and availability of the secret across terminals and sessions, making accidental leakage or post-compromise reuse much more likely.

Missing User Warnings

Medium
Confidence
98% confidence
Finding
The instructions tell users to place `GOG_KEYRING_PASSWORD` in `.bashrc` without warning that shell startup files often store secrets in plaintext and make them broadly accessible to local users, backups, logs, or other processes. This creates long-lived secret exposure and weakens protection of the file-based keyring.

Missing User Warnings

Medium
Confidence
88% confidence
Finding
This shell script reads `client_secret` from a local credentials file and sends it in an HTTP POST to Google's token endpoint. While the network action is part of the script's purpose, there is no explicit disclosure in comments or user-facing output that sensitive credentials and authorization data will be processed and transmitted.

External Transmission

Medium
Category
Data Exfiltration
Content
echo -e "${YELLOW}Exchanging code for tokens...${NC}"
    
    response=$(curl -s -X POST https://oauth2.googleapis.com/token \
        -d "code=${code}" \
        -d "client_id=${CLIENT_ID}" \
        -d "client_secret=${CLIENT_SECRET}" \
Confidence
70% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Static analysis

No suspicious patterns detected.