Mercurial > pidgin.yaz
annotate libpurple/protocols/jabber/auth_scram.h @ 30702:6829b27ee4c8
This patch attempts to fix four bugs in the oscar protocol plugin that
were introduced with the X-Status code in Pidgin 2.7.0.
Problem #1 (the remotely-triggerable crash):
The crash happens when a buddy sets an xstatus message containing <desc>
but no closing </desc>, or <title> but no closing </title>. The fix
is to check the result of strstr(closing_tag_name) and do nothing if it
is NULL. This is CVE-2010-2528.
Problem #2:
Fixes potential incorrect parsing of the xstatus string that could result
in an incorrect message being displayed to the libpurple user. Happens if
an xstatus message contains </desc> before <desc>, or </title> before
<title>. The fix is to start looking for the closing tag at the end
of the beginning tag rather than at the beginning of the xstatus xml.
Probably not a security problem, but definitely a bug.
Problem #3:
Fixes potential incorrect parsing of the xstatus string that could result
in the title not being shown to the libpurple user. Happens if the close
title tag appears after the desc tag in the xstatus xml, because we add a
null character at the beginning of the close title tag, so strstr() for
the desc tag would stop searching there. Probably not a security problem,
but definitely a bug.
Problem #4:
Fixes potential incorrect display of the xstatus string that could result
in an incorrect message being displayed to the libpurple user. Happens
because we reusing the 'xml' string when preparing the string for the user,
but we copy values from xml to xml. If those values overlap with themselves
or with each other then an incorrect value could be displayed. Probably not
a security problem, but definitely a bug.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 21 Jul 2010 02:49:23 +0000 |
parents | 1c1910b17ae5 |
children |
rev | line source |
---|---|
29085
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
1 /** |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
2 * @file auth_scram.h Implementation of SASL-SCRAM authentication |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
3 * |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
4 * purple |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
5 * |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
6 * Purple is the legal property of its developers, whose names are too numerous |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
8 * source distribution. |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
9 * |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
10 * This program is free software; you can redistribute it and/or modify |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
13 * (at your option) any later version. |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
14 * |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
18 * GNU General Public License for more details. |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
19 * |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
21 * along with this program; if not, write to the Free Software |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
23 */ |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
24 #ifndef PURPLE_JABBER_AUTH_SCRAM_H_ |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
25 #define PURPLE_JABBER_AUTH_SCRAM_H_ |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
26 |
29089
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
27 /* |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
28 * Every function in this file is ONLY exposed for tests. |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
29 * DO NOT USE ANYTHING HERE OR YOU WILL BE SENT TO THE PIT OF DESPAIR. |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
30 */ |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
31 |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
32 /* Per-connection state stored between messages. |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
33 * This is stored in js->auth_data_mech. |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
34 */ |
29104
1c1910b17ae5
jabber: Clean up the SCRAM code a little.
Paul Aurich <paul@darkrain42.org>
parents:
29099
diff
changeset
|
35 typedef struct { |
1c1910b17ae5
jabber: Clean up the SCRAM code a little.
Paul Aurich <paul@darkrain42.org>
parents:
29099
diff
changeset
|
36 const char *mech_substr; |
1c1910b17ae5
jabber: Clean up the SCRAM code a little.
Paul Aurich <paul@darkrain42.org>
parents:
29099
diff
changeset
|
37 const char *name; |
1c1910b17ae5
jabber: Clean up the SCRAM code a little.
Paul Aurich <paul@darkrain42.org>
parents:
29099
diff
changeset
|
38 guint size; |
1c1910b17ae5
jabber: Clean up the SCRAM code a little.
Paul Aurich <paul@darkrain42.org>
parents:
29099
diff
changeset
|
39 } JabberScramHash; |
29089
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
40 |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
41 typedef struct { |
29104
1c1910b17ae5
jabber: Clean up the SCRAM code a little.
Paul Aurich <paul@darkrain42.org>
parents:
29099
diff
changeset
|
42 const JabberScramHash *hash; |
29089
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
43 char *cnonce; |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
44 GString *auth_message; |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
45 |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
46 GString *client_proof; |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
47 GString *server_signature; |
29099
464d022d7d6e
jabber: Add SASLprep and the username substitution called for in draft-ietf-sasl-scram-10 5.1.
Paul Aurich <paul@darkrain42.org>
parents:
29093
diff
changeset
|
48 |
464d022d7d6e
jabber: Add SASLprep and the username substitution called for in draft-ietf-sasl-scram-10 5.1.
Paul Aurich <paul@darkrain42.org>
parents:
29093
diff
changeset
|
49 gchar *password; |
29089
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
50 gboolean channel_binding; |
29091
b0fb53868142
jabber: Handle the case where the server success-with-data is sent as a challenge/response pair.
Paul Aurich <paul@darkrain42.org>
parents:
29089
diff
changeset
|
51 int step; |
29089
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
52 } JabberScramData; |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
53 |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
54 #include "auth.h" |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
55 |
29085
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
56 /** |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
57 * Implements the Hi() function as described in the SASL-SCRAM I-D. |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
58 * |
29104
1c1910b17ae5
jabber: Clean up the SCRAM code a little.
Paul Aurich <paul@darkrain42.org>
parents:
29099
diff
changeset
|
59 * @param hash The struct corresponding to the hash function to be used. |
29085
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
60 * @param str The string to perform the PBKDF2 operation on. |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
61 * @param salt The salt. |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
62 * @param iterations The number of iterations to perform. |
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
63 * |
29089
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
64 * @returns A newly allocated string containing the result. The string is |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
65 * NOT null-terminated and its length is the length of the binary |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
66 * output of the hash function in-use. |
29085
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
67 */ |
29104
1c1910b17ae5
jabber: Clean up the SCRAM code a little.
Paul Aurich <paul@darkrain42.org>
parents:
29099
diff
changeset
|
68 guchar *jabber_scram_hi(const JabberScramHash *hash, const GString *str, |
29089
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
69 GString *salt, guint iterations); |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
70 |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
71 /** |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
72 * Calculates the proofs as described in Section 3 of the SASL-SCRAM I-D. |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
73 * |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
74 * @param data A JabberScramData structure. hash and auth_message must be |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
75 * set. client_proof and server_signature will be set as a result |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
76 * of this function. |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
77 * @param salt The salt (as specified by the server) |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
78 * @param iterations The number of iterations to perform. |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
79 * |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
80 * @returns TRUE if the proofs were successfully calculated. FALSE otherwise. |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29085
diff
changeset
|
81 */ |
29091
b0fb53868142
jabber: Handle the case where the server success-with-data is sent as a challenge/response pair.
Paul Aurich <paul@darkrain42.org>
parents:
29089
diff
changeset
|
82 gboolean jabber_scram_calc_proofs(JabberScramData *data, GString *salt, |
b0fb53868142
jabber: Handle the case where the server success-with-data is sent as a challenge/response pair.
Paul Aurich <paul@darkrain42.org>
parents:
29089
diff
changeset
|
83 guint iterations); |
29085
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
84 |
29093
65a34cce02e3
jabber: Fix up the remaining issues and add a test case that interoperates with gsasl. Woot.
Paul Aurich <paul@darkrain42.org>
parents:
29091
diff
changeset
|
85 /** |
65a34cce02e3
jabber: Fix up the remaining issues and add a test case that interoperates with gsasl. Woot.
Paul Aurich <paul@darkrain42.org>
parents:
29091
diff
changeset
|
86 * Feed the algorithm with the data from the server. |
65a34cce02e3
jabber: Fix up the remaining issues and add a test case that interoperates with gsasl. Woot.
Paul Aurich <paul@darkrain42.org>
parents:
29091
diff
changeset
|
87 */ |
65a34cce02e3
jabber: Fix up the remaining issues and add a test case that interoperates with gsasl. Woot.
Paul Aurich <paul@darkrain42.org>
parents:
29091
diff
changeset
|
88 gboolean jabber_scram_feed_parser(JabberScramData *data, gchar *in, gchar **out); |
65a34cce02e3
jabber: Fix up the remaining issues and add a test case that interoperates with gsasl. Woot.
Paul Aurich <paul@darkrain42.org>
parents:
29091
diff
changeset
|
89 |
65a34cce02e3
jabber: Fix up the remaining issues and add a test case that interoperates with gsasl. Woot.
Paul Aurich <paul@darkrain42.org>
parents:
29091
diff
changeset
|
90 /** |
65a34cce02e3
jabber: Fix up the remaining issues and add a test case that interoperates with gsasl. Woot.
Paul Aurich <paul@darkrain42.org>
parents:
29091
diff
changeset
|
91 * Clean up and destroy the data struct |
65a34cce02e3
jabber: Fix up the remaining issues and add a test case that interoperates with gsasl. Woot.
Paul Aurich <paul@darkrain42.org>
parents:
29091
diff
changeset
|
92 */ |
65a34cce02e3
jabber: Fix up the remaining issues and add a test case that interoperates with gsasl. Woot.
Paul Aurich <paul@darkrain42.org>
parents:
29091
diff
changeset
|
93 void jabber_scram_data_destroy(JabberScramData *data); |
65a34cce02e3
jabber: Fix up the remaining issues and add a test case that interoperates with gsasl. Woot.
Paul Aurich <paul@darkrain42.org>
parents:
29091
diff
changeset
|
94 |
29085
338eeaf371e2
jabber: Add the Hi() function (PBKDF2).
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
95 #endif /* PURPLE_JABBER_AUTH_SCRAM_H_ */ |