summaryrefslogtreecommitdiff
path: root/main/http.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-03-27 14:39:11 +0000
committerMatthew Jordan <mjordan@digium.com>2013-03-27 14:39:11 +0000
commitec144089eaffe07e07521ccdf27109e7e431ab40 (patch)
treeb4a6d6ee05ddea8a32831fc49b4389910d89f3d0 /main/http.c
parent4b5a0e1932104adb25132d31bf84f1caf621d8bc (diff)
AST-2013-002: Prevent denial of service in HTTP server
AST-2012-014, fixed in January of this year, contained a fix for Asterisk's HTTP server for a remotely-triggered crash. While the fix put in place fixed the possibility for the crash to be triggered, a denial of service vector still exists with that solution if an attacker sends one or more HTTP POST requests with very large Content-Length values. This patch resolves this by capping the Content-Length at 1024 bytes. Any attempt to send an HTTP POST with Content-Length greater than this cap will not result in any memory allocation. The POST will be responded to with an HTTP 413 "Request Entity Too Large" response. This issue was reported by Christoph Hebeisen of TELUS Security Labs (closes issue ASTERISK-20967) Reported by: Christoph Hebeisen patches: AST-2013-002-1.8.diff uploaded by mmichelson (License 5049) AST-2013-002-10.diff uploaded by mmichelson (License 5049) AST-2013-002-11.diff uploaded by mmichelson (License 5049) ........ Merged revisions 383978 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383980 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/http.c')
-rw-r--r--main/http.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/main/http.c b/main/http.c
index 73fb8bc92..a92c77db9 100644
--- a/main/http.c
+++ b/main/http.c
@@ -601,6 +601,8 @@ void ast_http_uri_unlink_all_with_key(const char *key)
AST_RWLIST_UNLOCK(&uris);
}
+#define MAX_POST_CONTENT 1025
+
/*
* get post variables from client Request Entity-Body, if content type is
* application/x-www-form-urlencoded
@@ -633,6 +635,13 @@ struct ast_variable *ast_http_get_post_vars(
return NULL;
}
+ if (content_length > MAX_POST_CONTENT - 1) {
+ ast_log(LOG_WARNING, "Excessively long HTTP content. %d is greater than our max of %d\n",
+ content_length, MAX_POST_CONTENT);
+ ast_http_send(ser, AST_HTTP_POST, 413, "Request Entity Too Large", NULL, NULL, 0, 0);
+ return NULL;
+ }
+
buf = ast_malloc(content_length + 1);
if (!buf) {
return NULL;