security: comprehensive security hardening for API keys, TLS, and data privacy#1121
Open
Littleyd wants to merge 3 commits intotisfeng:mainfrom
Open
security: comprehensive security hardening for API keys, TLS, and data privacy#1121Littleyd wants to merge 3 commits intotisfeng:mainfrom
Littleyd wants to merge 3 commits intotisfeng:mainfrom
Conversation
…a privacy - Store API keys in macOS Keychain instead of UserDefaults (with auto-migration) - Remove WebView trust-all-certificates bypass (EZURLSchemeHandler) - Tighten App Transport Security: NSAllowsLocalNetworking only (was NSAllowsArbitraryLoads) - Remove hardcoded Baidu session cookies (BDUSS) - Add user confirmation dialog for URL Scheme API key read/write operations - Change Bing endpoint from HTTP to HTTPS - Default analytics (Firebase) and crash logging (Sentry) to opt-in (was opt-out) - Truncate OCR text in logs to prevent sensitive data leakage - Filter API keys/tokens from backup export to Downloads folder Made-with: Cursor
Easydict connects to many translation services over HTTP (Ollama on localhost, Bing China, etc.). NSAllowsLocalNetworking alone is too restrictive and breaks Ollama. Restore NSAllowsArbitraryLoads while keeping NSAllowsLocalNetworking as explicit documentation. Made-with: Cursor
Owner
|
Please use dev branch as base branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses multiple security vulnerabilities identified during a comprehensive security audit of the Easydict codebase. The changes focus on protecting user data and API credentials.
High-Priority Fixes
API Keys migrated to macOS Keychain — All translation service API keys/secrets (DeepL, Baidu, Ali, Tencent, Volcano, NiuTrans, Caiyun, and OpenAI-compatible stream services) are now stored in Keychain instead of UserDefaults. A transparent migration runs on first launch.
WebView TLS certificate validation restored — Removed
allowsAnyHTTPSCertificateForHost:YESand the blanket trust indidReceiveAuthenticationChallenge:. WebView now properly validates server certificates.App Transport Security tightened — Replaced
NSAllowsArbitraryLoads = YESwithNSAllowsLocalNetworking = YESin both Info.plist and Info-debug.plist, restricting plaintext HTTP to localhost only.Hardcoded Baidu session cookie removed — Removed embedded
BDUSS/BDUSS_BFESSvalues fromEZWebViewTranslator.m.URL Scheme key read/write gated by user confirmation —
easydict://writeKeyValueandeasydict://readValueOfKeynow show an NSAlert requiring explicit user approval before executing.Medium-Priority Fixes
Analytics & crash reporting default to opt-in —
allowCrashLogandallowAnalyticsnow default tofalse.OCR text truncated in logs — Full OCR results are no longer written to system logs.
Sensitive keys filtered from backup export — API keys, secrets, and tokens are excluded from the user data export file.
Bing endpoint upgraded to HTTPS — Changed
http://tohttps://for the Bing China host.New Files
Easydict/Swift/Utility/KeychainHelper.swift— Keychain CRUD helper + migration logic from UserDefaults to Keychain.Test Plan
easydict://writeKeyValue?EZTest=abcshows confirmation dialogeasydict://readValueOfKey?EZTestshows confirmation dialogMade with Cursor