Skip to content

chore(gateway/teams): deferred review items from #667 #676

@masami-agent

Description

@masami-agent

Summary

Deferred items from the Teams adapter review (PR #667). None are blocking but should be addressed for production hardening.

Items

Security

  1. serviceUrl domain sanity check — Defense-in-depth: validate that cached serviceUrl domains are known Bot Framework endpoints. Note: Microsoft has marked IsTrustedServiceUrl as obsolete, so this should not be the primary defense.
  2. validate_nbf disabled — Consider enabling nbf validation with leeway = 30 for clock skew tolerance instead of skipping entirely.
  3. algorithms includes RS384 — OpenID metadata only declares RS256; consider restricting to vec![Algorithm::RS256].

Performance

  1. teams_service_urls uses Mutex — Reply path (read) is much hotter than inbound path (write). Switch to RwLock to reduce contention under load.
  2. teams_service_urls unbounded — Add max size similar to LINE's REPLY_TOKEN_CACHE_MAX.

Code Quality

  1. update_activity() dead code — Defined but never called. Add #[allow(dead_code)] with comment or defer to streaming PR.
  2. jsonwebtoken = "9" unpinned — Security-critical dependency; consider pinning to exact version.
  3. config_from_env test uses remove_var — Race condition risk in multi-threaded test runner; consider #[serial_test::serial] or temp_env.
  4. JWKS refresh_jwks thundering herd — Multiple concurrent cache misses during key rotation will all hit Microsoft's endpoint. Document as accepted behavior or add a lock.
  5. Telegram API URL hardcoded — Extract to TELEGRAM_API_BASE constant (matching LINE's LINE_API_BASE) for mock testing.
  6. LINE unwrap_or_default() for channel_id — Add warning log when empty string is produced.

Source

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurep2Medium — planned work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions