From: Jason Parker Date: Mon, 23 Apr 2012 15:17:20 +0000 (+0000) Subject: Multiple revisions 363102,363106,363141 X-Git-Tag: certified/1.8.11-cert1~3^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3b33b02265f3f67f39a7797440641b6fb24fede;p=thirdparty%2Fasterisk.git Multiple revisions 363102,363106,363141 ........ r363102 | mjordan | 2012-04-23 08:37:55 -0500 (Mon, 23 Apr 2012) | 16 lines AST-2012-005: Fix remotely exploitable heap overflow in keypad button handling When handling a keypad button message event, the received digit is placed into a fixed length buffer that acts as a queue. When a new message event is received, the length of that buffer is not checked before placing the new digit on the end of the queue. The situation exists where sufficient keypad button message events would occur that would cause the buffer to be overrun. This patch explicitly checks that there is sufficient room in the buffer before appending a new digit. (closes issue ASTERISK-19592) Reported by: Russell Bryant ........ Merged revisions 363100 from http://svn.asterisk.org/svn/asterisk/branches/1.6.2 ........ r363106 | mjordan | 2012-04-23 09:05:02 -0500 (Mon, 23 Apr 2012) | 17 lines AST-2012-006: Fix crash in UPDATE handling when no channel owner exists If Asterisk receives a SIP UPDATE request after a call has been terminated and the channel has been destroyed but before the SIP dialog has been destroyed, a condition exists where a connected line update would be attempted on a non-existing channel. This would cause Asterisk to crash. The patch resolves this by first ensuring that the SIP dialog has an owning channel before attempting a connected line update. If an UPDATE request is received and no channel is associated with the dialog, a 481 response is sent. (closes issue ASTERISK-19770) Reported by: Thomas Arimont Tested by: Matt Jordan Patches: ASTERISK-19278-2012-04-16.diff uploaded by Matt Jordan (license 6283) ........ r363141 | jrose | 2012-04-23 09:33:16 -0500 (Mon, 23 Apr 2012) | 20 lines AST-2012-004: Fix an error that allows AMI users to run shell commands sans authorization. As detailed in the advisory, AMI users without write authorization for SYSTEM class AMI actions were able to run system commands by going through other AMI commands which did not require that authorization. Specifically, GetVar and Status allowed users to do this by setting their variable/s options to the SHELL or EVAL functions. Also, within 1.8, 10, and trunk there was a similar flaw with the Originate action that allowed users with originate permission to run MixMonitor and supply a shell command in the Data argument. That flaw is fixed in those versions of this patch. (closes issue ASTERISK-17465) Reported By: David Woolley Patches: 162_ami_readfunc_security_r2.diff uploaded by jrose (license 6182) 18_ami_readfunc_security_r2.diff uploaded by jrose (license 6182) 10_ami_readfunc_security_r2.diff uploaded by jrose (license 6182) ........ Merged revisions 363117 from http://svn.asterisk.org/svn/asterisk/branches/1.6.2 ........ Merged revisions 363102,363106,363141 from http://svn.asterisk.org/svn/asterisk/branches/1.8 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8-digiumphones@363161 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 235f98aac7..dd4deccb6b 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -22492,6 +22492,10 @@ static int handle_request_update(struct sip_pvt *p, struct sip_request *req) transmit_response(p, "501 Method Not Implemented", req); return 0; } + if (!p->owner) { + transmit_response(p, "481 Call/Transaction Does Not Exist", req); + return 0; + } if (get_rpid(p, req)) { struct ast_party_connected_line connected; struct ast_set_party_connected_line update_connected; diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 2d1447f4d2..93a2175fc4 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -6147,7 +6147,8 @@ static int handle_message(struct skinny_req *req, struct skinnysession *s) struct skinny_speeddial *sd; struct skinny_line *l; struct skinny_device *d = s->device; - + size_t len; + if ((!s->device) && (letohl(req->e) != REGISTER_MESSAGE && letohl(req->e) != ALARM_MESSAGE)) { ast_log(LOG_WARNING, "Client sent message #%d without first registering.\n", req->e); ast_free(req); @@ -6212,8 +6213,13 @@ static int handle_message(struct skinny_req *req, struct skinnysession *s) ast_log(LOG_WARNING, "Unsupported digit %d\n", digit); } - d->exten[strlen(d->exten)] = dgt; - d->exten[strlen(d->exten)+1] = '\0'; + len = strlen(d->exten); + if (len < sizeof(d->exten) - 1) { + d->exten[len] = dgt; + d->exten[len + 1] = '\0'; + } else { + ast_log(AST_LOG_WARNING, "Dropping digit with value %d because digit queue is full\n", dgt); + } } else res = handle_keypad_button_message(req, s); } diff --git a/main/manager.c b/main/manager.c index 0a9f0c76fb..6e5dde673e 100644 --- a/main/manager.c +++ b/main/manager.c @@ -1180,6 +1180,19 @@ static const struct permalias { { 0, "none" }, }; +/*! \brief Checks to see if a string which can be used to evaluate functions should be rejected */ +static int function_capable_string_allowed_with_auths(const char *evaluating, int writepermlist) +{ + if (!(writepermlist & EVENT_FLAG_SYSTEM) + && ( + strstr(evaluating, "SHELL") || /* NoOp(${SHELL(rm -rf /)}) */ + strstr(evaluating, "EVAL") /* NoOp(${EVAL(${some_var_containing_SHELL})}) */ + )) { + return 0; + } + return 1; +} + /*! \brief Convert authority code to a list of options */ static const char *authority_to_str(int authority, struct ast_str **res) { @@ -3178,6 +3191,12 @@ static int action_getvar(struct mansession *s, const struct message *m) return 0; } + /* We don't want users with insufficient permissions using certain functions. */ + if (!(function_capable_string_allowed_with_auths(varname, s->session->writeperm))) { + astman_send_error(s, m, "GetVar Access Forbidden: Variable"); + return 0; + } + if (!ast_strlen_zero(name)) { if (!(c = ast_channel_get_by_name(name))) { astman_send_error(s, m, "No such channel"); @@ -3238,6 +3257,11 @@ static int action_status(struct mansession *s, const struct message *m) idText[0] = '\0'; } + if (!(function_capable_string_allowed_with_auths(variables, s->session->writeperm))) { + astman_send_error(s, m, "Status Access Forbidden: Variables"); + return 0; + } + if (all) { if (!(iter = ast_channel_iterator_all_new())) { ast_free(str); @@ -4029,6 +4053,7 @@ static int action_originate(struct mansession *s, const struct message *m) ast_parse_allow_disallow(NULL, &format, codecs, 1); } if (!ast_strlen_zero(app) && s->session) { + int bad_appdata = 0; /* To run the System application (or anything else that goes to * shell), you must have the additional System privilege */ if (!(s->session->writeperm & EVENT_FLAG_SYSTEM) @@ -4039,10 +4064,13 @@ static int action_originate(struct mansession *s, const struct message *m) TryExec(System(rm -rf /)) */ strcasestr(app, "agi") || /* AGI(/bin/rm,-rf /) EAGI(/bin/rm,-rf /) */ - strstr(appdata, "SHELL") || /* NoOp(${SHELL(rm -rf /)}) */ - strstr(appdata, "EVAL") /* NoOp(${EVAL(${some_var_containing_SHELL})}) */ + strcasestr(app, "mixmonitor") || /* MixMonitor(blah,,rm -rf) */ + (strstr(appdata, "SHELL") && (bad_appdata = 1)) || /* NoOp(${SHELL(rm -rf /)}) */ + (strstr(appdata, "EVAL") && (bad_appdata = 1)) /* NoOp(${EVAL(${some_var_containing_SHELL})}) */ )) { - astman_send_error(s, m, "Originate with certain 'Application' arguments requires the additional System privilege, which you do not have."); + char error_buf[64]; + snprintf(error_buf, sizeof(error_buf), "Originate Access Forbidden: %s", bad_appdata ? "Data" : "Application"); + astman_send_error(s, m, error_buf); return 0; } }