You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix OOB write on URL callback with 2GB+ response. Add new size limit.
The OOB write did not happen on file-backed downloads, such as remote
includes. It only happened for memory-backed requests, which are only
these 4 in standard UnrealIRCd: centralblocklist, central spam report,
other spamreport blocks (eg to dronebl) and the log block with
destination webhook. All those 4 cases are very likely to be trusted
web servers, given the nature of the data you are sending to them.
The fix was to extend the size fields everywhere to 64 bits. It was
applied to both URL backends: url_unreal.c and url_curl.c.
The new API feature is a 'max_size' in OutgoingWebRequest, which
defaults to 1MB. This is only used for memory-backed responses,
so not for real file downloads. This fixes not only the reported
bug but also the case where a rogue webserver was unbounded in
terms of what response it could send back, potentially filling
up gigabytes of server memory.
Reported by Link420.
Copy file name to clipboardExpand all lines: include/struct.h
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1983,6 +1983,8 @@ struct OutgoingWebRequest
1983
1983
intconnect_timeout; /**< How many seconds to wait for the (TLS) connect to succeed */
1984
1984
inttransfer_timeout; /**< How many seconds the total transfer may take (connect+reading everything) */
1985
1985
intminimum_tls_version;
1986
+
long longmax_size; /**< Max response size for memory-backed downloads, in bytes.
1987
+
* 0 = use DOWNLOAD_MAX_SIZE. Ignored for file-backed. */
1986
1988
// If you are adding fields here:
1987
1989
// 1) update duplicate_outgoingwebrequest() in src/misc.c
1988
1990
// 2) and update free_outgoingwebrequest() there as well (if something needs to be freed)
@@ -1993,7 +1995,7 @@ struct OutgoingWebResponse
1993
1995
{
1994
1996
constchar*file; /**< The temporary file of the download, or NULL. This is only set if OutgoingWebRequest had 'store_in_file' set to 1 and the download was succesful. */
1995
1997
constchar*memory; /**< The memory buffer of the response, or NULL if an error occured (see errorbuf) */
1996
-
intmemory_len; /**< The length of 'memory', since the response may contain binary data. */
1998
+
long longmemory_len; /**< The length of 'memory', since the response may contain binary data. */
1997
1999
constchar*errorbuf; /**< If this is non-NULL then an error occured and this is the error string. Check this member before checking any others! */
1998
2000
intcached; /**< Set to 1 if OutgoingWebRequest had 'cachetime' set and we have a cache hit on the webserver. The file and errobuf will be NULL since there was no data transfer. */
1999
2001
void*ptr; /**< The OutgoingWebRequest 'callback_data' */
0 commit comments