[Asterisk-code-review] manager: fix digest auth for ami/http mechanism. (asterisk[master])
Jaco Kroon
asteriskteam at digium.com
Tue May 8 05:20:39 CDT 2018
Jaco Kroon has uploaded this change for review. ( https://gerrit.asterisk.org/8938
Change subject: manager: fix digest auth for ami/http mechanism.
......................................................................
manager: fix digest auth for ami/http mechanism.
Given that the a2 buffer ends up containing the user-supplied uri value
a static buffer can be trivially overflowed. The potential DOS (memory
exhaustion) should be handled already in the http module by way of max
request size (specifically the MAX_HTTP_LINE_LENGTH).
ASTERISK-27841
Change-Id: I660609db13b8f9e5f9567f339dd804f4985d41b3
---
M main/manager.c
1 file changed, 14 insertions(+), 10 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/38/8938/1
diff --git a/main/manager.c b/main/manager.c
index 577c7f9..23e52b2 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -8006,22 +8006,26 @@
/* compute the expected response to compare with what we received */
{
- char a2[256];
+ char *a2;
char a2_hash[256];
char resp[256];
/* XXX Now request method are hardcoded in A2 */
- snprintf(a2, sizeof(a2), "%s:%s", ast_get_http_method(method), d.uri);
- ast_md5_hash(a2_hash, a2);
+ a2 = ast_asprintf("%s:%s", ast_get_http_method(method), d.uri);
+ if (a2) {
+ ast_md5_hash(a2_hash, a2);
- if (d.qop) {
- /* RFC 2617 */
- snprintf(resp, sizeof(resp), "%s:%08lx:%s:%s:auth:%s", user->a1_hash, nonce, d.nc, d.cnonce, a2_hash);
- } else {
- /* RFC 2069 */
- snprintf(resp, sizeof(resp), "%s:%08lx:%s", user->a1_hash, nonce, a2_hash);
+ if (d.qop) {
+ /* RFC 2617 */
+ snprintf(resp, sizeof(resp), "%s:%08lx:%s:%s:auth:%s", user->a1_hash, nonce, d.nc, d.cnonce, a2_hash);
+ } else {
+ /* RFC 2069 */
+ snprintf(resp, sizeof(resp), "%s:%08lx:%s", user->a1_hash, nonce, a2_hash);
+ }
+ ast_md5_hash(resp_hash, resp);
+
+ ast_free(a2);
}
- ast_md5_hash(resp_hash, resp);
}
if (strncasecmp(d.response, resp_hash, strlen(resp_hash))) {
--
To view, visit https://gerrit.asterisk.org/8938
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I660609db13b8f9e5f9567f339dd804f4985d41b3
Gerrit-Change-Number: 8938
Gerrit-PatchSet: 1
Gerrit-Owner: Jaco Kroon <jaco at uls.co.za>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180508/3ad39c14/attachment-0001.html>
More information about the asterisk-code-review
mailing list