# Security and privacy requirements These are hard requirements. The `swift-reviewer` agent checks every change against this list; `scripts/privacy-check.sh` automates what can be automated. ## Data handling | ID | Requirement | How to verify | |---|---|---| | SP-1 | The pasteboard is read only after an explicit user action (double copy, menu item, Services). No background reading, no folder watching. | No `FSEventStream`, `NSFilePresenter` or timer that reads content without a change event. | | SP-2 | Selected text, translations, prompt text, pasteboard strings, app names and paths never appear in logs in clear. | All `Logger` interpolations of such values use `privacy: .private`; grep for `\(text`, `\(translation`, `\(string`, `\(app`, `\(url`, `\(path` without `.private`. | | SP-3 | No telemetry, analytics, crash-reporting SDKs or accounts. | `Package.resolved` contains only allowed dependencies; no SDK names in sources. | | SP-4 | Network requests only to the configured Ollama endpoint. | `URLSession` and `URLRequest` appear only in `SprachmittlerOllama`. | | SP-5 | Default endpoint is loopback. Non-loopback requires `allowRemoteEndpoint == true` and an `https` scheme. | `EndpointPolicyTests`. | | SP-6 | Redirects are refused; the session is ephemeral (no cookies, no URL cache, no credential storage). | `RedirectRefusalTests`; grep for `URLSessionConfiguration.ephemeral`. | | SP-7 | No translation history. Source text and translations are never written to disk, caches, logs or UserDefaults. | Code review; privacy check for text fields in settings; no file writes outside settings. | | SP-8 | Copy writes the clipboard only when the user clicks Copy. Replace snapshots the clipboard, writes the translation, pastes, and restores the snapshot. | `ClipboardSnapshotTests`; manual checklist. | | SP-9 | The clipboard snapshot lives in memory for one replacement, is restored even on failure, and is never logged. | `ClipboardSnapshotTests`; code review. | | SP-10 | Permissions are minimal: Accessibility optional and only for Replace; no Input Monitoring, Screen Recording, Camera, Microphone or Apple Events. Entitlements are exactly `app-sandbox = false`. | `privacy-check.sh` compares the entitlements and Info.plist keys. | | SP-11 | Selected and translated text is treated as data: never executed, never inserted into another prompt except as the user-initiated source, never used to choose actions. | Code review. | | SP-12 | Warm-up and fixtures use only fixed synthetic text; no user text is sent anywhere except as the text being translated. | Code review; `capture-fixtures.sh` uses only fixtures. | | SP-13 | Our own clipboard writes are marked and suppressed so the watcher cannot translate the translation. | `OwnWriteSuppressionTests`. | | SP-14 | Replace verifies the source app and, when available, the selected text before changing it; it aborts on a mismatch. | `InsertionTargetTests`. | | SP-15 | The app never requests Accessibility on the double-copy path and never prompts repeatedly. | Code review; manual checklist. | ## Entitlements and runtime - App Sandbox: **disabled** (ADR-003), because Accessibility replacement requires it. Hardened Runtime: **enabled**. - Entitlements are exactly `com.apple.security.app-sandbox = false`. No network entitlement is needed outside the sandbox. - Xcode may inject `get-task-allow` into a Debug signature for the debugger. Release and the `make install` signature contain only `com.apple.security.app-sandbox = false`; `scripts/verify.sh` and `make install` check the signatures with `scripts/check-signature.sh`, and `scripts/privacy-check.sh` checks the entitlements file. - No `com.apple.security.cs.allow-unsigned-executable-memory`, `disable-library-validation`, `allow-jit` or other hardened-runtime exceptions. - ATS: `NSAllowsLocalNetworking = true` only. No `NSAllowsArbitraryLoads`. - Info.plist: `LSUIElement = true`, `NSServices` for "Translate with Sprachmittler", no microphone/camera/screen/Input Monitoring/Apple Events usage descriptions. ## Permissions | Permission | Use | Request policy | |---|---|---| | Accessibility | Replace (AX direct set or synthetic ⌘V) | Only when the user clicks Replace, or from onboarding if they opt in. `AXIsProcessTrustedWithOptions` is never called on the trigger path. | | Input Monitoring | Nothing | Never requested. The app does not install a key tap. | | Screen Recording | Nothing | Never requested. No screenshots, no `CGWindowListCreateImage`, no `SCStream`. | | Camera / Microphone | Nothing | Never requested. No `AVCaptureDevice`. | | Apple Events | Nothing | Never requested. No `NSAppleScript` / `AEDeterminePermissionToAutomateTarget`. | | Global mouse-down monitor | Dismiss the translation panel when the click goes to another app | Installed only while the panel is visible and removed on close. The event is discarded; no key events, location, text or app identity are read. Not a key tap and needs no Input Monitoring. | ## Clipboard rules 1. Poll only `changeCount`; read `.string` only when it changes. 2. Require two changes within the window with identical, non-empty text. 3. Ignore our own writes (`com.schihei.sprachmittler.own`), `org.nspasteboard.TransientType` and `org.nspasteboard.ConcealedType`. 4. Keep at most two strings in memory; clear them after the session starts or the window expires. 5. Snapshot all pasteboard items and types before a paste fallback; force lazy data up front; restore only if `changeCount` still matches our write. 6. Never log clipboard content, not even truncated. 7. Copy is user-initiated; Replace restores the previous clipboard. There is no automatic clipboard mutation. ## Endpoint policy (pseudo-code) ```swift func validate(_ url: URL, allowRemote: Bool) throws { guard let scheme = url.scheme?.lowercased(), ["http", "https"].contains(scheme) else { throw EndpointRejection.scheme } guard url.user == nil, url.password == nil, url.query == nil, url.fragment == nil else { throw EndpointRejection.form } let host = url.host?.lowercased() ?? "" let isLoopback = ["127.0.0.1", "localhost", "::1"].contains(host) if isLoopback { return } guard allowRemote else { throw EndpointRejection.remoteNotAllowed } guard scheme == "https" else { throw EndpointRejection.remoteRequiresHTTPS } } ``` ## Logging - Allowed: model name, digest prefix, token counts, durations, character counts, chunk counts, warning kinds, error kinds, changeCount deltas, short SHA-256 hashes at `privacy: .private`. - Forbidden: selected text, translations, prompt text, pasteboard strings, clipboard item types that identify content, app names, file paths, e-mail addresses, URLs. - Diagnostics is an in-memory, bounded list of error kinds and timings. It has no text field. ## Licensing notice (product, not code) - Sprachmittler bundles no models. - Hy-MT3 is Apache-2.0 per the model card. Settings shows the licence status and model digest; this is guidance, not legal advice. - Before commercial distribution, re-check the model card and the GGUF conversion provenance and record the result in an ADR.