Skip to content

Commit

Permalink
Fix Vulnerability: CVE-2023-25774 TALOS-2023-1743
Browse files Browse the repository at this point in the history
SoftEther VPN vpnserver ConnectionAccept () denial of service vulnerability
  • Loading branch information
Daiyuu Nobori authored and davidebeatrici committed Oct 9, 2023
1 parent 3b932f5 commit 35077de
Show file tree
Hide file tree
Showing 5 changed files with 309 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/Cedar/Admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,8 @@ void AdminWebProcPost(CONNECTION *c, SOCK *s, HTTP_HEADER *h, UINT post_data_siz
if (RecvAll(s, data, post_data_size, s->SecureMode))
{
c->JsonRpcAuthed = true;
#ifndef GC_SOFTETHER_OSS

RemoveDosEntry(c->Listener, s);
#endif // GC_SOFTETHER_OSS

// Divide url_target into URL and query string
StrCpy(url, sizeof(url), url_target);
Expand Down Expand Up @@ -767,9 +766,8 @@ void AdminWebProcGet(CONNECTION *c, SOCK *s, HTTP_HEADER *h, char *url_target)
}

c->JsonRpcAuthed = true;
#ifndef GC_SOFTETHER_OSS

RemoveDosEntry(c->Listener, s);
#endif // GC_SOFTETHER_OSS

// Divide url_target into URL and query string
StrCpy(url, sizeof(url), url_target);
Expand Down Expand Up @@ -1199,9 +1197,7 @@ void JsonRpcProcOptions(CONNECTION *c, SOCK *s, HTTP_HEADER *h, char *url_target

c->JsonRpcAuthed = true;

#ifndef GC_SOFTETHER_OSS
RemoveDosEntry(c->Listener, s);
#endif // GC_SOFTETHER_OSS

AdminWebSendBody(s, 200, "OK", NULL, 0, NULL, NULL, NULL, h);
}
Expand All @@ -1228,9 +1224,7 @@ void JsonRpcProcGet(CONNECTION *c, SOCK *s, HTTP_HEADER *h, char *url_target)

c->JsonRpcAuthed = true;

#ifndef GC_SOFTETHER_OSS
RemoveDosEntry(c->Listener, s);
#endif // GC_SOFTETHER_OSS

// Divide url_target into URL and query string
StrCpy(url, sizeof(url), url_target);
Expand Down Expand Up @@ -1357,9 +1351,7 @@ void JsonRpcProcPost(CONNECTION *c, SOCK *s, HTTP_HEADER *h, UINT post_data_size

c->JsonRpcAuthed = true;

#ifndef GC_SOFTETHER_OSS
RemoveDosEntry(c->Listener, s);
#endif // GC_SOFTETHER_OSS

if (json_req == NULL || json_req_object == NULL)
{
Expand Down
69 changes: 69 additions & 0 deletions src/Cedar/Cedar.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,34 @@ void DecrementNoSsl(CEDAR *c, IP *ip, UINT num_dec)
UnlockList(c->NonSslList);
}

// Check whether the specified IP address is in Non-SSL connection list
bool IsInNoSsl(CEDAR *c, IP *ip)
{
bool ret = false;
// Validate arguments
if (c == NULL || ip == NULL)
{
return false;
}

LockList(c->NonSslList);
{
NON_SSL *n = SearchNoSslList(c, ip);

if (n != NULL)
{
if (n->EntryExpires > Tick64() && n->Count > NON_SSL_MIN_COUNT)
{
n->EntryExpires = Tick64() + (UINT64)NON_SSL_ENTRY_EXPIRES;
ret = true;
}
}
}
UnlockList(c->NonSslList);

return ret;
}

// Add new entry to Non-SSL connection list
bool AddNoSsl(CEDAR *c, IP *ip)
{
Expand Down Expand Up @@ -704,6 +732,47 @@ void DelConnection(CEDAR *cedar, CONNECTION *c)
UnlockList(cedar->ConnectionList);
}

// Get the number of unestablished connections
UINT GetUnestablishedConnections(CEDAR *cedar)
{
UINT i, ret;
// Validate arguments
if (cedar == NULL)
{
return 0;
}

ret = 0;

LockList(cedar->ConnectionList);
{
for (i = 0;i < LIST_NUM(cedar->ConnectionList);i++)
{
CONNECTION *c = LIST_DATA(cedar->ConnectionList, i);

switch (c->Type)
{
case CONNECTION_TYPE_CLIENT:
case CONNECTION_TYPE_INIT:
case CONNECTION_TYPE_LOGIN:
case CONNECTION_TYPE_ADDITIONAL:
switch (c->Status)
{
case CONNECTION_STATUS_ACCEPTED:
case CONNECTION_STATUS_NEGOTIATION:
case CONNECTION_STATUS_USERAUTH:
ret++;
break;
}
break;
}
}
}
UnlockList(cedar->ConnectionList);

return ret + Count(cedar->AcceptingSockets);
}

// Add connection to Cedar
void AddConnection(CEDAR *cedar, CONNECTION *c)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Cedar/Cedar.h
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ void DelHubEx(CEDAR *c, HUB *h, bool no_lock);
void StopAllHub(CEDAR *c);
void StopAllConnection(CEDAR *c);
void AddConnection(CEDAR *cedar, CONNECTION *c);
UINT GetUnestablishedConnections(CEDAR *cedar);
void DelConnection(CEDAR *cedar, CONNECTION *c);
void SetCedarCipherList(CEDAR *cedar, char *name);
void InitCedar();
Expand All @@ -1046,6 +1047,7 @@ bool AddNoSsl(CEDAR *c, IP *ip);
void DecrementNoSsl(CEDAR *c, IP *ip, UINT num_dec);
void DeleteOldNoSsl(CEDAR *c);
NON_SSL *SearchNoSslList(CEDAR *c, IP *ip);
bool IsInNoSsl(CEDAR *c, IP *ip);
void FreeTinyLog(TINY_LOG *t);
void WriteTinyLog(TINY_LOG *t, char *str);
TINY_LOG *NewTinyLog();
Expand Down
Loading

0 comments on commit 35077de

Please sign in to comment.