Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Pomander talks only to Apple, by construction
Yashwanth Kamireddi560eb00c2d0c
diff --git a/SECURITY.md b/SECURITY.mdindex 54a87be..807997f 100644--- a/SECURITY.md+++ b/SECURITY.md@@ -16,6 +16,12 @@ Apple, and nothing else:- `calendars.icloud.com` — Apple's public holiday calendars.- The `.com.cn` equivalents of the above, for accounts in mainland China.+This is enforced, not only promised: every network client Pomander makes is built by+`quince_auth::apple_only()`, whose resolver refuses to look up any host outside `apple.com`,+`icloud.com` and `icloud-content.com` (and their `.com.cn` twins) — a request anywhere else+fails before a connection exists. The test `crates/quince-auth/tests/apple_only.rs` holds it+to that.+There are no Pomander servers. There is no telemetry, analytics, crash reporting or updatecheck. Nothing is sent anywhere but Apple, and only what is needed to show and change yourown data. The window itself cannot reach the network at all: its content security policydiff --git a/crates/quince-auth/Cargo.toml b/crates/quince-auth/Cargo.tomlindex aba78f4..0ebbe12 100644--- a/crates/quince-auth/Cargo.toml+++ b/crates/quince-auth/Cargo.toml@@ -20,6 +20,8 @@ rand = "0.9"reqwest_cookie_store = "0.8"cookie_store = { version = "0.21", features = ["serde_json"] }thiserror = "2"+# Looking up Apple's hosts for the client's own resolver (AppleOnly).+tokio = { workspace = true, features = ["net"] }[dev-dependencies]tokio = { workspace = true }diff --git a/crates/quince-auth/src/lib.rs b/crates/quince-auth/src/lib.rsindex 22d5ce6..600f548 100644--- a/crates/quince-auth/src/lib.rs+++ b/crates/quince-auth/src/lib.rs@@ -299,7 +299,7 @@ impl Client {HeaderValue::from_static("en-US,en;q=0.9"),);- let http = HttpClient::builder()+ let http = apple_only().cookie_provider(Arc::clone(&jar)).user_agent(UA).default_headers(defaults)@@ -1037,6 +1037,53 @@ impl Client {}}+/// Whether `host` is Apple's: its sign-in, iCloud's services and their files, push, and their+/// China-mainland twins — every host Pomander has any reason to reach. Loopback too, which is+/// this computer.+#[must_use]+pub fn is_apple_host(host: &str) -> bool {+ let host = host.trim_end_matches('.').to_ascii_lowercase();+ const APPLE: [&str; 6] = [+ "apple.com",+ "icloud.com",+ "icloud-content.com",+ "apple.com.cn",+ "icloud.com.cn",+ "icloud-content.com.cn",+ ];+ host == "localhost"+ || APPLE+ .iter()+ .any(|d| host == *d || host.ends_with(&format!(".{d}")))+}++/// Every HTTP client Pomander makes starts here: Apple's servers, and nothing else, can be+/// reached at all (see [`AppleOnly`]).+pub fn apple_only() -> reqwest::ClientBuilder {+ HttpClient::builder().dns_resolver(Arc::new(AppleOnly))+}++/// The one way Pomander's client finds a server: a host that is not Apple's is never looked+/// up, so no request can reach one — "talks only to Apple" is how the code works, not a promise+/// about it. Apple's are looked up as the system looks up any name.+struct AppleOnly;++impl reqwest::dns::Resolve for AppleOnly {+ fn resolve(&self, name: reqwest::dns::Name) -> reqwest::dns::Resolving {+ let host = name.as_str().to_string();+ Box::pin(async move {+ if !is_apple_host(&host) {+ let refused: Box<dyn std::error::Error + Send + Sync> =+ format!("{host} is not Apple's, and Pomander talks only to Apple").into();+ return Err(refused);+ }+ let found = tokio::net::lookup_host((host.as_str(), 0)).await?;+ let addrs: reqwest::dns::Addrs = Box::new(found.collect::<Vec<_>>().into_iter());+ Ok(addrs)+ })+ }+}+#[cfg(test)]mod tests {use super::*;diff --git a/crates/quince-auth/tests/apple_only.rs b/crates/quince-auth/tests/apple_only.rsnew file mode 100644index 0000000..c53804d--- /dev/null+++ b/crates/quince-auth/tests/apple_only.rs@@ -0,0 +1,44 @@+//! Pomander talks only to Apple, by construction: the client cannot resolve, so cannot reach,+//! any host that is not Apple's.++#[test]+fn only_apples_hosts_count_as_apples() {+ use quince_auth::is_apple_host;+ for ok in [+ "idmsa.apple.com",+ "setup.icloud.com",+ "p177-ckdatabasews.icloud.com",+ "cvws.icloud-content.com",+ "p34-webcourier.push.apple.com",+ "setup.icloud.com.cn",+ "www.icloud.com.",+ "localhost",+ ] {+ assert!(is_apple_host(ok), "{ok}");+ }+ for no in [+ "example.com",+ "icloud.com.evil.example",+ "notapple.com",+ "apple.com.evil.example",+ "evilicloud.com",+ "tile.openstreetmap.org",+ ] {+ assert!(!is_apple_host(no), "{no}");+ }+}++#[tokio::test(flavor = "multi_thread")]+async fn a_client_refuses_anything_but_apple_before_connecting() {+ let client = quince_auth::apple_only().build().unwrap();+ let err = client+ .get("https://example.com/")+ .send()+ .await+ .expect_err("a request to a host that is not Apple's");+ let said = format!("{err:?}");+ assert!(+ said.contains("Pomander talks only to Apple"),+ "refused by the resolver, not the network: {said}"+ );+}diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex 6111495..1b151a4 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -1356,7 +1356,9 @@ fn spawn_holidays(app: tauri::AppHandle) {*app.state::<Occasions>().feed.lock().await =quince_icloud::occasions::parse_feed(&text);}- let http = reqwest::Client::new();+ let Ok(http) = quince_auth::apple_only().build() else {+ return;+ };loop {let stale = std::fs::metadata(&path).and_then(|m| m.modified())