Public: anyone can read this; the crew can change it.

See what outside agents tried: a compact, redacted request log the owner can read #763

Closed opened this in answer to
Closed without merging

The forge now writes one redacted line for each request it answers, except static assets and /healthz. An admin can read what outside agents tried in Settings → Access log or with the MCP access tool.

Notes

stopped closed without shipping deploy 42542bf

opened this

The forge now writes one redacted line for each request it answers, except static assets and /healthz. An admin can read what outside agents tried in Settings → Access log or with the MCP access tool.

What to look at

  • src/http/access-log.ts (new) does all of it: it builds each line, redacts it, hashes the client address, writes the files, rotates and caps them, and reads them back.
    • Redaction happens when the line is built, before it's written. The path is stored without its query string. Any forge_… token in the path or user agent becomes forge_…, and a /go/<code> sign-in link becomes /go/…. Control characters are stripped. No header except the user agent is kept, cut to 200 characters.
    • The client is stored as an HMAC of the address, keyed with the data directory's secret.key and salted with the UTC day. It's the same within a day and can't be linked across days. The raw address is never written.
    • One JSON-lines file per UTC day goes under <data>/access/. Each file stops at 8 MiB, and files older than 14 days are deleted when a new day's first line is written. Lines are batched for 50 ms and appended in order, so writing never slows the response. Nothing serves this directory, and snapshots don't copy it.
    • Reads return only requests from non-browser user agents to the public paths: /…/issues, /api/, /mcp, /.well-known/, /llms.txt, /signin, /signup. Newest first, at most 500. A "browser" is a Mozilla/ user agent that doesn't name a bot or AI crawler.
  • src/http/server.ts: the listener's fetch now times every response, including app-host proxying, and records it. Proxied app requests always show as anonymous, because the forge doesn't sign them in itself. The security-floor door is unchanged, just moved into answerAny.
  • src/web/pages/access.ts: a new admin-only settings page with a GET filter form (since, user agent, path). Non-admins get the usual 404.
  • src/http/mcp.ts: a new access {since?, ua?, path?} tool. It is refused unless the caller is a forge admin with an rw token.
  • Docs: the README, docs/MCP.md and CLAUDE.md describe it.

Tests

  • test/access-log.test.ts (new, added to the gate) passes all 11 tests. It reads the raw files on disk and checks that no token, session cookie, query string, /go code or forwarded address appears in them. It also covers the 200-character user agent limit, skipping static assets and the health probe, the daily hash, deleting files past 14 days, the per-day cap, parsing since, the MCP filters and who may call it, and HTML escaping and the 404 on the page.
  • beforeAll in the new test has a 30 s timeout. At the default 5 s it timed out once on this machine while hashing two passwords for setup.
  • test/mcp.test.ts: the exact list of tool names now includes access. That's a new entry in the list, not a change in behaviour.
  • These fail the same way on main on this machine: test/apps-ws.test.ts (4 tests) and the MCP following, take_updates and converge test (5 s timeout). A few other 5 s timeouts in the web and surfaces suites came and went between runs on both branches. The /apps N+1 test that failed once on this branch passes on its own.
  • tsc --noEmit is clean.

Look I took a screenshot of /settings/access as an admin after replaying outside-agent/0.3 requests to /llms.txt, /.well-known/oauth-protected-resource, /mcp, /api/v1/repos/owner/notes/issues?…&token=forge_abc and /signup. Each showed as one row with its status, method, path (no query), host, duration, client hash and user agent. After that I moved the user agent to the front of each row's details, because it was being cut off at the end; that change isn't in the screenshot. The screenshot isn't committed.

Not done

  • No REST endpoint.
  • No user-agent heuristic beyond the Mozilla/ rule.
  • Requests to app hostnames are logged, but aren't marked signed in when they are.

Try it Send a request with a non-browser user agent, for example curl $FORGE/llms.txt. Then, as an admin, open /settings/access, or call the MCP access tool with an admin's rw token.

🤖 Generated with Claude Code

Closes #665

the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs