Skip to content

security: authenticate RPC socket and validate route registration#8

Closed
kvendrik wants to merge 1 commit intomainfrom
fix/rpc-socket-auth
Closed

security: authenticate RPC socket and validate route registration#8
kvendrik wants to merge 1 commit intomainfrom
fix/rpc-socket-auth

Conversation

@kvendrik
Copy link
Copy Markdown
Owner

@kvendrik kvendrik commented Apr 9, 2026

Problem

Any process running as appuser (including anything spawned via shell) can connect to the internal Unix socket at /tmp/backoffice.sock and register arbitrary HTTP routes. This means a compromised or malicious background process could:

  • Register /mcp and intercept all MCP traffic (including OAuth tokens)
  • Point a route at http://169.254.169.254 to access cloud metadata

Changes

src/rpc.ts

  • Generate a randomBytes(32) shared secret at startup, written to /tmp/backoffice-rpc.secret (mode 0600)
  • Every RPC call must include params.secret — rejected via timing-safe comparison if missing/wrong
  • Route targets validated against /^http:\/\/(?:localhost|127\.0\.0\.1):\d+$/
  • Route patterns restricted to allowlist (/share)

skills/share/index.ts

  • Reads secret from /tmp/backoffice-rpc.secret before RPC calls
  • Includes secret in route.register and route.unregister params

Typechecks clean.

- Generate a shared secret at startup, write to /tmp/backoffice-rpc.secret
- Require secret in every RPC call (timing-safe comparison)
- Validate route targets are localhost only (http://localhost:<port>)
- Restrict route patterns to allowlist (/share)
- Share skill reads secret from file before RPC calls

Prevents background processes from hijacking routes or proxying
to internal/cloud metadata endpoints.
@kvendrik kvendrik closed this Apr 9, 2026
@kvendrik kvendrik deleted the fix/rpc-socket-auth branch April 9, 2026 09:44
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