curl命令行参数安全漏洞:凭据在/proc文件系统中暴露

本文详细分析了curl工具在处理命令行参数时的安全缺陷,当凭据以无空格形式传递时,敏感信息会通过/proc/XXX/cmdline暴露,导致系统其他用户可查看密码等敏感数据,存在安全风险。

curl 不隐藏通过 CLI 参数提供的 /proc/XXX/cmdline 中的凭据

摘要

cleanarg 辅助函数在凭据以无空格形式提供给短选项标志时不起作用,例如 -uUSER:PASS 对比 -u USER:PASS-UUSER:PASS 对比 -U UUSER:PASS

受影响版本

1
2
3
4
5
curl -V
curl 8.12.1 (x86_64-pc-linux-musl) libcurl/8.12.1 OpenSSL/3.3.3 zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.1 nghttp2/1.64.0
Release-Date: 2025-02-13
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd

重现步骤

在 Linux 环境(在 zsh、bash、posix sh 中测试)运行以下命令:

使用 root 或其他用户运行 curl:

1
curl 8.8.8.8:444 -u user:pass -ufoo:bar -U baz:qux -U123:456 --user USER:PASS

在同一主机上的另一个终端中,以另一个非特权用户身份运行 ps ax

1
2
$ ps ax | grep ' [c]url 8'
283299 ?        Ss     0:00 curl 8.8.8.8:444 -u           -ufoo:bar -U         -U123:456 --user
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
$ cat /proc/283299/cmdline | tr '\0' '\n'
curl
8.8.8.8:444
-u

-ufoo:bar
-U

-U123:456
--user
 

支持材料/参考文献

初始实现:https://github.com/curl/curl/commit/7f67a28c2a2ee81b0998e57a10bccbdfe9078fd7

影响

摘要

当通过命令行无空格分隔符传递敏感参数(例如密码)时,curl 无法屏蔽这些参数。因此,这些参数在系统进程列表(ps aux、/proc//cmdline)中仍然可见,构成安全风险。

影响

系统上的任何用户都可以通过检查运行中的进程查看敏感信息。这可能导致未经授权的访问、凭据泄露和潜在的安全漏洞。

时间线

  • 2025年2月19日 13:41 UTC:stogusho 向 curl 提交报告

  • 2025年2月19日 13:46 UTC:bagder (curl staff) 评论认为这是 bug 而非安全漏洞

  • 2025年2月19日 13:49 UTC:dgustafsson (curl staff) 同意不是安全漏洞

  • 2025年2月19日 14:58 UTC:bagder 建议在 GitHub 提交常规问题

  • 2025年2月19日 15:01 UTC:stogusho 表示将在 GitHub 提交问题

  • 2025年2月19日 23:03 UTC:bagder 关闭报告并将状态改为 Informative

  • 2025年7月1日 14:10 UTC:bagder 请求披露此报告

  • 2025年7月3日 06:43 UTC:bagder 披露此报告

报告详情

  • 报告时间:2025年2月19日 13:41 UTC
  • 报告者:stogusho
  • 报告对象:curl
  • 报告ID:#3000639
  • 严重程度:中等 (4 ~ 6.9)
  • 披露时间:2025年7月3日 06:43 UTC
  • 弱点:敏感信息的明文传输
  • CVE ID:无
  • 赏金:无
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计