# Privacy & Security
This document describes NOOP's privacy posture, security model, and the hardening
applied to the parts of the codebase that touch untrusted input. It is written
against the actual source tree; file paths and identifiers below are real and can
be checked.
> **Not affiliated with WHOOP. Not a medical device.** NOOP is an independent,
> unofficial, local-first companion app. It interoperates with a WHOOP strap that
> **you own**, reading **your own** biometric data from **your own** device. It is
> not affiliated with, endorsed by, or connected to WHOOP, Inc. All computed
> outputs (Charge, Effort, Rest, HRV, SpO₂, skin temperature, respiratory rate — Charge/Effort/Rest
> being NOOP's own recovery/strain/sleep scores, not WHOOP's)
> are approximations and are not clinically validated. Self-tracking features such
> as the Mind / mood check-in and nutrition import are **informational only** and are
> **not** a diagnosis, treatment, or dietary/medical advice. Use at your own risk;
> your data stays on your device unless you explicitly export it or enable an optional network path.
> See `DISCLAIMER.md`, `TERMS.md`, and
> `ATTRIBUTION.md` at the repo root.
---
## 1. Design principle: offline by default
NOOP is **offline by default**. The biometric pipeline — strap → on-device decode →
local SQLite — has no network layer at all: no phone-home, no analytics, no accounts,
no login, no cloud sync, and no telemetry. Everything NOOP computes about you lives in a
single SQLite file on your own device.
**Offline does not mean the app has no internet permission or never makes a request.**
Strap collection and local analytics work without a network connection. The update check is
**on by default**; optional features can send data to destinations you configure.
[§1.1](#11-network-paths-canonical-inventory) is the canonical inventory of network paths,
their defaults, triggers and payloads.
The main local data paths are:
| Path | Transport | Direction |
|------|-----------|-----------|
| Live collection | Bluetooth LE, strap → device | Read-only from the strap |
| File import (Apple Health, WHOOP CSV, nutrition CSV) | User-selected files on disk | Read-only from disk |
| Apple Health export, incl. iOS "Export for Shortcuts" | On-device, user-initiated | NOOP → your Apple Health, on your device only (§1.3) |
These local hand-offs do not upload data through NOOP's HTTP clients. What another app or
the operating system does with shared data is governed by that service and your settings (§1.3).
### 1.1 Network paths (canonical inventory)
The following table covers NOOP's direct HTTP clients. A path can make several requests;
these are features, not a count of individual requests or destinations.
| Path / platforms | Default and trigger | What is sent | Destination |
| --- | --- | --- | --- |
| AI Coach / macOS, iOS, Android (§1.1a) | Unconfigured initially; requests after provider setup for chat, model refresh or enabled briefs | Provider authentication when required; conversation text; health summaries only with data consent; optional chart attachment on Apple/Gemini | Chosen provider or Custom server |
| Oura history import / opt-in macOS, iOS build (§1.1b) | Compiled out by default; user starts authorization/import | OAuth credentials, authorization/refresh tokens and history query parameters; no existing NOOP health data | `cloud.ouraring.com`, `api.ouraring.com` |
| Update check / macOS, iOS, Android (§1.1c) | Automatic check **on by default**, at most daily after onboarding/Terms; manual check on tap | Public release `GET`; no health data or app-added user/account identifier | `api.github.com` |
| Self-hosted push / Android (§1.1d) | Experimental, **off by default**; configured export after offload/launch or on tap; explicit connection test | Bearer authentication; capability `GET`; versioned health batches with local installation/device IDs on export | User-owned HTTP(S) endpoint |
**Platform services are a separate boundary.** Apple's workout route view uses `MKMapView`
(`Strand/Screens/WorkoutDetailView.swift`), which can load map data for the displayed region.
The route overlay is built locally; that does not guarantee the map makes no network requests.
Opening a web link hands it to a browser; Apple Health/Health Connect and sideloaders have their
own network and sharing settings. This inventory does not promise those services are offline.
For ordinary strap collection without NOOP's direct HTTP requests: turn off **Check automatically**
in Settings → About, leave the AI Coach and self-hosted push unconfigured, use a default build
without the Oura cloud import, and do not tap the manual update check. This does not disable
platform-service traffic such as the route map.
Networking clients live in the app targets: `Strand/AI/`, `Strand/Oura/`, `Strand/System/UpdateChecker.swift`,
and Android's `ai/`, `update/` and `push/` packages. The biometric pipeline and Swift packages under
`Packages/` do not make runtime network requests; shared parsers such as `SseDeltas` only process
already-received text. Android's Oura support is local BLE, with no equivalent to the cloud import.
The package manifests reference dependency *download* URLs that Swift Package Manager
resolves at build time, never at runtime:
```
Packages/WhoopStore/Package.swift → https://github.com/groue/GRDB.swift.git
Packages/StrandImport/Package.swift → https://github.com/weichsel/ZIPFoundation.git
Packages/NoopLocalAccess/Package.swift → https://github.com/groue/GRDB.swift.git
```
GRDB.swift is the SQLite layer; ZIPFoundation is the archive reader used by the
importers. Neither opens a socket.
### 1.1a The AI Coach (optional, provider setup required)
The AI Coach sends requests directly to the provider you choose:
- **Unconfigured until you set it up.** Hosted providers (Anthropic, OpenAI and Google Gemini)
require your API key. A Custom OpenAI-compatible server requires an explicit Connect action;
its key is optional. A server on the same machine receives requests locally; a LAN or remote
server receives them over that network. "Self-hosted" does not necessarily mean on-device.
- **What triggers a request.** Sending a question, refreshing the provider's model list, or
connecting a Custom server (which fetches its models). With data consent, opening an empty
Coach conversation can generate a brief. A separately enabled morning brief can also request
one without a chat question. Saving a hosted-provider key alone does not fetch models.
- **What is sent.** Chat requests include your question and conversation context. With the
separate, default-off data consent, they also include compact summaries of recent metrics
and workouts. Additional on-device-signal summaries require another opt-in. On Apple,
Gemini can also receive a rendered chart when its default-off multimodal option is enabled
and you attach one. Model-list requests send authentication where required, without health
summaries. Scheduled briefs require provider configuration and data consent.
- **What is not automatically attached.** Raw biometric streams, BLE frames and local device
identifiers. Text you type and charts you attach can contain personal information.
- **Your provider, your relationship.** NOOP operates no intermediary. Provider retention and
processing policies apply to what you send. The conversation is also stored locally in NOOP.
Code: `Strand/AI/AICoach.swift`, `Strand/AI/AIProvider.swift`, `Strand/AI/Providers/`,
`Strand/System/CoachBriefScheduler.swift`; Android `com.noop.ai` and `com.noop.ui.CoachViewModel`.
### 1.1b The Oura history import (compiled out by default, bring your own OAuth app)
The Oura history import pulls your own historical Oura data into NOOP over Oura's official
API — a one-time, foreground backfill you trigger yourself, not an ongoing background sync
(nothing runs on a timer, at launch, or in the background):
- **Not in the binary unless you build it in.** Every file of the lane's network code
(`Strand/Oura/*.swift` and its Data Sources card) sits behind the `OURA_CLOUD_IMPORT`
compilation condition, which is **unset in every default build** — the release binaries
and any plain `xcodegen && xcodebuild` from a clean checkout contain **zero Oura network
code**, provably, at the byte level. The condition is set only by the untracked
`Strand/Oura/OuraSecrets.xcconfig` you create yourself from the example template, which
also carries your own Oura developer app's client ID/secret — so the code and the
credentials arrive in the same deliberate act. Then the import runs only when you tap
**"Import your Oura history"** in Data Sources. (Belt-and-braces, the runtime guard
remains too: absent/blank credentials disable the lane — `OuraCredentials.fromBundle`.)
- **What is sent.** An OAuth authorization-code handshake — you sign into Oura's own
consent page (`cloud.ouraring.com`) through Apple's system `ASWebAuthenticationSession`,
not an in-app WebView NOOP controls — followed by bearer-token `GET` requests to
`api.ouraring.com/v2/usercollection/*` carrying only your access token and the
endpoint/date-range parameters needed to page through your history. No NOOP data rides
along with these requests beyond the token itself.
- **What comes back.** Your own Oura data — sleep, readiness, activity, workouts, heart
rate, and the other endpoints your granted scopes cover — flowing **in**, once, to seed
your local database. Oura's own readiness/sleep scores are kept for reference only
(`ref_*`/`oura_*` metric keys); NOOP's own Charge/Effort/Rest are never derived from
them and are never sent anywhere.
- **What is NOT sent.** None of your existing NOOP data — no WHOOP streams, no other
imports, no computed scores — ever leaves the device via this lane. It is inbound-only.
- **Your app, your grant, revocable at Oura.** You register your own OAuth app at Oura's
developer portal; NOOP runs no server in between. Revoke access any time from your Oura
account settings, or tap **Forget Oura access** in NOOP, which signs out locally and
deletes the stored tokens plus every row this lane wrote — including the raw archive
(`ouraRaw` table, see `docs/DATA_MODEL.md`).
- **Tokens in the Keychain, not a plist.** The access/refresh tokens are stored via
`OuraTokenStore` as a single Keychain item (`kSecAttrAccessibleAfterFirstUnlock`), the
same pattern as the AI Coach's API key (`AIKeyStore`) — never UserDefaults, never on
disk in the clear.
If you never build the lane in, your binary cannot call `ouraring.com` — the code is not there.
### 1.1c The update check
NOOP is sideloaded on every platform — there is no App Store or Play Store to update it — so an install
that is never told about a release simply runs an old build indefinitely. Two paths address that, and
both read the **same** public endpoint: `https://api.github.com/repos/ryanbr/noop/releases/latest`.
- **"Check for updates"** in Settings → About. Runs only when tapped. It has always existed;
it was previously undocumented here, which is why this section is new rather than merely amended.
- **"Check automatically"**, beside it. At most once a day, after onboarding and the
Terms gate, NOOP reads that endpoint and — if a newer release exists — puts a row in the Updates
inbox. **On by default**, and switchable off, at which point it makes no request at all.
What is sent: an unauthenticated `GET` of a public URL, with normal HTTP headers but no app-added
user/account identifier or biometric data. What comes back is a version number and the
release notes. **It never installs anything** — on iOS no API permits that for a sideloaded app (see
[docs/IOS.md](IOS.md)); the row tells you a release exists and where to get it.
The request is a plain HTTPS call, so your IP address is visible to GitHub exactly as it would be if
you opened the releases page in a browser. If that is not a trade you want, turn the toggle off; the
manual button then remains the only way NOOP touches the network for this.
Code: `Strand/System/UpdateChecker.swift` + `Strand/System/UpdateAvailability.swift` (Swift),
`com.noop.update.UpdateCheck` + `com.noop.update.UpdateAvailability` (Android).
### 1.1d Self-hosted push (Experimental, Android, off by default)
Self-hosted push keeps a fresh one-way copy of selected rows on a machine the user controls. It is
not a NOOP cloud, account, restore path, or two-way sync:
- **Off until configured.** No endpoint means the worker does not send. The user supplies both the
HTTP(S) URL and bearer token; NOOP operates no intermediary or receiver.
- **After offload, at launch, or explicitly now — always outside BLE sync.** Automatic work is queued
after a complete strap offload and at app launch to catch up; the user may also press **Export now**.
An unavailable or slow endpoint cannot delay BLE collection, local persistence, analytics, or UI.
- **What is sent.** The finite, versioned stream registry in
[`PUSH_PROTOCOL.md`](PUSH_PROTOCOL.md) includes biometric rows and rolling snapshots of selected
recomputed/editable tables, scoped by a locally generated installation ID and local device ID.
- **What comes back.** The receiver may advertise only a subset of NOOP's fixed v1 stream names, and
acknowledges submitted batches. NOOP never fetches health rows, remote changes, commands, URLs,
schemas, settings, or conflict decisions. The local database remains authoritative.
- **Connection test.** The explicit **Test connection** action performs only the authenticated
capability `GET`; it does not open the health database or submit a batch, and uses the same
network policy as export work: Wi-Fi only by default, with an explicit option to allow mobile
and other connected networks.
- **Useful diagnostics without leaking secrets.** The screen distinguishes DNS lookup, TLS
certificate/handshake, timeout, connection-refused, unreachable/reset connection, HTTP status,
capability/acknowledgement, local encoding, and local database failures. It stores and displays
only that stable category and (where applicable) the numeric HTTP status. Bearer tokens, response
bodies, health rows, endpoint-derived exception text, and stack traces are never placed in push
status. Retryable failures also say that backoff is scheduled; permanent failures identify the
configuration or receiver area to check.
- **Credential transport.** The bearer token authenticates every capability `GET` and batch `POST`. Public cleartext endpoints
are rejected; HTTP is limited to numeric loopback/private/link-local/ULA addresses. Cleartext
hostnames are rejected, so DNS cannot move an allowed local URL to a public address. Even on an
allowed IP, HTTP exposes the token and batch contents locally, so HTTPS remains preferable.
The repository ships the Android client and protocol document, not a server. The feature remains
Experimental and default-off under the boundary in [`SCOPE.md`](SCOPE.md).
### 1.2 The macOS sandbox (and what it means for the AI Coach and the Oura import)
On macOS the App Sandbox is the backstop. The app ships with a minimal entitlement set
(`Strand/Resources/Strand.entitlements`):
```xml
com.apple.security.app-sandbox
com.apple.security.device.bluetooth
com.apple.security.files.user-selected.read-write
com.apple.security.network.client
```
That is the entire entitlement file. Four keys:
- **`app-sandbox`** — the process runs inside the macOS App Sandbox container.
- **`device.bluetooth`** — permits BLE access to talk to the strap. The matching
`NSBluetoothAlwaysUsageDescription` string (declared in `project.yml`) states
plainly: *"NOOP connects directly to your WHOOP strap over Bluetooth to read heart
rate, R-R intervals, battery, and sensor data locally on your Mac. Nothing leaves
your device."*
- **`files.user-selected.read-write`** — lets the app read import files the user
explicitly picks (and write the database in its own container).
- **`network.client`** — outbound socket access. Added for the AI Coach on a
signed/sandboxed build, where the sandbox otherwise refuses any socket the app tries
to open (#128); the Oura history import (§1.1b) now relies on the same entitlement. The
ad-hoc distributed build applies **no** entitlements at all (unsigned build + ad-hoc
re-sign), so this key only matters for a signed/sandboxed build. The update check (§1.1c)
also uses outbound network access. The entitlement permits connections; feature code
determines when they happen and what they carry.
Notably **absent**:
- `com.apple.security.network.server` — no inbound listener.
- No `files.downloads`, `files.documents`, or any broad filesystem entitlement —
the app cannot wander the disk; it sees only what the user hands it through the
open panel, plus its own sandbox container.
The sandbox restricts filesystem and device access, but `network.client` is **not a
destination allow-list** or proof that only the documented features can connect. As
[Apple documents](https://developer.apple.com/documentation/bundleresources/entitlements/com.apple.security.network.client),
it permits outgoing connections. The network boundaries in §1.1 rely on the source's feature
gates and request construction, not on an OS restriction to particular servers.
> **Note on Hardened Runtime.** `project.yml` currently sets
> `ENABLE_HARDENED_RUNTIME: NO` for local development builds. Distributable /
> notarized builds should enable the Hardened Runtime; it composes with, and does
> not weaken, the sandbox entitlements above.
### 1.3 iOS Apple Health export ("Export for Shortcuts") — on-device, user-initiated, one-way
On iOS NOOP can hand your metrics to **Apple Health**. This is the one path where data leaves
NOOP's own store — but it never leaves your **device**, and never touches the network.
- **You initiate it; NOOP writes only what you enable.** Nothing is exported automatically. You
choose which metrics to push, and NOOP writes only those, only when you trigger the export. There
is no background sync.
- **On-device, not a network upload.** The export is a local hand-off to Apple Health on the same
phone. No NOOP server, no cloud, no telemetry is involved — consistent with §1.
- **HealthKit-free option.** The **"Export for Shortcuts"** path produces data for the Apple
Shortcuts app rather than writing through HealthKit directly, so you can route it with a Shortcut
you control. Where it does write to Apple Health, it does so through Apple's permission-gated APIs:
you grant access per data type, and you can revoke it in iOS Settings at any time.
- **Once it's in Apple Health, it's yours and Apple's, not NOOP's.** NOOP cannot read back, manage,
or delete what you exported; that store, its backups (e.g. iCloud Health if *you* enabled it), and
its sharing settings are governed by Apple and by your choices. **You are responsible for the data
you push into Apple Health and for anything you or your Shortcuts then do with it.** See
`DISCLAIMER.md` §5.3 and `TERMS.md` §5.
---
## 2. Data at rest
### 2.1 Where the data lives
All durable data is stored in a single GRDB/SQLite database. The Swift apps (macOS and
iOS, which share the `WhoopStore` package) open it at (`Strand/Collect/StorePaths.swift`):
```
/OpenWhoop/whoop.sqlite
```
Because the app is sandboxed, `` resolves **inside the app's
sandbox container**, not the user's global `~/Library/Application Support`. Other
apps cannot read it through normal filesystem access. (On Android the equivalent store
is a Room/SQLite database in the app's private storage; the rest of this section
describes the GRDB/SQLite store shared by the macOS and iOS apps.)
The schema is defined by a versioned `DatabaseMigrator` in
`Packages/WhoopStore/Sources/WhoopStore/Database.swift` (currently schema version 9).
It holds exactly the kinds of data you would expect from the features:
- **Decoded biometric streams** (durable): `hrSample`, `rrInterval`, `spo2Sample`,
`skinTempSample`, `respSample`, `gravitySample`, `battery`, `event`.
- **Derived/cached metrics**: `sleepSession`, `dailyMetric`, `workout`, `journal`,
`appleDaily`, and the generic long-format `metricSeries`.
- **Your own entries and imports**: daily **mood check-ins** (the Mind feature) and imported
**nutrition** figures (from a Cronometer / MacroFactor CSV) are stored the same way — locally, in
this database, never transmitted. They are self-tracking notes, not clinical records (see
`DISCLAIMER.md` §5).
- **A transient raw outbox** (`rawBatch`): compressed raw BLE frames, **prunable**.
- **Device records** (`device`): strap id, MAC, name, first/last-seen timestamps.
The database is opened in WAL journal mode with `synchronous = NORMAL` and a busy
timeout, tuned for bulk import/backfill writes
(`Packages/WhoopStore/Sources/WhoopStore/WhoopStore.swift`). WAL means you will also
see `whoop.sqlite-wal` and `whoop.sqlite-shm` sidecar files alongside the main
database — they live in the same container.
### 2.2 Encryption
The SQLite file is **not encrypted at rest by NOOP itself.** Confidentiality of the
data on disk relies on the platform:
- **FileVault** (full-disk encryption, on by default on modern Macs) protects the
database whenever the disk is at rest / the machine is powered off. On iOS and
Android the equivalent is the platform's on-by-default device encryption / data
protection, which guards the file while the device is locked.
- The **sandbox container** (app container on macOS/iOS, private app storage on
Android) keeps other user-space apps from reading the file directly.
What this does **not** protect against: an attacker with your unlocked, logged-in
session, or a backup/Time Machine copy of the container made while FileVault is
unlocked. The data is plaintext SQLite once the volume is mounted.
> **Option: SQLCipher.** GRDB supports SQLCipher (an encrypted SQLite build) as a
> drop-in. Wiring NOOP's `DatabaseQueue` to a SQLCipher build with a
> Keychain-derived key would give at-rest encryption independent of FileVault. This
> is not enabled in the current build, but the persistence layer is small and
> centralized (one `WhoopStore.init(path:)`), so it is a contained change.
### 2.3 Data minimization & pruning
The raw-frame outbox (`rawBatch`) is treated as transient, not as the system of
record — the decoded streams are durable, the raw frames are a compressed,
**prunable** buffer. The prune policy in
`Packages/WhoopStore/Sources/WhoopStore/RawOutbox.swift` deletes old batches:
```sql
DELETE FROM rawBatch WHERE syncedAt IS NOT NULL AND syncedAt < ?
```
So raw captures do not accumulate forever. (The `syncedAt`/upload-related columns are
schema scaffolding inherited from the upstream collection library; in NOOP's offline
configuration nothing uploads, and the raw buffer is purely a local replay/recovery
aid.)
### 2.4 Diagnostics: the strap connection log
When a strap won't connect or behaves oddly, the single most useful thing a user can
send is the connection log. NOOP keeps one so it can be shared **without** needing
`adb` or a developer setup (this is what made issues #17/#18 reportable), and the same
log doubles as the primary tool for **debugging and protocol development** (see
`ANDROID.md` → "Debugging the strap connection").
**What it is.** The BLE client (`android/.../ble/WhoopBleClient.kt`,
`Strand/BLE/BLEManager.swift` on the Swift side — macOS and iOS) keeps an **in-memory
ring buffer** — the last
2000 log lines on Android — of the connection's control flow: scan results (strap
advertised name + RSSI), the bond/handshake state machine, command names with their
outbound payload **hex**, and offload progress (trim cursors, chunk acks). It is held
in RAM only; the "Share strap log" button writes it to a private app-cache file at
share time and hands that file to the OS share sheet. Nothing is uploaded by NOOP.
**What it does *not* contain.** No account credentials (there is no account), no
decoded biometric *values* (heart-rate numbers, R-R intervals, SpO₂, skin-temp are not
written to the log — only control-plane command names and frame-routing), and no
hello-token or serial hex (the handshake lines log *that* a step happened, not its
secret payload). The one mild identifier is the strap's advertised name (e.g.
`WHOOP 5AG…`), which the user chooses to include when they tap Share.
**logcat is opt-in (debug mode), off by default.** By default the log is mirrored
**only** to the in-app buffer — it is *not* written to Android's system log
(`Log.d`/logcat). A user has no reason to emit the connection log to the device-wide
log, so they don't. Developers who want to watch a session live over
`adb logcat -s WhoopBleClient` turn on **Settings → Strap → "Debug logging"**
(persisted as `NoopPrefs.KEY_DEBUG_LOGGING`, default `false`); the flag drives
`WhoopBleClient.debugLogcat`, which gates the single `Log.d` call. The in-app buffer
and the "Share strap log" export work the same whether or not debug logging is on, so
the diagnostic path is always available without ever defaulting users into logcat.
### 2.5 Wrist alerts: the Android notification listener
Android wrist alerts (buzz the strap when chosen apps notify you) need a
`NotificationListenerService` — that's the only way to register in the OS's
**Notification Access** list and be told a notification was posted. Notification
access is a powerful permission, so for a privacy-first app it's worth being precise
about what NOOP does and does not do with it:
- **Off by default, double opt-in.** The service does nothing until you both grant
Notification Access in system settings *and* turn on **Wrist alerts** in NOOP, then
enable specific apps (each app is off by default).
- **It reads only the posting package name — never content.** On a posted
notification NOOP looks at *which app* posted (and skips ongoing / foreground-service /
group-summary noise), checks your settings (master toggle, that app's opt-in, quiet
hours, only-when-worn), and if all pass, sends a haptic-pattern command to the strap.
The notification's title, text, sender, and extras are never read, stored, logged, or
transmitted.
- **Nothing leaves the device.** There is no server; the only output is a Bluetooth
buzz to your own strap. (`android/.../notif/NoopNotificationListener.kt`.)
---
## 3. Threat model
NOOP parses two classes of **untrusted input**: bytes arriving over Bluetooth, and
files chosen for import. Both are treated as hostile and validated before anything
reaches the database. Apple Health and WHOOP files in particular can be very large
(multi-hundred-MB to multi-GB), so resource exhaustion is part of the model.
What is explicitly **out of scope**: NOOP cannot defend the data against an attacker
who already controls your unlocked user session (see §2.2), and it makes no claim of
cryptographic authentication of the strap — BLE pairing/bonding security is provided
by the OS Bluetooth stack and the device, not by NOOP.
### 3.1 Threat A: a malicious or malfunctioning BLE peer
A device advertising as a strap (or a glitching real strap) could send malformed,
truncated, oversized, or adversarial frames. The protocol core
(`Packages/WhoopProtocol/`) is the reverse-engineering layer and is the first line of
defense.
**Integrity-gated parsing.** Every frame is checked against its envelope before it is
allowed to drive any application state. `Framing.swift` implements three checksums
verbatim from the wire formats:
- `crc8` (poly 0x07) over the length header,
- `crc32` (zlib/reflected) over the inner payload,
- `crc16Modbus` for the WHOOP 5.0 header (ported from the `goose` work).
`verifyFrame(_:)` (and the family-aware `verifyFrame(_:family:)`) return
`ok == true` only when the header CRC, the payload CRC32 **and** the configured size
rules all hold. The size half matters as much as the checksums: a frame must be
at least 11 bytes on WHOOP 4.0 and 13 on 5.0/MG, and must carry *exactly* the total its
length field declares (`length + 4`, `declLength + 8`), so a truncated frame and one
with trailing bytes past its own end are both rejected. If the payload CRC32 cannot be
computed safely, the earlier size rule is the rejection reason; every frame reaching the
payload-integrity decision has a CRC result. The outcome is one verdict plus one non-optional reason:
```swift
guard total >= FrameLimits.whoop4MinimumFrameBytes else { /* reject minimum */ }
guard total == frame.count else { /* reject length; retain any safe CRC diagnostic */ }
let crc32OK = crc32(frame, 4, length) == u32le(frame, length)
let reason = integrityRejectReason(headerCRCOK: crc8OK, payloadCRCOK: crc32OK)
return FrameCheck(ok: reason == .none, /* … */ reason: reason)
```
The live BLE path then refuses anything that fails, in a single condition. In
`Strand/BLE/FrameRouter.swift`:
```swift
let parsed = parseFrame(frame)
// `ok` is the FULL verdict — never let bad bytes drive state.
guard parsed.ok else { return }
```
The same gate guards clock correlation (`Strand/Collect/ClockCorrelation.swift`),
historical-metadata classification, live and historical stream extraction, and the
data-range reply — so a corrupt frame can neither update the displayed metrics, nor
poison the device-clock model, nor advance the strap's trim cursor. `parsed.rejectReason`
carries the cause, so a rejection is counted and attributable rather than silent.
**What this does not claim.** A CRC is not a signature, so none of the above asserts
**authenticity**: a peer that forms the envelope correctly is not excluded. Nor is the
claim "every frame consumer" — six state-driving consumers require the full verdict.
Evidence-preserving readers deliberately keep the opposite direction: a raw history
frame that fails is *archived* rather than dropped, so the durable copy of a frame the
strap is about to release survives.
**Bounds-checked decoding.** Field reads never index past the end of the buffer, and
never reach into the frame's own CRC32 trailer. The low-level readers in
`Interpreter.swift` take an explicit `limit` and return `nil` instead of trapping:
```swift
@inline(__always) private func readU16(_ f: [UInt8], _ off: Int, _ limit: Int) -> Int? {
off >= 0 && off + 2 <= limit ? Int(f[off]) | (Int(f[off + 1]) << 8) : nil
}
```
The `limit` is the **minimum** of where the trailer starts and how many bytes the frame
actually has. Both halves are load-bearing: the trailer start is derived from the
*declared* length and points past the buffer on a truncated frame, while the buffer size
alone would let a frame sitting at the family minimum have its own checksum trailer
decoded as a sequence number, a command byte or a metadata type. The argument is
required rather than defaulted, so adding a field read without deciding its bound does
not compile. The one deliberate exception is the 8-byte history-end acknowledgement
block echoed back to the strap verbatim, which reaches into the trailer by construction
and is an opaque echo rather than a decoded field.
Schema-driven field extraction skips any field whose offset is out of range
(`guard let val = readDType(frame, fld.off, dtype, limit) else { continue }`), the same
bound applies to the per-type post-hooks, and the `FieldBuilder` clamps every slice to
the real buffer length (`let end = min(off + length, frame.count)`). The WHOOP 5.0 path
adds explicit minimum-length and `payloadEnd <= frame.count` guards before slicing the
payload or trailer. A short or lying length field therefore yields a partial parse,
never an out-of-bounds read.
**Sane-value gating at the application edge.** Even a CRC-valid frame is range-checked
before it updates the UI/state. The realtime handler discards implausible heart rates
(`hr >= 30, hr <= 220`) and only overwrites R-R intervals when the frame actually
carries them — so a single bad-but-valid packet can't wipe good state.
**Reassembly is bounded by the declared length.** The `Reassembler` resynchronizes on
the `0xAA` start-of-frame byte, discards leading garbage, and only emits a frame once
`length + 4` bytes are present — it does not unboundedly buffer arbitrary data. A
declared total below the family minimum (11 bytes on WHOOP 4.0, 13 on 5.0/MG) or above
the 8192-byte ceiling is not a frame at all: that start byte is dropped and the scan
resyncs on the next one. Sub-minimum drops are counted rather than discarded silently.
### 3.2 Threat B: a malicious import file (zip bombs, XML bombs, huge exports)
Both importers live in `Packages/StrandImport/` and assume the file is hostile.
**Apple Health (`AppleHealthImporter.swift`).** Apple Health exports routinely exceed
1 GB, and a malicious one could be far worse.
- **Streaming SAX parse, never DOM.** The importer parses with `XMLParser` /
`XMLParserDelegate` over an `InputStream` opened directly on the file. It explicitly
does **not** use `XMLParser(contentsOf:)`, which would load the whole multi-hundred-
MB document into memory first. Element handling runs inside a per-element
`autoreleasepool` so temporaries from tens of millions of elements drain instead of
accumulating — peak memory stays bounded regardless of file size.
- **Zip-bomb cap on decompression.** When the input is a `.zip`, `export.xml` is
extracted to a temp file in fixed-size chunks with a running budget; the moment the
decompressed total crosses the ceiling, extraction aborts:
```swift
var written = 0
let cap = 8 << 30 // 8 GB decompressed ceiling — zip-bomb guard
_ = try archive.extract(entry, bufferSize: 1 << 20) { chunk in
written += chunk.count
if written > cap { throw ImportError.xmlParseFailed("export.xml too large") }
try handle.write(contentsOf: chunk)
}
```
Chunks go straight to disk, so a bomb cannot inflate RAM. This deliberately replaced
an earlier pipe-fed parser that could deadlock or crash on a malformed export.
- **Robust error handling.** Parse failures are surfaced as typed `ImportError`s; the
delegate distinguishes a genuinely malformed document from a benign empty/EOF
condition rather than crashing.
- **Temp files are cleaned up** via `defer { try? FileManager.default.removeItem(at: tmp) }`.
**WHOOP CSV export (`WhoopExportImporter.swift`).** The WHOOP data export is a small
bundle of CSV files, but the same defensive posture applies.
- **Per-entry size ceiling.** Each CSV is capped at 256 MB
(`maxEntryBytes = 256 << 20`). Folder imports skip any file larger than the cap;
zip imports reject entries whose *declared* uncompressed size exceeds it **and**
enforce a running byte budget during extraction, so a ZIP64 header that lies about
its size is still stopped mid-stream:
```swift
let declared = Int(exactly: entry.uncompressedSize) ?? Int.max
if declared > Self.maxEntryBytes { continue }
...
if written > Self.maxEntryBytes { throw CancellationError() }
```
- **CRC32 verification on extraction.** `archive.extract()` verifies each entry's
CRC32 (ZIPFoundation's `skipCRC32` defaults to `false`) and throws on a mismatch or
truncation. A corrupt/truncated/oversized entry is skipped entirely rather than
partially imported — no half-rows reach the database.
- **Filename allow-list.** Only four known CSV names
(`physiological_cycles.csv`, `sleeps.csv`, `workouts.csv`, `journal_entries.csv`)
are ever read; everything else in the archive is ignored. Matching is by filename,
case-insensitively, so the parser never executes or interprets arbitrary archive
members.
- **Tolerant, header-name-driven parsing.** Columns are matched by normalized header
name (not position), every column is optional, BOMs are stripped, and rows with no
usable timestamp are dropped. Malformed input degrades to fewer rows, not a crash.
**Nutrition CSV (`NutritionCsvImport.swift`).** The nutrition importer (Cronometer /
MacroFactor daily-summary exports) reuses the same shared CSV reader (`CSVParsing.swift`)
and the same tolerant posture: headers are matched case-insensitively by name (date /
calories / protein / carbs / fat / weight), every column is optional, non-`yyyy-MM-dd`
dates and value-less rows are **skipped and counted, never fatal**, and only the
recognised numeric fields are read — no archive member or cell is ever executed or
interpreted. The result is projected into the long-format `metricSeries` store under the
dedicated source id `nutrition-csv`, alongside your other metrics and entirely on-device.
---
## 4. What NOOP does *not* collect or transmit
- **No NOOP account, no NOOP login.** Nothing to sign into with NOOP itself; NOOP
issues no credentials of its own. The one exception is opt-in: the Oura history import
(§1.1b) has *you* sign into *your own* Oura account, at Oura's own login page, over
OAuth — NOOP never sees your Oura password, only the resulting tokens, kept in the
Keychain.
- **No telemetry / analytics / crash reporting.** No third-party SDKs of that kind.
- **No NOOP cloud, account sync, or operated remote backup.** The Oura history import (§1.1b) is
**inbound only**. Android self-hosted push (§1.1d) is the sole standing outbound export: off by
default, one-way, and directed only to the endpoint the user configured and owns.
- **No advertising identifiers, no tracking.**
- **No WHOOP account or API credentials.** NOOP talks only to the strap over local
BLE; it does not authenticate against, or pull from, any WHOOP server. (Oura is the
one account-based exception — see above and §1.1b.)
---
## 5. Hardening summary
| Surface | Risk | Mitigation | Where |
|---------|------|------------|-------|
| Process | Data exfiltration / network egress | Feature defaults, triggers, destinations and payloads are documented once in the [§1.1 inventory](#11-network-paths-canonical-inventory), including update checks and platform-service boundaries. No NOOP server, account or telemetry. Internet permission is not a destination allow-list. | App HTTP clients and source paths in §1.1 |
| Oura history import | OAuth token / scope leakage, cross-account data mixing | Compiled out by default (`OURA_CLOUD_IMPORT`, §1.1b); tokens Keychain-only (`kSecAttrAccessibleAfterFirstUnlock`, never UserDefaults/plist); fixed OAuth scopes set at build time; raw + normalized rows partitioned under `deviceId = "oura-api"`; Oura's own scores kept reference-only (`ref_*`/`oura_*` metricSeries keys, never NOOP's Charge/Effort/Rest); `.cloudImport` is structurally priority-2 so it never seizes a WHOOP day; Forget Oura access purges tokens + every `oura-api` row incl. the raw archive | `Strand/Oura/OuraTokenStore.swift`, `Strand/Oura/OuraConnectModel.swift`, `Packages/WhoopStore/Sources/WhoopStore/OuraRawStore.swift` |
| Filesystem | Broad disk access | Only `files.user-selected.read-write`; data stays in the sandbox container | `Strand.entitlements`, `Strand/Collect/StorePaths.swift` |
| BLE frames | Malformed / adversarial packets | CRC8 + CRC32 (+ CRC16 for v5) gating; reject on failure | `WhoopProtocol/Framing.swift`, `Strand/BLE/FrameRouter.swift` |
| BLE frames | Out-of-bounds reads from short/lying length | `nil`-returning bounds-checked readers; slice clamping; min-length guards | `WhoopProtocol/Interpreter.swift` |
| BLE frames | Garbage / partial fragments | SOF-resync reassembler bounded by declared length | `WhoopProtocol/Framing.swift` (`Reassembler`) |
| App state | Implausible-but-valid values | Range gates (e.g. HR 30–220) at the state edge | `Strand/BLE/FrameRouter.swift` |
| Health import | XML bomb / multi-GB DOM blowup | Streaming SAX over `InputStream`; per-element autorelease pool | `StrandImport/AppleHealthImporter.swift` |
| Health import | Zip bomb | 8 GB decompressed ceiling, chunked to disk, hard abort | `StrandImport/AppleHealthImporter.swift` |
| CSV import | Zip bomb / oversized entries | 256 MB per-entry cap (declared + running budget); CRC32 verify | `StrandImport/WhoopExportImporter.swift` |
| CSV import | Arbitrary archive members | Filename allow-list; tolerant optional-column parsing | `StrandImport/WhoopExportImporter.swift` |
| Data at rest | Disk theft / offline access | Relies on FileVault + sandbox container; SQLCipher available as an option | `WhoopStore/WhoopStore.swift` |
| Diagnostics log | Leaking the strap log to the device-wide system log | In-app ring buffer only; logcat mirroring is **opt-in** (Settings → Strap → "Debug logging", default off); no biometric values / tokens logged (§2.4) | `android/.../ble/WhoopBleClient.kt` (`debugLogcat`), `android/.../ui/MainActivity.kt` (`NoopPrefs`) |
---
## 6. Reporting a security issue
NOOP is a hobbyist, non-commercial interoperability and research project provided
**as-is, with no warranty**, for personal and educational use only (see
`DISCLAIMER.md`). If you find a security or privacy issue, please open a GitHub issue
describing the problem and a reproduction; sensitive reports can be coordinated
privately via the contact on the project's GitHub profile. Issues will be reviewed in
good faith.
---
## 7. Credits
The protocol and persistence work NOOP builds on is community reverse-engineering of
hardware the user owns, used for interoperability:
- **`johnmiddleton12/my-whoop`** — the WHOOP 4.0 BLE framing/command/decode work and
the collection logic the `WhoopProtocol` / `WhoopStore` packages and the app's
collection layer are adapted from.
- **`b-nnett/goose`** — the WHOOP 5.0 protocol (the `fd4b0001-…` service family, the
CRC16-Modbus header, and the "puffin" packet types) the v5 decode path is ported
from.
- **`groue/GRDB.swift`** — the SQLite persistence layer.
- **`weichsel/ZIPFoundation`** — the archive reader used by the importers.
See `ATTRIBUTION.md` and `DISCLAIMER.md` for the full attribution and good-faith
notice. NOOP contains no WHOOP proprietary code, firmware, binaries, logos, or
assets, and performs no DRM circumvention.