Skip to content

Security Model

The MCP Bridge implements defense-in-depth security across all three layers.

Every HTML response includes a strict CSP header:

Content-Security-Policy: default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src wss://your-domain.com

CSP directives are auto-generated from resource metadata, with default-src 'none' as the baseline.

  1. Session creation: A crypto-secure token is generated using crypto.getRandomValues()
  2. Token delivery: Sent to the client during the WebSocket handshake
  3. Validation: Every subsequent message must include the session token
  4. Expiration: Sessions expire after inactivity (configurable)
initData signature = HMAC-SHA256(data_check_string, secret_key)
secret_key = HMAC-SHA256(bot_token, "WebAppData")

The adapter validates every request’s initData before creating a session.

Access tokens will be validated against LINE’s token verification API once the LINE platform adapter is complete.

All ui:// resource paths are normalized before resolution:

  • ../ and . segments are resolved lexically
  • Paths are resolved relative to the app base directory
  • Resolved paths must remain within the configured asset directory

WebSocket messages include strict origin checking. The bridge only accepts messages from the configured resourceBaseUrl origin.