Repository navigation
fix(hooks): keep the session token out of curl's command line - #100
Merged
Merged
Conversation
Every hook script posted to "http://127.0.0.1:$LICH_PORT/<endpoint>?token=$LICH_TOKEN", so the expanded token was an argument of curl, readable by every user on the machine through /proc/<pid>/cmdline each time a hook fired. The scripts now send it as an Authorization: Bearer header fed to curl as a config line on stdin (printf is a shell builtin, so the token enters no argv; a -H argument would leak the same way). This is the shape lich adopted in lichdotdev/lich#1067, which makes the listener accept the header. A lich released before that answers 401 to a report whose token is only in the header. The scripts read the status of the first request and, on a 401 alone, send the report again with ?token=, so a card keeps its state under any lich. A 500 or a refused connection is not retried.
This was referenced Nov 9, 2026
Merged
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
Every shell hook (
report-state.sh,report-tool.sh,report-session-start.sh,report-title.sh,report-touched.sh) posted tohttp://127.0.0.1:$LICH_PORT/<endpoint>?token=$LICH_TOKEN. The expanded token was an argument ofcurl, which/proc/<pid>/cmdlineshows to every user on the machine, each time a hook fired.The scripts now send the token as
Authorization: Bearer <token>, fed tocurlas a config line on stdin, the shape lich adopted in lichdotdev/lich#1067:printfis a shell builtin, so the token enters no argv. A-Hargument would leak the same way as the query string.Compatibility with a lich that does not accept the header
The plugin runs against whatever lich is installed, and every release before lichdotdev/lich#1067 answers 401 to a report whose token is only in the header. Each script reads the status of the first request (
-w '%{http_code}', body to/dev/null) and, on a 401 alone, sends the same report again with?token=. A 500 or a refused connection is not retried, so the existing "one request on a 500" tests hold unchanged.report-title.shlatches on whichever request lich took, so an older lich does not bring the transcript scan back on every tool call.Cost, measured on
report-touched.shover 3 rounds of 500 runs against a loopback server: 5.2 to 6.6 ms a run before, 5.6 to 6.6 ms with the header accepted, about 10 ms on the fallback (one morecurl).Scope
antigravity.go,kiro.go,crush.goininternal/agentplugin), so a new sourced helper would not reach those installs under any released lich..shfiles throughhooks/win-run.cmdand Git Bash, so it takes the same path. The repository has no PowerShell.hooks/*.js),opencode/lich.jsandomp/lich.jsreport with an in-processfetchand run no process with the token; they are unchanged.agent-cards.jsrunslich openwith no token in its argv.Tests
tests/hooks.test.mjs: every existing hook assertion now requires the token in theAuthorizationheader and no token in the URL (assertHookHonoured). The in-process clients keep asserting?token=throughassertContractHonoured.curland aprintfwrapper onPATHrecording their argv against the stub server. One request, token in the header, token in no recorded argv line.?token=. Two requests, the first with the header and a clean URL, the second the old shape with the same body.report-title.sh oncelatches after a title an older lich took through the fallback.node --test tests/*.test.mjs: 492 tests, 492 pass.hooks/report-touched.shagainst a running lich that does not accept the header yet, with a wrapper recording eachcurlrun: first run without the token in argv answered 401, second run with?token=answered 204.