SoapClient only strips `Authorization: Basic` when a WSDL imports from another host
@DanielEScherzer 已经在做这个了。
开始于 2026年9月15日。
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.2k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
Originally reported by @christos-cantina-security.
When a WSDL imports a schema or another WSDL from a different host, SoapClient clears the credentials from the stream context before fetching it in sdl_set_uri_credentials() @ ext/soap/php_sdl.c. The strip only matches the exact string Authorization: Basic in http.header, and only when that option is a string. The TODO right above it already notes that the array form of http.header is not handled.
Any other credential passes through to the third-party host as-is: a Bearer or Digest Authorization header, a lowercase authorization: header, a Cookie header, a Proxy-Authorization header, and every header given as an array.
The following code, with https://a.example serving a WSDL that contains <xsd:import schemaLocation="https://b.example/schema.xsd"/>:
<?php
$client = new SoapClient('https://a.example/service.wsdl', [
'cache_wsdl' => WSDL_CACHE_NONE,
'stream_context' => stream_context_create([
'http' => ['header' => "Authorization: Bearer secret-token\r\n"],
]),
]);
Resulted in this request on b.example:
GET /schema.xsd HTTP/1.1
Host: b.example
Authorization: Bearer secret-token
But I expected the header to be dropped on the host change, like Authorization: Basic already is:
GET /schema.xsd HTTP/1.1
Host: b.example
This should be hardened on master, potentially introducing a BC break:
- strip every
Authorization,Proxy-AuthorizationandCookieheader, case-insensitively - handle the array form of
http.header, resolving the existingTODO - add a
SoapClientoption to keep the headers for setups where the same credentials serve both hosts - document the behavior change in
UPGRADING
PHP Version
master
Operating System
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
评估
这个 Issue 还没有评估数据。