#1052·server

CORS 和 websocket 来源允许列表匹配不固定的域名,因此 'https://example.com' 也允许 'https://example.com.evil.net'

作者: lbellows创建于 2026年9月17日更新于 2026年9月17日

两个源允许列都使用 regexp.MustCompile 编译配置项,并使用 MatchString 进行匹配,除非操作员记得锚定:

  • auth/cors.go:45compileAllowedCORSOrigins,由 AllowOriginFunc 使用
  • api/stream/stream.go:183compileAllowedWebSocketOrigins,由 Upgrader.CheckOrigin 使用