Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ You need a Car Thing running bridgething, paired with the bridgething companion

```sh
git clone https://github.com/snowopsdev/t3-things && cd t3-things
mkdir -p ~/.config/agent-status
mkdir -p ~/.config/agent-status && chmod 700 ~/.config/agent-status

# The token the Car Thing sends. Any long random string works.
openssl rand -hex 24 > ~/.config/agent-status/display.token
Expand Down Expand Up @@ -128,6 +128,10 @@ Built on [bridgething](https://bridgething.com), which makes the Car Thing run w

T3 Things isn't affiliated with Spotify, Anthropic, OpenAI, or the makers of T3 Code. Car Thing is a Spotify product, and the device frame in these docs is an original drawing. Claude's usage numbers come from an endpoint Claude Code uses that isn't publicly documented, so that part may break without notice.

## Security

The service sits next to your Claude, Codex, and T3 Code credentials. See [SECURITY.md](SECURITY.md) for how to run it safely and how to report a problem.

## License

[MIT](LICENSE)
21 changes: 21 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Security

The status service reads Claude Code's login, Codex session logs, and T3 Code session tokens on your computer, so a hole in it can expose more than this project's own data.

## Reporting a problem

Open a [GitHub issue](https://github.com/snowopsdev/t3-things/issues) with the steps to reproduce it. Leave out your own tokens, hostnames, and tailnet name.

## What's in scope

- `service/agent-status.mjs`: anything that gets around the bearer token, reads or writes outside what it documents, or leaks a credential into `status.json` or its logs.
- The Car Thing app and its settings page: anything that leaks the service URL or token beyond the device and the companion app.

Claude, Codex, T3 Code, bridgething, and Tailscale belong to their own projects, so report problems in them there.

## Running it safely

- Keep the service on `127.0.0.1` and reach it only through `tailscale serve`. Don't publish it with `tailscale funnel` or open its port to the internet.
- Use a long random display token (`openssl rand -hex 24`). The service won't start with one shorter than 16 characters.
- Give each T3 Code host a session token with only the `orchestration:read` scope.
- Keep `~/.config/agent-status` readable only by you: `chmod 700 ~/.config/agent-status && chmod 600 ~/.config/agent-status/*`.
8 changes: 7 additions & 1 deletion service/agent-status.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import { createServer } from 'node:http';
import { execFile } from 'node:child_process';
import { timingSafeEqual } from 'node:crypto';
import { mkdir, open, readFile, readdir, stat, writeFile } from 'node:fs/promises';
import { homedir } from 'node:os';
import { join } from 'node:path';
Expand Down Expand Up @@ -40,6 +41,9 @@ const DEFAULTS = {

const config = { ...DEFAULTS, ...(await readJson(join(CONFIG_DIR, 'config.json')).catch(() => ({}))) };
const displayToken = (await readFile(join(CONFIG_DIR, 'display.token'), 'utf8')).trim();
// an empty token would let any `Authorization: Bearer ` request through.
if (displayToken.length < 16) throw new Error(`${join(CONFIG_DIR, 'display.token')} must hold at least 16 characters`);
const displayTokenBytes = Buffer.from(displayToken);

const state = {
t3: Object.fromEntries(config.t3Hosts.map(h => [h.name, { ok: false, error: 'not polled yet', threads: [] }])),
Expand Down Expand Up @@ -493,7 +497,9 @@ function statusDocument() {
function authorized(req, url) {
const header = req.headers.authorization ?? '';
const given = header.startsWith('Bearer ') ? header.slice(7) : url.searchParams.get('token');
return given === displayToken;
if (typeof given !== 'string') return false;
const bytes = Buffer.from(given);
return bytes.length === displayTokenBytes.length && timingSafeEqual(bytes, displayTokenBytes);
}

function handler(req, res) {
Expand Down
Loading