From d534bb58bc00e53fb2487b6ff110924477e9bbe5 Mon Sep 17 00:00:00 2001 From: Hasan Basbunar Date: Mon, 9 Nov 2026 11:16:02 +0100 Subject: [PATCH] cockpit: the test Connect a client copies reads the key through a descriptor, not curl's arguments The local CI's scan for secrets on a command line (tests/test_no_secret_in_argv.py) found the copied test sending -H "Authorization: Bearer $(cat )": the shell spells the key into curl's arguments, where any local user reads it in /proc. The header now goes through a descriptor, -H @<(printf 'Authorization: Bearer %s\n' ...), as the repo's own scripts do. Run on the reference box against the proxy, the copied command is answered by the lane that serves. Co-Authored-By: Claude Opus 5.5 --- dashboard/static/js/now.js | 6 ++++-- dashboard/tests/test_page_details.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dashboard/static/js/now.js b/dashboard/static/js/now.js index 8ee85be3..a3466e96 100644 --- a/dashboard/static/js/now.js +++ b/dashboard/static/js/now.js @@ -249,7 +249,9 @@ function renderApi(){ // with client keys, the proxy refuses every other key, the cockpit's login included (keepalive-proxy.py, its wall) const keySaid = d.client_keys ? "a client key of yours, from the proxy's keys file: it refuses any other, the cockpit's login included" : `the cockpit's login, in ${d.key_file} on the box`; - const keyArg = d.client_keys ? '$YOUR_CLIENT_KEY' : `$(cat ${d.key_file})`; + // the header through a descriptor, never an argument of curl's, where any local user reads it in /proc (the rule of + // tests/test_no_secret_in_argv.py, which caught this command at first) + const keyHeader = `@<(printf 'Authorization: Bearer %s\\n' "${d.client_keys ? '$YOUR_CLIENT_KEY' : `$(cat ${d.key_file})`}")`; const rows = [['OpenAI API', `${base}/v1`, 'wrap'], ['Anthropic API', base, 'wrap'], ['Model', modelSaid], ['Key', keySaid, 'wrap'], boxOnly ? ['Other machines', `the proxy listens on this box only (PROXY_BIND=${d.bind}): PROXY_BIND=0.0.0.0 ./install.sh opens it, the key still the gate`, 'wrap'] : others.length ? ['From another machine', others.join('\n'), 'wrap lines'] : [null, null], @@ -259,7 +261,7 @@ function renderApi(){ // claude-local sets Claude Code up for the lane that serves (proxy, key, model, budgets: docs/clients.md); the test // reads the key from its file, on the box, and never shows it const items = [['Copy the address', `${base}/v1`], ['Copy for Claude Code, on the box', 'claude-local'], - ['Copy a test', `curl -s ${base}/v1/chat/completions -H "Authorization: Bearer ${keyArg}" -H 'Content-Type: application/json' -d '{"model":"${m}","messages":[{"role":"user","content":"Say ok."}],"max_tokens":8}'`]]; + ['Copy a test', `curl -s ${base}/v1/chat/completions -H ${keyHeader} -H 'Content-Type: application/json' -d '{"model":"${m}","messages":[{"role":"user","content":"Say ok."}],"max_tokens":8}'`]]; // the unit not read: the proxy's usual port, said as a guess (review of v1.45.1) const aside = !d.known ? 'its port not read: 30001 assumed' : boxOnly ? 'from this box only' : 'OpenAI and Anthropic APIs'; // built again only when what it says changed: rebuilt at every tick of the lanes (2 s), a selection or a focus on diff --git a/dashboard/tests/test_page_details.py b/dashboard/tests/test_page_details.py index 7e0bbe38..f1775056 100644 --- a/dashboard/tests/test_page_details.py +++ b/dashboard/tests/test_page_details.py @@ -1050,8 +1050,9 @@ class AClientIsToldWhereToSendItsRequests(unittest.TestCase): self.assertIn("OpenAI APIhttp://[fd7a:115c::1]:30001/v1", r["v6"]) self.assertIn("a client key of yours", r["v6"]) self.assertIn("the cockpit's login included", r["v6"]) - self.assertIn("Bearer $YOUR_CLIENT_KEY", r["test"]) + self.assertIn("-H @<(printf 'Authorization: Bearer %s\\n' \"$YOUR_CLIENT_KEY\")", r["test"]) self.assertNotIn("api-key", r["test"]) + self.assertNotIn('-H "Authorization', r["test"], "the key in curl's arguments, read by any local user") self.assertTrue(r["same"], "rebuilt though nothing it says changed") self.assertIn("Modelreading the lane that serves", r["switched"]) self.assertEqual(r["aside"], "its port not read: 30001 assumed")