Skip to content

V1: Gate unverified channel routes behind LOUSHO_API_TOKEN in the built server - #676

Merged
LinuxDevil merged 1 commit into
mainfrom
v1-gate-channel-routes
Oct 19, 2026
Merged

LinuxDevil merged 1 commit into
mainfrom
v1-gate-channel-routes

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

Fixes audit finding SEC-1 (Vercel competitor audit, 2026-10-19).

What was wrong

lousho build --target=node-server with channels/http.ts = export default httpChannel() and LOUSHO_API_TOKEN=secret: /chat and /sessions without the token answered 401, but POST /channels/http without the token answered 200 and ran the agent. httpChannel takes sessionKey from the body, so anyone could read or continue another user's conversation by guessing a key. The start-up log only said channels: http.

What changed

  • createDeployedServer() (src/deploy/nodeServer.ts): when server auth is configured (LOUSHO_API_TOKEN, the build's token, or the agent directory's auth.ts), a channel route (POST /channels/<name> and /channels/<name>/approvals/:id) whose channel has no verify now runs that auth first (same routeAuth as /chat: 401 / 403 / WWW-Authenticate). The check reads headers only, so the channel still gets the untouched body.
  • A channel with a verify (Slack, Discord, Telegram, GitHub, Teams, webhookChannel({ secret | auth }), httpChannel({ verify }), or any user defineChannel({ verify })) still authenticates itself and stays reachable without the bearer token, since platform callers can't send it. No new flag was needed: "self-verifying" is simply "has verify", which already holds for every built-in platform channel (webhookChannel only sets verify when it has a secret/auth). Non-breaking for user channel definitions.
  • DeployedServer gains channelRoutes: { name, auth: 'self-verified' | 'server-auth' | 'open' }[].
  • The generated agent-directory server.ts logs each channel route's guard at start-up, e.g. channels: slack (verifies its own requests), http (behind the server auth), and warns when any route is open (no verify, no token).

Behavior change: with LOUSHO_API_TOKEN (or auth.ts) set, channel routes for channels that have no verify now require the same Authorization as /chat; before, they were open. Callers of such channels must send the bearer token, or the channel must be given a verify.

Docs (ticket V2 owns docs/deployment.md and docs/channels.md, so not edited here) need a line like: "In the built server, a channel without verify sits behind LOUSHO_API_TOKEN / auth.ts like /chat; a channel with verify (Slack, Discord, Telegram, GitHub, Teams, a webhook with a secret) authenticates its own callers and is reachable without the token. The start-up log lists each channel route as verifies-its-own-requests, behind-the-server-auth, or open."

Tests

  • src/deploy/nodeServerChannels.test.ts (new route auth block): httpChannel() with LOUSHO_API_TOKEN → 401 without / with a wrong token (also on the approvals route), 200 with it (reproduced as 200 before the fix); httpChannel({ verify }) reachable without the bearer token and its own verify still rejects; webhookChannel({ secret }) 401 unsigned, 200 signed without the bearer token; no token → route reported open and reachable; channelRoutes asserted in each case.
  • Updated tests that encoded the old open behaviour: src/deploy/nodeServer.test.ts (auth list now guards a channel without verify), src/deploy/adapters/node-server-dir.test.ts (built server: echo channel 401 without, 200 with auth.ts's token; start-up log channels: echo (behind the server auth)), src/oauth/signInRoutes.test.ts (sends the bearer token).
  • npx tsc --noEmit, npm run typecheck:tests, npm run lint: pass. npm run test:coverage: 6005 passed; failures only scripts/changelogGuard.test.ts and packages/create-lousho-agent (index + e2e) — the known missing alpha.24 CHANGELOG heading (V0) plus the sub-package's unbuilt dist/ in a fresh worktree — and one run of a timing-sensitive MCP test (src/tools/mcp/connect.test.ts, passed on the previous full run). npm run fallow (on coverage written with --coverage.reportOnFailure): exit 0.

Changelog: The built node-server now protects channel routes without a verify with LOUSHO_API_TOKEN / auth.ts, like /chat; self-verifying channels (Slack, Discord, Telegram, GitHub, Teams, signed webhooks) are unchanged, and the start-up log lists each channel route's guard.

🤖 Generated with Claude Code

…n the built server

A channel with no verify of its own (e.g. httpChannel()) was served by the
built node-server without the bearer token, even with LOUSHO_API_TOKEN set.
Now such a route is guarded by the server's auth like /chat; channels that
verify their own requests (platform signatures, webhook secrets, a custom
verify) stay reachable without it. createDeployedServer() reports each
channel route's guard, and the generated server logs it at start-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LinuxDevil
LinuxDevil force-pushed the v1-gate-channel-routes branch from 1b7d779 to f9128f7 Compare October 19, 2026 20:14
@LinuxDevil
LinuxDevil merged commit 30e58db into main Oct 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant