curl 内存泄漏漏洞分析:doh_write_cb 函数问题与修复

本文详细分析了curl项目中由doh_write_cb函数引起的内存泄漏漏洞,包括复现步骤、堆栈跟踪信息以及开发团队的修复过程,最终确认为非安全问题但已得到修复。

内存泄漏来自 doh_write_cb | HackerOne 报告 #3089595

摘要

通过 curl_fuzzer_http 发现的内存泄漏问题。

受影响版本

curl 8.13.0-DEV (x86_64-apple-darwin23.6.0) libcurl/8.13.0-DEV OpenSSL/1.0.2n zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 nghttp2/1.55.1 librtmp/2.3 发布日期:[未发布] 协议:dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp ws wss 特性:alt-svc AsynchDNS HSTS HTTP2 HTTPS-proxy IDN IPv6 Largefile libz NTLM PSL SSL threadsafe TLS-SRP UnixSockets

复现步骤

使用复现器运行模糊测试器。

支持材料/参考

堆栈跟踪如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
==14==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 107 byte(s) in 1 object(s) allocated from:
    #0 0x55da4969379c in realloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:82:3
    #1 0x55da496ff27b in curl_dbg_realloc /src/curl/lib/memdebug.c:265:9
    #2 0x55da497fc6f3 in dyn_nappend /src/curl/lib/dynbuf.c:111:15
    #3 0x55da497faee5 in doh_write_cb /src/curl/lib/doh.c:183:6
    #4 0x55da497f2636 in cw_out_ptr_flush /src/curl/lib/cw-out.c:224:16
    #5 0x55da497f1644 in cw_out_do_write /src/curl/lib/cw-out.c:383:14
    #6 0x55da497f0ab6 in cw_out_write /src/curl/lib/cw-out.c:416:14
    #7 0x55da497f2f62 in cw_pause_write /src/curl/lib/cw-pause.c:192:14
    #8 0x55da497476e1 in Curl_cwriter_write /src/curl/lib/sendf.c:184:10
    #9 0x55da497476e1 in cw_download_write /src/curl/lib/sendf.c:312:14
    #10 0x55da497415b9 in Curl_cwriter_write /src/curl/lib/sendf.c:184:10
    #11 0x55da497415b9 in Curl_client_write /src/curl/lib/sendf.c:92:12
    #12 0x55da498363a5 in Curl_http_write_resp /src/curl/lib/http.c:4201:14
    #13 0x55da49762635 in Curl_xfer_write_resp /src/curl/lib/transfer.c:862:14
    #14 0x55da4975e364 in sendrecv_dl /src/curl/lib/transfer.c:342:14
    #15 0x55da4975e364 in Curl_sendrecv /src/curl/lib/transfer.c:441:14
    #16 0x55da497250f5 in state_performing /src/curl/lib/multi.c:1733:12
    #17 0x55da497250f5 in multi_runsingle /src/curl/lib/multi.c:2423:12
    #18 0x55da497222f2 in curl_multi_perform /src/curl/lib/multi.c:2599:16
    #19 0x55da496d3e98 in fuzz_handle_transfer(fuzz_data*) /src/curl_fuzzer/curl_fuzzer.cc:419:5
    #20 0x55da496d2e47 in LLVMFuzzerTestOneInput /src/curl_fuzzer/curl_fuzzer.cc:97:3

需要传递 -runs=100 参数,如 /out/curl_fuzzer_http /out/leak-247f5201c537eecc44d9f44dd815fd43f19a8a72 -runs=100,因为并非每次都会发生。

影响

内存泄漏可能最终导致拒绝服务(DOS)。

时间线

  • 2025年4月11日 20:06 UTC - catenacyber 提交报告
  • 2025年4月11日 20:08 UTC - catenacyber 评论:认为这不是安全问题,而是信息性报告
  • 2025年4月11日 20:23 UTC - bagder (curl staff) 确认收到报告
  • 2025年4月11日 20:28 UTC - dfandrich (curl staff) 指出小内存泄漏不被视为安全问题
  • 2025年4月14日 10:42 UTC - jimfuller2024 (curl staff) 提供漏洞披露政策链接
  • 2025年4月16日 07:54 UTC - bagder 确认泄漏量小且不频繁,不是安全问题,但已有修复PR (#16834)
  • 2025年4月16日 09:32 UTC - catenacyber 同意在合并后测试
  • 2025年4月18日 21:14 UTC - bagder 询问是否已修复
  • 2025年4月19日 09:24 UTC - catenacyber 确认问题已修复
  • 2025年4月20日 16:27 UTC - bagder 关闭报告,状态改为"信息性"
  • 2025年6月28日 12:24 UTC - bagder 请求披露报告
  • 2025年6月29日 19:12 UTC - catenacyber 同意披露,报告被公开

报告详情

  • 报告ID: #3089595
  • 严重程度: 无 (0.0)
  • 披露日期: 2025年6月29日 19:12 UTC
  • 弱点: 资源分配无限制或节流
  • CVE ID: 无
  • 赏金: 无
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计