Skip to content

net: lib: http_server: Buffer Under-read

High
ceolin published GHSA-hfww-j92m-x8fv Feb 3, 2025

Package

zephyr (zephyr)

Affected versions

<= 3.7

Patched versions

None

Description

Summary

No proper validation of the length of user input in http_server_get_content_type_from_extension in /subsys/net/lib/http/http_server_core.c.

Details

There is no check whether &url[url_len - ct->extension_len] creates a pointer prior to url.

void http_server_get_content_type_from_extension(char *url, char *content_type,
						 size_t content_type_size)
{
	size_t url_len = strlen(url);

	HTTP_SERVER_CONTENT_TYPE_FOREACH(ct) {
		char *ext = &url[url_len - ct->extension_len];  // (0) - Create pointer prior to url if url_len is less than ct->extension_len

		if (strncmp(ext, ct->extension, ct->extension_len) == 0) {  // (1) - Access of memory before url buffer
			strncpy(content_type, ct->content_type, content_type_size);
			return;
		}
	}
}
  • (0) - Create pointer prior to url if url_len is less than ct->extension_len
  • (1) - Access of memory before url buffer

PoC

I haven't tried to reproduce these potential vulnerabilities against a live install of the Zephyr OS.

Impact

An attacker could cause a segmentation fault or crash by causing memory to be read outside of the bounds of the buffer.

Patches

main: #80396

For more information

If you have any questions or comments about this advisory:

embargo: 2025-01-23

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H

CVE ID

CVE-2024-10395

Weaknesses

Credits