Back to skill

Security audit

Google Drive

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real Google Drive helper, but it uses broad Drive credentials and has under-scoped authentication behavior that should be reviewed before installation.

Install only if you intend to give this skill broad Google Drive access. Prefer a least-privilege Google credential, avoid untrusted service-account JSON files, restrict or remove arbitrary --scope use, and require explicit confirmation before upload or folder-creation commands, especially in shared drives or delegated Workspace environments.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/gdrive_sa.py:97
Finding
Unvalidated Service-Account Token URI Enables SSRF and Disclosure of Signed Authentication Material<![CDATA[ ## Vulnerability Details **File Location**: `scripts/gdrive_sa.py`, lines 97-132 **Vulnerability Type**: Unvalidated credential-controlled network destination / SSRF **Risk Level**: Medium ### Vulnerable Code ```python def mint_access_token(sa: dict, scope: str, subject: str | None) -> str: now = int(time.time()) header = {"alg": "RS256", "typ": "JWT"} claim = { "iss": sa["client_email"], "scope": scope, "aud": sa.get("token_uri", "https://oauth2.googleapis.com/token"), "iat": now, "exp": now + 3600, } if subject: claim["sub"] = subject signing_input = f"{b64url(json.dumps(header, separators=(',', ':')).encode())}.{b64url(json.dumps(claim, separators=(',', ':')).encode())}" signature = sign_rs256(signing_input.encode("ascii"), sa["private_key"]) assertion = f"{signing_input}.{b64url(signature)}" payload = urllib.parse.urlencode( { "grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer", "assertion": assertion, } ).encode("utf-8") req = urllib.request.Request( sa.get("token_uri", "https://oauth2.googleapis.com/token"), data=payload, headers={"Content-Type": "application/x-www-form-urlencoded"}, method="POST", ) try: with urllib.request.urlopen(req) as resp: data = json.loads(resp.read().decode("utf-8")) except urllib.error.HTTPError as exc: detail = exc.read().decode("utf-8", "replace") raise SystemExit(f"Token exchange failed: HTTP {exc.code}: {detail}") return data["access_token"] ``` ### Technical Analysis The service-account JSON is loaded from `GOOGLE_SERVICE_ACCOUNT_KEY`, which may either contain JSON directly or identify a local JSON file. Its optional `token_uri` property is used without validation as: 1. The `aud` claim of a newly signed JWT assertion. 2. The destination of an outbound HTTP POST request. No check restric ...[truncated 2570 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not trust `token_uri` from externally supplied service-account JSON. Use a fixed token endpoint: ```python GOOGLE_TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token" ``` Use this constant for both the JWT `aud` claim and the outbound request URL. 2. If alternate endpoints are operationally required, implement a strict allowlist based on parsed URL components: - Require the `https` scheme. - Require an explicitly approved hostname. - Require the expected path. - Reject embedded credentials, fragments, unexpected ports, and malformed URLs. - Do not use suffix-only hostname checks that could accept attacker-controlled domains. 3. Prevent redirects from moving token requests to an unapproved origin. Either disable automatic redirects for token exchange or validate every redirect destination against the same allowlist. 4. Fail closed when endpoint validation fails and avoid including the JWT assertion or credentials in error messages or logs. 5. Treat the service-account JSON as security-sensitive configuration: - Restrict file permissions. - Do not accept credential files from untrusted workspaces or uploads. - Validate expected service-account fields before use. - Document that control of this configuration is equivalent to control of the authentication flow. A fixed-endpoint implementation should resemble: ```python GOOGLE_TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token" claim = { "iss": sa["client_email"], "scope": scope, "aud": GOOGLE_TOKEN_ENDPOINT, "iat": now, "exp": now + 3600, } req = urllib.request.Request( GOOGLE_TOKEN_ENDPOINT, data=payload, headers={"Content-Type": "application/x-www-form-urlencoded"}, method="POST", ) ``` ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
Findings (14)

Tainted flow: 'req' from os.environ.get (line 120, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Content
method="POST",
    )
    try:
        with urllib.request.urlopen(req) as resp:
            data = json.loads(resp.read().decode("utf-8"))
    except urllib.error.HTTPError as exc:
        detail = exc.read().decode("utf-8", "replace")
Confidence
90% confidence
Finding
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Tainted flow: 'req' from os.environ.get (line 120, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Content
method="POST",
    )
    try:
        with urllib.request.urlopen(req) as resp:
            data = json.loads(resp.read().decode("utf-8"))
    except urllib.error.HTTPError as exc:
        detail = exc.read().decode("utf-8", "replace")
Confidence
90% confidence
Finding
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Tainted flow: 'req' from os.environ.get (line 120, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Content
method="POST",
    )
    try:
        with urllib.request.urlopen(req) as resp:
            data = json.loads(resp.read().decode("utf-8"))
    except urllib.error.HTTPError as exc:
        detail = exc.read().decode("utf-8", "replace")
Confidence
90% confidence
Finding
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Tainted flow: 'req' from os.environ.get (line 120, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Content
method="POST",
    )
    try:
        with urllib.request.urlopen(req) as resp:
            data = json.loads(resp.read().decode("utf-8"))
    except urllib.error.HTTPError as exc:
        detail = exc.read().decode("utf-8", "replace")
Confidence
90% confidence
Finding
The token exchange endpoint is taken from the service-account JSON via sa.get("token_uri", ...), so a malicious or untrusted GOOGLE_SERVICE_ACCOUNT_KEY value can redirect the signed JWT assertion to an attacker-controlled URL. That would disclose a bearer-style assertion signed by the private key and could leak delegated subject information, turning credential material into an exfiltration channel.

Credential Access

High
Category
Privilege Escalation
Content
- `GOOGLE_SERVICE_ACCOUNT_KEY` for service-account auth
- `GOOGLE_OAUTH_REFRESH_TOKEN` for the dashboard Google Drive OAuth connector

OAuth mode also needs `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET` so the refresh token can be exchanged for an access token.

This skill is for:
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
- `GOOGLE_SERVICE_ACCOUNT_KEY` for service-account auth
- `GOOGLE_OAUTH_REFRESH_TOKEN` for the dashboard Google Drive OAuth connector

OAuth mode also needs `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET` so the refresh token can be exchanged for an access token.

This skill is for:
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
94% confidence
Finding
The skill exposes significant capabilities via environment variables, shell execution, filesystem read/write, and network access, but does not declare any explicit tool scope or permissions boundary. That increases the chance an agent can invoke this skill with broader authority than intended, including access to Google Drive data and local file paths, without clear policy enforcement or user visibility.

Missing User Warnings

Medium
Confidence
89% confidence
Finding
The private key from GOOGLE_SERVICE_ACCOUNT_KEY is written to a temporary file on disk so openssl can use it. Even with 0600 permissions and cleanup, writing secret key material to disk increases exposure to forensic recovery, backup capture, crash artifacts, or local compromise.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
try:
        os.write(fd, private_key.encode("utf-8"))
        os.close(fd)
        proc = subprocess.run(
            ["openssl", "dgst", "-sha256", "-sign", key_path],
            input=message,
            stdout=subprocess.PIPE,
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Tainted flow: 'data' from pathlib.Path.read_bytes (line 307, file read) → pathlib.Path.write_text (file write)

Medium
Category
Data Flow
Content
path = Path(out_path)
        path.parent.mkdir(parents=True, exist_ok=True)
        if text:
            path.write_text(data.decode("utf-8"))
        else:
            path.write_bytes(data)
        print(str(path))
Confidence
65% confidence
Finding
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Tainted flow: 'data' from pathlib.Path.read_bytes (line 307, file read) → pathlib.Path.write_bytes (file write)

Medium
Category
Data Flow
Content
if text:
            path.write_text(data.decode("utf-8"))
        else:
            path.write_bytes(data)
        print(str(path))
        return
    if text:
Confidence
65% confidence
Finding
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Description-Behavior Mismatch

Medium
Confidence
90% confidence
Finding
The skill description frames the capability as Drive access, but the code also supports creating folders and uploading content. In agent settings, capability understatement is dangerous because operators may grant credentials expecting read-oriented access while the skill can also modify remote data.

Context-Inappropriate Capability

Medium
Confidence
92% confidence
Finding
The --scope argument allows arbitrary OAuth scopes rather than constraining the tool to the stated Drive purpose. In an agent context, this enables privilege expansion if a caller supplies broader scopes and the backing credentials permit them.

Context-Inappropriate Capability

Medium
Confidence
95% confidence
Finding
The --subject option enables domain-wide delegation impersonation of arbitrary users when used with a suitably configured service account, yet this capability is not disclosed in the skill purpose. In enterprise environments this greatly increases risk because the skill can act as other principals and access or modify their Drive data.

Static analysis

No suspicious patterns detected.