Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
FuJacob
force-pushed
the
security/endpoint-origin-approval
branch
from
November 23, 2026 04:09
c1886af to
03f127b
Compare
This branch has not been deployed
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
The endpoint's server URL and the selected engine are plain UserDefaults keys. The app is unsandboxed, so any process running as the same user can rewrite them, and on the next launch Cotabby would send the user's text, plus the stored API key, to whatever server they name. The Server URL field also saved on every keystroke, so editing the address to a new provider sent the old provider's key to the new host on the next suggestion, before Connect was pressed. With this change, text and the API key go only to a server (scheme, host, port) the user approved by pressing Connect.
approved-origin) in the same service as the API key, not in UserDefaults. The record exists with or without an API key, so local servers that need no key work the same way.openAICompatibleApprovedConfiguration. It checks the configured origin before the API key is read, and if they differ it throwsunapprovedServerand sends nothing. Settings shows "Press Connect to confirm before Cotabby sends it any text." in the pane callout and the connection status, the sidebar shows its attention dot, and the Home card reads "Confirm server". Automatic refreshes (pane appear, engine switch, power profile) never approve anything.OpenAICompatibleEndpointOrigin(Support/Runtime) normalizes case, default ports, path and trailing slash, and IPv6 brackets.OpenAICompatibleOriginApprovalPolicy(Support/Settings) holds the request gate and the one-time upgrade rule.nonesentinel. Because the sentinel is a Keychain record, later edits to the defaults can't make the adoption run again. If the Keychain read fails, nothing is approved and nothing is written. Reset to Defaults writes the sentinel.fc/fd/fe8–feb"local network" rule now applies only to hosts that parse as IPv6 literals (inet_pton), so DNS names likefdic.govare public again, and with them plain HTTP is rejected. This also fixesfd::1, which is00fd::1and therefore outsidefc00::/7.Validation
swiftlint lint --quiet --stricton the app target: clean.xcodegen generate: the committedCotabby.xcodeprojincludes the four new files.OpenAICompatibleEndpointOriginTests,OpenAICompatibleOriginApprovalPolicyTests, approval cases inSuggestionSettingsModelTests(Connect gate, invalid address leaves state unchanged, one-shot adoption, sentinel, Keychain failure, reset), host-scope and warning rows inOpenAICompatibleEndpointConfigurationTestsandOpenAICompatibleAPIClientTests.Linked issues
None filed. Addresses H2, L1, and L2 from a static security review of
8cdbea2.Risk / rollout notes
OpenAICompatibleOriginApprovalPolicy.restore, and I'd consider it if endpoint users are few.OpenAICompatibleEndpointOrigin.swiftand its test file are byte-identical to the copies in Keep endpoint requests on their own session, the same server, and bounded streams #929, which uses the helper for its redirect check, so either PR can merge first. Both PRs add files, soproject.pbxprojmay needxcodegen generateafter the first one merges.🤖 Generated with Claude Code