From: "cron2 (Code Review)" Date: Wed, 17 Jan 2024 09:38:53 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="KO7nwEhUF8k="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: NTLM: add length check to add_security_buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --KO7nwEhUF8k= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#2) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/496?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: NTLM: add length check to add_security_buffer ...................................................................... NTLM: add length check to add_security_buffer Especially ntlmv2_response can be very big, so make sure we not do exceed the size of the phase3 buffer. Change-Id: Icea931d29e3e504e23e045539b21013b42172664 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Message-Id: <20240117085951.27414-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28= 037.html Signed-off-by: Gert Doering --- M src/openvpn/ntlm.c 1 file changed, 9 insertions(+), 4 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/96/496/2 diff --git a/src/openvpn/ntlm.c b/src/openvpn/ntlm.c index bc33f41..99d4ae7 100644 --- a/src/openvpn/ntlm.c +++ b/src/openvpn/ntlm.c @@ -154,8 +154,13 @@ static void add_security_buffer(int sb_offset, void *data, int length, - unsigned char *msg_buf, int *msg_bufpos) + unsigned char *msg_buf, int *msg_bufpos, size_t msg_bu= fsize) { + if (*msg_bufpos + length > msg_bufsize) + { + msg(M_WARN, "NTLM: security buffer too big for message buffer"); + return; + } /* Adds security buffer data to a message and sets security buffer's * offset and length */ msg_buf[sb_offset] =3D (unsigned char)length; @@ -362,15 +367,15 @@ /* NTLMv2 response */ add_security_buffer(0x14, ntlmv2_response, ntlmv2_blob_size + 16, - phase3, &phase3_bufpos); + phase3, &phase3_bufpos, sizeof(phase3)); /* username in ascii */ add_security_buffer(0x24, username, strlen(username), phase3, - &phase3_bufpos); + &phase3_bufpos, sizeof(phase3)); /* Set domain. If is empty, default domain will be used * (i.e. proxy's domain) */ - add_security_buffer(0x1c, domain, strlen(domain), phase3, &phase3_bufp= os); + add_security_buffer(0x1c, domain, strlen(domain), phase3, &phase3_bufp= os, sizeof(phase3)); /* other security buffers will be empty */ phase3[0x10] =3D phase3_bufpos; /* lm not used */ -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/496?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Icea931d29e3e504e23e045539b21013b42172664 Gerrit-Change-Number: 496 Gerrit-PatchSet: 2 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --KO7nwEhUF8k= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #2 to the change originally cr= eated by flichtenheld.

View Change

The following approvals got outda= ted and were removed: Code-Review+2 by cron2

NTLM: add length check to add_security_buffer
Especially ntlmv2_response can be very big, so make sure
we not do exce= ed the size of the phase3 buffer.

Change-Id: Icea931d29e3e504e23e045= 539b21013b42172664
Signed-off-by: Frank Lichtenheld <frank@...2641...= >
Acked-by: Gert Doering <gert@...1296...>
Message-Id: <2= 0240117085951.27414-1-gert@...1296...>
URL: https://www.mail-archive.= com/openvpn-devel@lists.sourceforge.net/msg28037.html
Signed-off-by: Ger= t Doering <gert@...1296...>
---
M src/openvpn/ntlm.c
1 file = changed, 9 insertions(+), 4 deletions(-)

git pull ssh://gerrit.op=
envpn.net:29418/openvpn refs/changes/96/496/2
diff --git a/src/open=
vpn/ntlm.c b/src/openvpn/ntlm.c
index bc33f41..99d4ae7 1006= 44
--- a/src/openvpn/ntlm.c
+++ b/src/openv= pn/ntlm.c
@@ -154,8 +154,13 @@

= static void
add_security_buffer(int sb_offset, void= *data, int length,
- = unsigned char *msg_buf, int *msg_bufpos)
+ unsigned char *m= sg_buf, int *msg_bufpos, size_t msg_bufsize)
{
<= span style=3D"color: hsl(120, 100%, 40%);">+ if (*msg_bufpos + length &g= t; msg_bufsize)
+ = {
+ msg(M_WARN= , "NTLM: security buffer too big for message buffer");
= + return;
+ }
/* Adds= security buffer data to a message and sets security buffer's * offset and length */
msg_buf[sb_offset]= =3D (unsigned char)length;
@@ -362,15 +367,15 @@
/* NTLMv2 response */
ad= d_security_buffer(0x14, ntlmv2_response, ntlmv2_blob_size + 16,
<= span style=3D"color: hsl(0, 100%, 40%);">- phase3, &= amp;phase3_bufpos);
+= phase3, &phase3_bufpos, sizeof(phase3));=

/* username in ascii */
= add_security_buffer(0x24, username, strlen(username), phase3,
= - &pha= se3_bufpos);
+ = &phase3_bufpos, sizeof(phase3));

/* Set domain. If <domain> is empty, default domain= will be used
* (i.e. proxy's domain) */- add_security_buffer(0x1c, = domain, strlen(domain), phase3, &phase3_bufpos);
+ add_security_buffer(0x1c, domain, str= len(domain), phase3, &phase3_bufpos, sizeof(phase3));
=
/* other security buffers will be empty */
= phase3[0x10] =3D phase3_bufpos; /* lm not used */
=

To view, visit change 496. To unsubscribe, or for help= writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icea931d29e3e504e23e045539b2= 1013b42172664
Gerrit-Change-Number: 496
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--KO7nwEhUF8k=--