CVE-2015-10088: Use of Externally-Controlled Format String (CWE-134)
value: A vulnerability, which was classified as critical, was found in ayttm up to 0.5.0.89. This affects the function http_connect in the library libproxy/proxy.c. The manipulation leads to format string. It is possible to initiate the attack remotely. The complexity of an attack is rather high. The exploitability is told to be difficult. The patch is named 40e04680018614a7d2b68566b261b061a0597046. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-222267.
CWE description: The product uses a function that accepts a format string as an argument, but the format string originates from an external source.
CVSS v3 base score: 8.1
Published: 2023-03-05T05:15Z
Repository: https://github.com/ayttm/ayttm
Language: C
Files changed: libproxy/proxy.c
Commit date: 2015-08-24 12:56:43 -0400
Commit message: Fix format string vulnerability

Reported by Kapil Anand on ayttm-users:
https://sourceforge.net/p/ayttm/mailman/message/34397158/

This patch does the following two things:

1. Makes sure debug_print is only used in DEBUG mode and not in non-DEBUG mode
2. Since debug_print is basically printf, we don't really need to first
   snprintf into a buffer and then print the buffer.
3. We no longer need debug_buff

Diff: diff --git a/libproxy/proxy.c b/libproxy/proxy.c
index 8b2bd6a..902954e 100644
--- a/libproxy/proxy.c
+++ b/libproxy/proxy.c
@@ -292,11 +292,10 @@ int http_connect(int sockfd, const char *host, int port, AyProxyData *proxy)
 {
 	/* step two : do  proxy tunneling init */
 	char cmd[512];
 	char *inputline = NULL;
 	char *proxy_auth = NULL;
-	char debug_buff[512];
 	int remaining = sizeof(cmd) - 1;
 
 	remaining -= snprintf(cmd, sizeof(cmd), "CONNECT %s:%d HTTP/1.1\r\n", host, port);
 	if (proxy->username && proxy->username[0]) {
 		proxy_auth = encode_proxy_auth_str(proxy);
@@ -307,21 +306,19 @@ int http_connect(int sockfd, const char *host, int port, AyProxyData *proxy)
 		remaining -= strlen(proxy_auth);
 		strncat(cmd, "\r\n", remaining);
 		remaining -= 2;
 	}
 	strncat(cmd, "\r\n", remaining);
-#ifndef DEBUG
-	snprintf(debug_buff, sizeof(debug_buff), "<%s>\n", cmd);
-	debug_print(debug_buff);
+#ifdef DEBUG
+	debug_print("<%s>\n", cmd);
 #endif
 	if (send(sockfd, cmd, strlen(cmd), 0) < 0)
 		return AY_CONNECTION_REFUSED;
 	if (ay_recv_line(sockfd, &inputline) < 0)
 		return AY_CONNECTION_REFUSED;
-#ifndef DEBUG
-	snprintf(debug_buff, sizeof(debug_buff), "<%s>\n", inputline);
-	debug_print(debug_buff);
+#ifdef DEBUG
+	debug_print("<%s>\n", inputline);
 #endif
 	if (!strstr(inputline, "200")) {
 		/* Check if proxy authorization needed */
 		if (strstr(inputline, "407")) {
 			while (ay_recv_line(sockfd, &inputline) > 0) {
@@ -342,13 +339,12 @@ int http_connect(int sockfd, const char *host, int port, AyProxyData *proxy)
 	while (strlen(inputline) > 1) {
 		free(inputline);
 		if (ay_recv_line(sockfd, &inputline) < 0) {
 			return AY_CONNECTION_REFUSED;
 		}
-#ifndef DEBUG
-		snprintf(debug_buff, sizeof(debug_buff), "<%s>\n", inputline);
-		debug_print(debug_buff);
+#ifdef DEBUG
+		debug_print("<%s>\n", inputline);
 #endif
 	}
 	free(inputline);
 
 	g_free(proxy_auth);

Vulnerable code: 	char debug_buff[512];
#ifndef DEBUG
	snprintf(debug_buff, sizeof(debug_buff), "<%s>\n", cmd);
	debug_print(debug_buff);
#ifndef DEBUG
	snprintf(debug_buff, sizeof(debug_buff), "<%s>\n", inputline);
	debug_print(debug_buff);
#ifndef DEBUG
		snprintf(debug_buff, sizeof(debug_buff), "<%s>\n", inputline);
		debug_print(debug_buff);
Fixed code: #ifdef DEBUG
	debug_print("<%s>\n", cmd);
#ifdef DEBUG
	debug_print("<%s>\n", inputline);
#ifdef DEBUG
		debug_print("<%s>\n", inputline);