Skip to content

fix: privacy and transport hardening from the October review - #10

Merged
Ferdinand99 merged 2 commits into
mainfrom
fix/privacy-hardening
Oct 27, 2026
Merged

Ferdinand99 merged 2 commits into
mainfrom
fix/privacy-hardening

Conversation

@Ferdinand99

Copy link
Copy Markdown
Owner

Fixes from the October privacy review (KS-01 to KS-07, apart from KS-08).

Opt-out (KS-01). The flush loop checks isEnabled before every batch and after every upload. Kestrel.isEnabled = false cancels the upload in flight at once instead of waiting for the engine, and nothing more is sent.

Scrubbing (KS-02, KS-03, KS-04).

  • Values are cleaned of control characters before scrubbing, not after, so john@exa<TAB>mple.com or a card number split by a newline is caught.
  • Compressed IPv6 (2001:db8::1, ::1) and card numbers separated by dots or non-breaking spaces are scrubbed.
  • Payload keys containing pass, secret, token, auth, key, card, cookie, cvv, or ssn as a word, are dropped with their values.
  • A value is cut to 2,000 characters before scrubbing, and the email and name=value patterns have bounded runs. A 20k-character value scrubs in milliseconds.

Transport (KS-05, KS-07).

  • http:// is refused except for localhost and debug builds. Redirects are not followed, answers over 64 KB are ignored, timeoutIntervalForResource is 60 s.
  • Only a 202 with {"accepted": n} counts as delivered. Other 2xx, 3xx, 405, 407, 408 and 410 keep the batch and retry with backoff. 401, 403 and 404 pause sending for an hour instead of until relaunch.

Queue (KS-06). The command stream is bounded to 1,000 (oldest dropped, waiters released, an opt-out is never lost). A full queue file is appended to and compacted after a batch of drops instead of rewritten per signal.

Behaviour changes for apps: payload keys that contain key, auth, pass and so on (keyboard_layout, author) are dropped; http:// endpoints stop working in release builds except for localhost; a wrong key no longer silences the SDK until relaunch.

Tests: swift test on Linux (Swift 6.2): 86 passed. The redirect test is Apple-only (swift-corelibs traps on redirects from a mock protocol), so the macOS job covers it, along with the delegate signatures.

Opting out now takes effect at once: the flush loop checks the switch before
every batch, and turning it off cancels the upload in flight.

Payload values are cleaned of control characters before they are scrubbed
(they used to split an address past the patterns and be removed afterwards),
cut to 2,000 characters first, and the patterns' leading runs are bounded so a
long value scrubs fast. Shortened IPv6 addresses and card numbers grouped with
dots or non-breaking spaces are scrubbed too, and payload keys that look like
they hold a secret (password, token, auth, key, card, cookie, cvv, ssn) are
dropped with their values.

Transport: http:// is refused except for localhost and debug builds, redirects
are not followed, answers over 64 KB are ignored and a request has 60 seconds
in all. Only Keen Kestrel's own 202 answer counts as delivered; other 2xx
answers retry with backoff, as do 405, 407 and 410 instead of dropping the
batch. 401, 403 and 404 pause sending for an hour instead of until relaunch.

The command stream is bounded to 1,000 commands, and a full queue file is
appended to and compacted now and then instead of rewritten for every signal.
@Ferdinand99
Ferdinand99 merged commit 2732d2b into main Oct 27, 2026
7 checks passed
@Ferdinand99
Ferdinand99 deleted the fix/privacy-hardening branch October 27, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant