Repository navigation
Read the Claude active-organization cookie in process - #39
Merged
euforic merged 1 commit intoOct 30, 2026
Merged
Conversation
The lastActiveOrg lookup was the last provider-database sqlite3 launch on the refresh path. It now uses SQLiteReadOnly.query, which gains an `under:` root forwarded to databaseArgument so the profile-root containment check is kept. The query returns host_key, the plain value, and the encrypted value as typed text and blob columns instead of a hex-and-pipe string; decryption, host-hash and UUID validation are unchanged, as are the 2 s timeout and 4 KiB budget, now with a one-row limit. Any query failure still yields no organization. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Stacked on #38. Review and merge that first. This PR's diff is only the commit on top of it.
Summary
ClaudeCredentialReader.activeOrganization(userDataURL:key:)was the last place that launched/usr/bin/sqlite3to read a provider database during a refresh. It now reads thelastActiveOrgcookie fromCookiesorNetwork/Cookieswith the in-processSQLiteReadOnly.queryreader added in #38.SQLiteReadOnly.querygains anunder root: URL? = nilparameter that it passes todatabaseArgument. The cookie lookup passes the profile's user-data root, so the containment check against the profile root stays in place. Existing callers are unchanged.host_key,CAST(value AS TEXT)andCAST(encrypted_value AS BLOB)as separate typed columns instead of the old hex-and-|string. A non-empty plain value is still used first.maximumRows: 1. Any query error still givesnilfor that database.Data(hexString:)helper was no longer used, so it is removed.activeOrganizationgoes from private to internal so tests can call it without a Keychain.docs/resource-usage-readers.mdand updated one sentence indocs/security.md.Tests
All tests use real SQLite files created through the SQLite C API and real AES encryption, with no mocks.
ClaudeCredentialReaderTests:Network/Cookies: it decrypts, and a value encrypted for a different host is rejected.Networkfolder symlinked to another profile's folder is rejected, while that other profile still reads its own cookie.cookiestable givesnil, and the lookup still moves on toNetwork/Cookies.SQLiteReadOnlyTests: the newunder:parameter onqueryrejects a symlinked parent from another profile. The same query without a root follows the link.under: userDataURLremoved, the symlink test fails.swift testpasses: 342 core tests and 63 app tests, with only the usual opt-in tests skipped.🤖 Generated with Claude Code