Skip to content

CamilleScholtz/swmpc / .agents/skills/audit-xcode-security-settings

audit-xcode-security-settings

Verified

Audit and enable security-oriented Xcode build settings, compiler warnings, static analysis, and Enhanced Security features.

references/adoption-strategy.md

View on GitHub
# Adoption Strategy

A recommended order for validating and addressing Xcode Enhanced Security features, from lowest risk and effort to highest.

Adding the Enhanced Security capability enables all cascaded settings at once. The phases below represent the order in which to **validate and fix issues** — not separate enablement steps. Phase 1 features are zero-cost (nothing to fix for well-behaved code), Phase 2 may need minor code changes, and Phase 3 requires active annotation or rewriting.

## Phase 1: Zero-Cost, No Code Changes

Start here. These features have no runtime cost and require no source code changes for well-behaved code.

| Feature | Why first | Reference |
|---------|----------|-----------|
| **Security Compiler Warnings** | Compile-time only. Zero runtime cost. Identifies real bugs. | `security-compiler-warnings.md` |
| **Stack Zero Initialization** | Transparent. Cannot cause crashes. Prevents info leaks. | `stack-zero-init.md` |
| **Read-Only Platform Memory** | No impact on well-behaved code. Blocks post-exploitation. | `readonly-platform-memory.md` |

**Action:** After enabling Enhanced Security, build and fix any new warnings. These features won't cause runtime issues.

## Phase 2: Low-Effort Runtime Protections

Next, validate runtime protections that require minimal or no code changes for most apps.

| Feature | Effort | Reference |
|---------|--------|-----------|
| **Runtime Restrictions** | No changes if using XPC or no IPC. Review needed only for raw Mach IPC. | `runtime-restrictions.md` |
| **Typed Allocators** | No changes for standard `malloc`/`free`. Update custom allocator wrappers if present. | `typed-allocators.md` |

**Action:** Test thoroughly. If you use raw Mach IPC, read the Mach IPC conformance guide.

## Phase 3: Annotation and Code Hardening

These features require active code changes — annotations, pointer type updates, or fixing unsafe patterns.

| Feature | Effort | Reference |
|---------|--------|-----------|
| **Pointer Authentication** | Add `__ptrauth` qualifiers to security-critical function/data pointers. Review pointer casts. | `pointer-authentication.md` |
| **C++ Stdlib Hardening** | Fix out-of-bounds container access and unsafe buffer operations. | `cpp-hardening.md` |

**Action:** Prioritize security-critical code paths first (parsers, network handlers, IPC).

Additionally, consider adopting **C Bounds Safety** (`-fbounds-safety`) as a complementary feature for C codebases — see the `adopt-c-bounds-safety` skill.

## Phase 4: Hardware-Dependent Protections

These require specific hardware and OS versions.

| Feature | Requirement | Reference |
|---------|------------|-----------|
| **Hardware Memory Tagging** | iPhone/iPad with an A19 chip or later; Mac/Vision Pro with an M5 chip or later; Apple Watch with an S11 chip or later | `hardware-memory-tagging.md` |
| **Checked Pointer Arithmetic** | device running iOS with an A20 Pro chip or later; device running watchOS with an S11 chip or later. | `checked-pointer-arithmetic.md` |

**Action for Hardware Memory Tagging:**
1. Enable with soft mode first — this generates simulated crash reports without terminating the app
2. Deploy soft mode to internal testers
3. Review simulated crash reports and fix memory bugs
4. Disable soft mode for production enforcement

**Action for Checked Pointer Arithmetic:** enable hardware memory tagging first — run time enforcement requires it — and finish that rollout before adding this. Then build the `arm64e.x1` slice, add the enforcement entitlement, and test on capable hardware. There is no soft mode here, and memory tagging's soft mode does not cover these faults: a latent pointer-arithmetic bug terminates the app. Read `checked-pointer-arithmetic.md` for instructions on how to enable checked pointer arithmetic and additional notes about adoption.

## Decision Matrix

Use this to decide which features to prioritize based on your codebase:

| If your app... | Prioritize |
|---|---|
| Is pure Swift | Phase 1 + Runtime Restrictions + Read-Only Memory |
| Has C code | All of Phase 1-3, plus consider C Bounds Safety (separate skill) |
| Has C++ code | All of Phase 1-3, especially C++ Hardening |
| Processes untrusted input | All features, prioritize bounds checking, memory tagging, and checked pointer arithmetic |
| Uses Mach IPC | Review runtime restrictions carefully before enabling |
| Targets MTE-capable hardware (iPhone/iPad with chip A19 or later, Mac/Vision Pro with chip M5 or later, Apple Watch with chip S11 or later) | Consider hardware memory tagging (start with soft mode) |
| Runs on devices running iOS with an A20 Pro chip or later, or devices running watchOS with an S11 chip or later | Consider checked pointer arithmetic — it requires hardware memory tagging for run time enforcement |
| Is a DriverKit extension | All applicable features — elevated privilege means higher stakes |

## General Principles

1. **Enable Enhanced Security as a capability first** — this turns on all cascaded features at once
2. **Fix warnings before testing runtime protections** — compiler warnings often reveal the same bugs that runtime protections would crash on
3. **Fix undefined behavior in pointer arithmetic** — most checked pointer arithmetic failures are a consequence of undefined behavior, such as subtracting pointers into different objects
4. **Test in soft mode before hard mode** — applies to hardware memory tagging
5. **Prioritize security-critical code** — parsers, network handlers, IPC, auth logic
6. **Don't skip testing** — Enhanced Security features turn latent bugs into crashes, which is the point, but you want to find them before your users do
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall