Read the session from a signed-in Firefox-family browser - #2
Merged
Conversation
The paste exists because LS is a session cookie and cookies.sqlite never holds it. That was the right measurement and the wrong conclusion: Gecko's session store keeps the cookies of every host a browsing session touched, so it can restore them, and LS is in there. Measured on a real profile, LS and _csrf out of recovery.jsonlz4 return HTTP 200 and the full owned list. Two things decide what that can promise, both measured rather than assumed. The jar is not tab-scoped: on the profile tested, 156 of 169 cookie hosts had no tab open anywhere in the session, assetstore.unity.com among them, so the credential outlives the tab and lasts as long as the browsing session. And the file is rewritten periodically, so it lags a sign-in by seconds. `session_source = "browser"` sweeps the known Gecko roots. A path still works and now also accepts a profile directory or a recovery.jsonlz4 directly, so a browser this does not know where to find is reachable by pointing at it. Which kind of source a path is gets decided by reading it — a session store by its mozLz40 magic — rather than by asking the user to declare it. Profile discovery reads installs.ini before the Default=1 flag in profiles.ini. They disagree on the machine this was built against, and only the profile installs.ini names has a session store at all; preferring the flag finds an empty profile and reports no session where there plainly is one. The mozlz4 decoder is ~40 lines of LZ4 block decoding rather than a dependency, bounds-checked throughout because it parses a file another program wrote, with a ceiling on the size the header claims. Tests cover overlapping matches, extended lengths, truncation, and a lying header; an opt-in test decodes a real profile, skipped by default since that file is a live credential store. That store carries credentials for every host the session touched, so it is filtered to the unity.com family inside internal/session before anything leaves the package, and no value is ever logged. Chromium encrypts its session cookies elsewhere and is out of scope. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012LiuqQ1Kt5Ak2YgAxuzUZV
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.
What
Adds a third session source: a signed-in Firefox-family browser.
session_source = "browser"(or
--session browser) reads Gecko's session store instead of a pasted curl command.--sessionalso now accepts a browser profile directory or arecovery.jsonlz4directly, andworks out what any path is by reading it rather than by configuration — a session store is
identified by its
mozLz40\0magic, a curl paste by its structure.Why
The paste exists because
LSis a session cookie andcookies.sqlitenever holds it. Thatmeasurement was right and the conclusion drawn from it was wrong: Gecko keeps a session
store so it can restore a session, and that file holds the cookies of every host the session
touched —
LSamong them. Verified against a real profile:LS+_csrfout ofrecovery.jsonlz4return HTTP 200 with the full owned list.Two properties decide what this can promise, both measured rather than assumed:
in the session,
assetstore.unity.comamong them. The credential outlives the tab and lastsas long as the browsing session, so this is not "keep a tab open".
takes seconds to show up.
Chromium keeps session cookies in an encrypted SQLite database instead, so it is out of scope
and the docs say so.
Notable details
installs.inibefore theDefault=1flag inprofiles.ini.They disagree on the machine this was built against, and only the profile
installs.ininames has a session store at all. Preferring the flag finds an empty profile and reports no
session on a machine where there plainly is one.
one. It is bounds-checked throughout because it parses a file another program wrote, and it
caps the size the header claims so a corrupt header cannot become a huge allocation.
session touched, so it is filtered to the
unity.comfamily insideinternal/sessionbefore anything leaves the package, and no cookie value is ever logged — every error and
diagnostic carries paths and cookie names only.
Testing
go test -race ./...green across 14 packages;go vetandgofmt -lclean.New tests cover the decoder against overlapping matches, extended match lengths, truncated
blocks, a header that overstates its payload, and one that claims a gigabyte; that only
unity.comcookies survive a jar containing other sites; thatinstalls.inibeats theDefault=1flag; that a profile without the credential is skipped rather than fatal; and thata path is identified by content.
One test is opt-in and skipped by default, since it needs a live credential store:
Run live against the real 176-asset account, all three paths:
session_source = "browser"inconfig.toml— no paste anywhere, reports which profile it read--session <profile dir>pointed straight at a Zen profile--session session.curl, the existing paste, unchangedRelease Notes
You can now point unity-sync at your browser instead of pasting a session. Set
session_source = "browser"inconfig.toml, sign in to the Asset Store in Firefox, Zen,LibreWolf, Waterfox or Floorp, and unity-sync reads the session from there — no re-pasting when
it expires. Pasting still works exactly as before.