Back to skill

Security audit

swift-macos

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent Swift/macOS development guide, but it includes a copy-paste command that downloads and runs a remote installer without verification.

Review this skill before installing if your agent may execute setup commands. Do not allow the agent to run the Swiftly `curl | bash` installer blindly; prefer a verified installer or download-and-verify flow. Treat the macOS capture, Accessibility, login-item, Keychain, and CloudKit sections as powerful app-development guidance that should be applied only to apps with clear user consent and narrow scope.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Findings (1)

T03 · Remote Payload Retrieval and Execution

Error
Location
references/spm-build.md:300
Finding
Unverified Remote Installer Piped Directly to Bash## Vulnerability Details **File Location**: `references/spm-build.md:300-302` **Vulnerability Type**: Remote payload retrieval and execution **Risk Level**: Critical ### Vulnerable Code ```bash # Install swiftly curl -L https://swift.org/install | bash ``` ### Technical Analysis The installation instructions stream content retrieved from an external URL directly into Bash. The response is executed immediately without being saved for inspection, pinned to a specific immutable release, or validated using a cryptographic checksum or signature. HTTPS authenticates the connection under normal conditions, but it does not make mutable upstream content safe to execute. Compromise of the hosting infrastructure, DNS or redirect chain, certificate trust path, or upstream installer could cause arbitrary attacker-controlled commands to run. The `-L` option also follows redirects without constraining the final host. Executing a network response directly is not required for the Skill's declared Swift and macOS development functionality. A verifiable package or separately downloaded and authenticated installer would provide the same functionality with substantially lower privilege and supply-chain risk. ### Attack Path 1. An attacker compromises the installer host, its publishing process, or a destination in the HTTP redirect chain. 2. The attacker modifies the response returned by `https://swift.org/install` to contain malicious shell commands. 3. A user or AI Agent follows the Skill's documented installation command. 4. `curl -L` retrieves and follows redirects to the attacker-controlled content. 5. The pipe sends the response directly to Bash without integrity verification or review. 6. Bash executes the payload with the privileges and environment of the invoking user. ### Impact Assessment Successful exploitation provides arbitrary command execution under the invoking user's account. The payload could: - Read or modify files accessible to the user. - Access deve ...[truncated 569 chars]
Remediation
## Remediation Suggestions 1. Remove the direct `curl | bash` pipeline. 2. Prefer an official, signed operating-system package or another installer whose authenticity is verified by the platform. 3. If a shell installer is unavoidable: - Pin an immutable release URL rather than a mutable installer endpoint. - Download the file separately. - Restrict or carefully validate redirects and the final destination. - Verify a cryptographic signature or a checksum obtained through an authenticated, independent channel. - Inspect the downloaded script before execution. - Execute only the verified local file. 4. Document the expected signer, checksum, release version, and verification commands. 5. Run the installer with the minimum necessary user privileges and avoid requesting administrative access unless explicitly required and justified. A safer documentation pattern is: ```bash curl --fail --show-error --location \ --output swiftly-install.sh \ "PINNED_IMMUTABLE_RELEASE_URL" # Verify the publisher's signature or authenticated checksum here. # Inspect the file before executing it. less swiftly-install.sh bash swiftly-install.sh ``` The placeholder verification step must be replaced with the official publisher's concrete signature or checksum procedure before this pattern is recommended to users.
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
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Memory PoisoningPersistent Context Injection, Context Window Stuffing, Memory Manipulation
Findings (72)

Ae1

High
Category
analysis-evasion
Content
For forms, popovers, sheets, inspector, and macOS modifiers, see `references/swiftui-macos.md`.
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
For forms, popovers, sheets, inspector, and macOS modifiers, see `references/swiftui-macos.md`.
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
| `references/core-audio-tap.md` | CATap for per-process audio: tap-only aggregate (HFP-safe), drift compensation, rate-change anti-pattern, interleaved-stereo
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
| `references/system-integration.md` | Keyboard shortcuts, drag & drop, file access, App Intents (entities, Spotlight, snippets), widgets & Control Center, proc
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Memory Manipulation

High
Category
Memory Poisoning
Content
project.name = "Updated Name"
project.updatedAt = .now

// Delete
context.delete(project)

// Save explicitly
Confidence
80% confidence
Finding
Skill manipulates agent memory, state, or stored context. Memory corruption can alter personality, override safety rules, or cause unpredictable behavior.

Credential Access

High
Category
Privilege Escalation
Content
xcrun notarytool submit MyApp.dmg \
  --apple-id your@email.com \
  --team-id TEAM_ID \
  --password @keychain:AC_PASSWORD \
  --wait

# Check status
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
xcrun notarytool submit MyApp.dmg \
  --apple-id your@email.com \
  --team-id TEAM_ID \
  --password @keychain:AC_PASSWORD \
  --wait

# Check status
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
xcrun notarytool submit MyApp.dmg \
  --apple-id your@email.com \
  --team-id TEAM_ID \
  --password @keychain:AC_PASSWORD \
  --wait

# Check status
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
xcrun notarytool submit MyApp.dmg \
  --apple-id your@email.com \
  --team-id TEAM_ID \
  --password @keychain:AC_PASSWORD \
  --wait

# Check status
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
xcrun notarytool submit MyApp.dmg \
  --apple-id your@email.com \
  --team-id TEAM_ID \
  --password @keychain:AC_PASSWORD \
  --wait

