Mac hosting guide

Keep Clipboard Data Separate in Mac Automation

Capture clipboard data immediately, clear it with an EXIT trap, and pass secrets through chmod-600 temp files. Sequential single-user jobs fit a Figment Intel Mac VM ($25 a month); separate classes need separate users or Macs.

Figment editorial teamPublished Updated Facts checked November 10, 2026

Figment Mac plans

US East. Pay before use. Hourly and daily too.

Intel Mac VM4 shared vCPUs, 4GB RAM, 80GB SSD$25per monthApple Silicon Mac VM4 shared vCPUs, 4GB RAM, 65GB SSD$39per monthDedicated M4 Pro12-core CPU, 24GB RAM, 512GB SSD$199per month

Minimum first purchase: $25 of account credit, used for your rental.

Stop clipboard leaks between Mac automation jobs with one rule: capture immediately, then clear. macOS exposes one general pasteboard per login session, shared by every process in that session. When a job leaves a parsed token, a customer name or a temporary credential on the clipboard, it stays there until something overwrites it, and a parallel job, a Shortcut or any GUI app can read it with pbpaste, with no error, no log entry and no TCC prompt. If your automation is single-user and sequential, a Figment Intel Mac VM ($25 a month) is enough. Clipboard isolation is a session-level discipline and applies on every plan.

Which Figment plan fits clipboard-safe automation?

