Skip to content

Commit 7052312

Browse files
committed
Refuse PUSH_REQUEST as client/refactor process_incoming_push_request
When a server sends a client a push request, the client will reply with a push reply. The reply is bogus and almost empty since almost all the options that are normally set (remote ip etc) are unset. I checked 2.4 and master and this does not have any security implications or other bugs but it is still better to refuse this. This code also refactors the method to get rid of the ret variable to make the code flow easier to understand. Signed-off-by: Arne Schwabe <[email protected]>
1 parent cb87888 commit 7052312

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

src/openvpn/push.c

+21-18
Original file line numberDiff line numberDiff line change
@@ -966,15 +966,20 @@ push_remove_option(struct options *o, const char *p)
966966
int
967967
process_incoming_push_request(struct context *c)
968968
{
969-
int ret = PUSH_MSG_ERROR;
969+
/* if we receive a message as a client we do not want to reply to it. */
970+
if (c->options.pull)
971+
{
972+
return PUSH_MSG_ERROR;
973+
}
974+
970975

971976

972977
if (tls_authentication_status(c->c2.tls_multi) == TLS_AUTHENTICATION_FAILED
973978
|| c->c2.tls_multi->multi_state == CAS_FAILED)
974979
{
975980
const char *client_reason = tls_client_reason(c->c2.tls_multi);
976981
send_auth_failed(c, client_reason);
977-
ret = PUSH_MSG_AUTH_FAILURE;
982+
return PUSH_MSG_AUTH_FAILURE;
978983
}
979984
else if (tls_authentication_status(c->c2.tls_multi) == TLS_AUTHENTICATION_SUCCEEDED
980985
&& c->c2.tls_multi->multi_state >= CAS_CONNECT_DONE)
@@ -984,29 +989,27 @@ process_incoming_push_request(struct context *c)
984989
openvpn_time(&now);
985990
if (c->c2.sent_push_reply_expiry > now)
986991
{
987-
ret = PUSH_MSG_ALREADY_REPLIED;
992+
return PUSH_MSG_ALREADY_REPLIED;
988993
}
989-
else
990-
{
991-
/* per-client push options - peer-id, cipher, ifconfig, ipv6-ifconfig */
992-
struct push_list push_list = { 0 };
993-
struct gc_arena gc = gc_new();
994994

995-
if (prepare_push_reply(c, &gc, &push_list)
996-
&& send_push_reply(c, &push_list))
997-
{
998-
ret = PUSH_MSG_REQUEST;
999-
c->c2.sent_push_reply_expiry = now + 30;
1000-
}
1001-
gc_free(&gc);
995+
int ret = PUSH_MSG_ERROR;
996+
/* per-client push options - peer-id, cipher, ifconfig, ipv6-ifconfig */
997+
struct push_list push_list = { 0 };
998+
struct gc_arena gc = gc_new();
999+
1000+
if (prepare_push_reply(c, &gc, &push_list)
1001+
&& send_push_reply(c, &push_list))
1002+
{
1003+
ret = PUSH_MSG_REQUEST;
1004+
c->c2.sent_push_reply_expiry = now + 30;
10021005
}
1006+
gc_free(&gc);
1007+
return ret;
10031008
}
10041009
else
10051010
{
1006-
ret = PUSH_MSG_REQUEST_DEFERRED;
1011+
return PUSH_MSG_REQUEST_DEFERRED;
10071012
}
1008-
1009-
return ret;
10101013
}
10111014

10121015
static void

0 commit comments

Comments
 (0)