# Check status
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
xcrun notarytool submit MyApp.dmg \
  --apple-id your@email.com \
  --team-id TEAM_ID \
  --password @keychain:AC_PASSWORD \
  --wait

# Check status
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
xcrun notarytool submit MyApp.dmg \
  --apple-id your@email.com \
  --team-id TEAM_ID \
  --password @keychain:AC_PASSWORD \
  --wait

# Check status
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
xcrun notarytool submit MyApp.dmg \
  --apple-id your@email.com \
  --team-id TEAM_ID \
  --password @keychain:AC_PASSWORD \
  --wait

# Check status
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Self-Modification

High
Category
Rogue Agent
Content
- **Pick a globally unique cask token.** Tap CI (`brew test-bot --only-tap-syntax`) fails if your token collides with one in homebrew-core, and renaming later orphans every existing install.
- **If you must rename, ship `cask_renames.json`** in the tap so `brew update` migrates existing installs. `tap_migrations.json` is for cross-tap moves and will not do this.
- **Set `auto_updates true`** when the app self-updates via Sparkle, so Homebrew does not fight the in-app updater. Add a `livecheck` block so version bumps are detectable.
- **`depends_on macos:` cannot express a point release** (e.g. 26.1). Enforce a precise minimum in the app at launch and treat the cask constraint as approximate.
- **Reinstalling over an app already in `/Applications` fails** without `--force`.
- Run `brew style` and `brew audit --cask` before pushing; generated casks commonly trip on a redundant `version` line.
Confidence
90% confidence
Finding
Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Credential Access

High
Category
Privilege Escalation
Content
# Create self-signed dev cert (one-time)
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes \
    -subj "/CN=My Development"
security import cert.pem -k ~/Library/Keychains/login.keychain-db
security import key.pem -k ~/Library/Keychains/login.keychain-db
```
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
# Create self-signed dev cert (one-time)
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes \
    -subj "/CN=My Development"
security import cert.pem -k ~/Library/Keychains/login.keychain-db
security import key.pem -k ~/Library/Keychains/login.keychain-db
```
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
```bash
# Install swiftly
curl -L https://swift.org/install | bash

# Install latest stable
swiftly install latest
Confidence
98% confidence
Finding
The command fetches an external script from the internet and immediately executes it, creating a direct remote code execution path in the user's shell. In a developer-focused build/setup guide, this is especially risky because readers may run it verbatim on workstations or CI hosts with valuable credentials, signing keys, and source access.

Chaining Abuse

High
Category
Tool Misuse
Content
```bash
# Install swiftly
curl -L https://swift.org/install | bash

# Install latest stable
swiftly install latest
Confidence
98% confidence
Finding
The `| bash` construction chains network retrieval directly into shell execution, removing opportunities for review and making command substitution trivial if the upstream content is compromised. In this skill's context, the danger is elevated because it is presented as official setup guidance for macOS/Swift tooling, encouraging copy-paste execution by developers.

Missing User Warnings

High
Confidence
95% confidence
Finding
The Accessibility API section explains how to read and control another application's UI but omits strong user-consent and abuse warnings despite explicitly describing cross-app inspection and automation. This is dangerous because AXUIElement can expose window titles, focused elements, and text selections, enabling credential capture, sensitive data harvesting, or unauthorized UI manipulation if incorporated without strict safeguards.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
This markdown file documents use of ScreenCaptureKit to capture screen content, app audio, and microphone, which can affect user privacy and sensitive data. Although permissions are mentioned only as a reference topic later, the skill description here does not provide a direct warning that these operations may record sensitive on-screen or audio information.

Session Persistence

Medium
Category
Rogue Agent
Content
If you only need to know *whether* the pasteboard holds something you can handle - to enable a Paste menu item, say - use `detectedValues(for:)` / `detectedPatterns(for:)` rather than reading. Read the contents only in response to an explicit user paste action, which is what the alert is designed to permit. Test the behaviour ahead of the rollout:

```bash
defaults write <your_app_bundle_id> EnablePasteboardPrivacyDeveloperPreview -bool yes
```

Apps using the standard responder-chain paste (`NSTextView`, `Cmd+V` through first responder) are unaffected; this hits polling and clipboard-manager patterns.
Confidence
75% 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.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The guidance enables automatic CloudKit syncing without explicitly warning that model data may be transmitted off-device to the user's iCloud account and, in sharing scenarios, to other users. In a developer skill, omitting this privacy and consent warning can lead downstream apps to sync sensitive data unexpectedly, creating privacy, compliance, and user-trust risks.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
**Schema mismatch:**
- After adding new properties, deploy schema to CloudKit Dashboard
- Development environment: auto-deployed
- Production: must manually deploy via Dashboard

## Sharing (CloudKit Sharing)
Confidence
85% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Session Persistence

Medium
Category
Rogue Agent
Content
// Tap-only. DO NOT include kAudioAggregateDeviceMainSubDeviceKey
        // or kAudioAggregateDeviceSubDeviceListKey - they lock the aggregate
        // to the output device's rate and break under HFP.
        kAudioAggregateDeviceTapListKey: [[
            kAudioSubTapUIDKey: tapUID(for: tapID),
            // Must be true: compensates for tap-vs-device clock drift.
            kAudioSubTapDriftCompensationKey: true,
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
3. Upload: Distribute App > App Store Connect
4. Submit for review in App Store Connect

### ExportOptions.plist (for CI)
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
Confidence
75% 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.

Static analysis

No suspicious patterns detected.