The Intel Mac VM ($25 a month, $2 a day, $0.15 an hour) is enough for shell-driven automation, pbcopy and pbpaste work, and Intel-compatible Xcode toolchains. It has 4 shared vCPUs, 4GB of RAM and an 80GB SSD, and runs macOS Sequoia, where Apple lists Xcode 26.0 to 26.3 (see Apple's porting guidance). Outbound CI agents can connect to your runner service from the VM.

If two job classes must never see each other's clipboard, run them under separate macOS user accounts or on separate machines. You have administrator access to your own Mac or VM, so you can create users yourself. Pick the plan by how hard the separation must be:

  • Sequential jobs under one user: the Intel Mac VM ($25 a month).
  • arm64 tools, or a second isolated user on Apple silicon: the Apple Silicon Mac VM ($39 a month, $6 a day), with 4 shared vCPUs and 4GB of RAM.
  • Job classes that must not share a machine at all: the Dedicated M4 Pro 48 GB ($349 a month, or $299 a month on a 12-month term), a whole Mac with an M4 Pro chip, 48GB of RAM and 512GB of storage. Or run each class on its own VM.

Figment runs the Mac and network layer. Your scripts, users and secrets are yours to manage.

Why is the clipboard a leakage surface?

The general pasteboard (NSPasteboard.general) is reachable by any process in the same session through pbpaste, without a permission prompt. These are the typical exposure points:

ScenarioData at risk
OCR step stages text on the clipboard for the next stepPrior extraction readable by the next job
Script writes an API token via pbcopy for one commandToken readable by any parallel script
Shortcut uses an internal Copy to Clipboard actionOutput persists after the shortcut returns
UI automation pastes text via simulated keystrokesInjected text lingers on the pasteboard
Script reads clipboard expecting fresh inputReads stale data from a prior job

Recent macOS releases added an interactive paste-protection prompt for foreground apps, but it does not intercept pbpaste in headless scripts. Verify the behaviour on the exact macOS version you deploy to. The Intel Mac VM runs macOS Sequoia.

How do I capture and clear the clipboard in every script?

Add these wrapper functions and an EXIT trap at the top of every job script. Never leave job data on the pasteboard across step boundaries.

#!/usr/bin/env bash
set -euo pipefail

# Read the clipboard and immediately clear it
clipboard_take() {
    local value
    value=$(pbpaste 2>/dev/null || true)
    printf '' | pbcopy
    printf '%s' "$value"
}

# Clear the clipboard unconditionally
clipboard_clear() {
    printf '' | pbcopy
}

# Always clear on normal exit or trappable signal
trap clipboard_clear EXIT

The EXIT trap fires on normal exit, on set -e failures and on trappable signals. It does not fire on SIGKILL or on sudden power loss. Apple's launchd job guide notes that launchd issues SIGTERM for graceful shutdown of daemons and user agents, so your trap runs during a normal unload. Keep the capture-and-clear window short anyway. Use printf '' rather than echo so no trailing newline lands on the pasteboard.

This is an untested example. Run it against your own project and confirm its behaviour before trusting it in production.

How do I pass a secret between steps without the clipboard?

Use a restricted temp file, not the pasteboard:

TMPFILE=$(mktemp -t job_data) || exit 1
chmod 600 "$TMPFILE"
cleanup() { rm -f "$TMPFILE"; clipboard_clear; }
trap cleanup EXIT
printf '%s' "$API_TOKEN" > "$TMPFILE"
# downstream step in the SAME shell reads it:
TOKEN=$(cat "$TMPFILE")

A separate CI step runs in a separate shell and will not know this temp path unless you persist it explicitly and safely. For real secrets, keep the value in your CI secret manager (GitHub Actions secrets, Vault, 1Password CLI) and read it directly into an environment variable inside the step that needs it.

How do I stop Shortcuts from using the clipboard?

Prefer explicit output redirection over any internal Copy to Clipboard action. The shortcuts run command accepts -o or --output-path to write output to a file and supports piping to another command:

shortcuts run "Extract Invoice Data" \
    -i ~/invoice-spool/invoice_042.pdf \
    -o ~/results/invoice_042.json

If a Shortcut you do not control uses Copy to Clipboard internally, call clipboard_clear immediately after shortcuts run returns.

What should a per-job clipboard checklist cover?

Use this checklist in code review:

Before job starts:
  [ ] trap clipboard_clear EXIT set at top of script
  [ ] If reading from clipboard, call clipboard_take() once, then
      work from the captured variable

During job:
  [ ] No secrets or PII passed through pbcopy/pbpaste
  [ ] Sensitive intermediates live in chmod-600 temp files
  [ ] shortcuts run uses -o; no internal Copy to Clipboard action
  [ ] UI steps that paste text clear the pasteboard afterward

After job (enforced by EXIT trap):
  [ ] Clipboard cleared (printf '' | pbcopy)
  [ ] Temp files removed (rm -f)

Verification:
  [ ] pbpaste returns empty after the job completes

Run the verification as a CI post-step:

clipboard_clear
REMAINING=$(pbpaste 2>/dev/null || true)
if [[ -n "$REMAINING" ]]; then
    echo "WARNING: clipboard not empty after job: $(printf '%s' "$REMAINING" | wc -c) bytes" >&2
fi

What if the trap does not fire, or jobs race?

Handle each failure like this:

SIGKILL or power loss before the trap fires. The trap does not run. Minimise the window: read, clear, then work from variables or files for the rest of the job.

Parallel jobs racing on the pasteboard. Two jobs under the same user share one pasteboard. The reliable fix is not to use the clipboard as a handoff channel at all. Use temp files or pipes. For strong separation between job classes, run them as separate macOS users.

Audit trail for compliance. Log a byte count or hash, never the content, to a user-writable path:

AUDIT_LOG="${HOME}/Library/Logs/clipboard_audit.log"
clipboard_take_logged() {
    local value
    value=$(pbpaste 2>/dev/null || true)
    printf '' | pbcopy
    printf '%s CLIPBOARD_READ job=%s bytes=%d\n' \
        "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "${JOB_NAME:-unknown}" \
        "$(printf '%s' "$value" | wc -c)" >> "$AUDIT_LOG"
    printf '%s' "$value"
}

What does clipboard isolation cost?

It adds no runtime cost. The sizing question is session separation: if sequential jobs under one user are acceptable, the Intel Mac VM at $25 a month is enough. If you need Apple silicon (for arm64 execution, or because your signing policy requires it), the Apple Silicon Mac VM is $39 a month, and a whole dedicated Mac is $349 a month. Idle jobs do not pause billing.

How do I roll this out on an existing set of scripts?

  1. Pick a plan on the Mac hosting page.
  2. Audit existing scripts: grep -rn 'pbcopy\|pbpaste' ~/scripts/.
  3. Add trap clipboard_clear EXIT and the clipboard_take wrapper to each script found.
  4. Replace clipboard-based handoffs with chmod-600 temp files in the same shell, or move the handoff into your CI secret manager.
  5. Run two jobs back-to-back and confirm pbpaste in the second returns an empty string.
  6. Add the checklist above to code review.

Related guides: Task queue for Mac agents · Idempotent jobs for Mac agents · Self-hosted GitHub Actions runner on Mac

Which Figment Mac fits this work?

Intel Mac VM from $25 a month, Apple Silicon Mac VM from $39, or a Dedicated M4 Pro for $199. Hourly and daily plans too. You pay before use, starting with at least $25 of account credit.

Choose a Mac plan