-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add carbon source verification (CVE-2017-5589)
- Loading branch information
Showing
3 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
from gabbletest import XmppXmlStream, exec_test, elem, acknowledge_iq | ||
from servicetest import (EventPattern, wrap_channel, assertEquals, assertLength, | ||
assertContains) | ||
assertContains, TimeoutError) | ||
import constants as cs | ||
|
||
NS_CARBONS = 'urn:xmpp:carbons:2' | ||
|
@@ -172,6 +172,57 @@ def test(q, bus, conn, stream): | |
assert body['content-type'] == 'text/plain', body | ||
assert body['content'] == u'goodbye', body | ||
|
||
# Verify source protection | ||
msg = elem('message', type='chat', from_='[email protected]/agent712')( | ||
elem(NS_CARBONS, 'received')( | ||
elem(NS_FORWARD, 'forwarded')( | ||
elem('jabber:client','message', id=id, from_='[email protected]/Pidgin', type='chat')( | ||
elem('body')('Mr. Anderson!') | ||
) | ||
) | ||
) | ||
) | ||
stream.send(msg) | ||
# This is a nasty test but we need to make sure spoofed message is ignored | ||
try: | ||
q.timeout = 2 | ||
message_received = q.expect('dbus-signal', signal='MessageReceived') | ||
assert not message_received, message_received.args | ||
except TimeoutError as e: | ||
pass | ||
|
||
# And MUC - demo attack vector | ||
msg = elem('message')( | ||
elem(NS_CARBONS, 'received')( | ||
elem(NS_FORWARD, 'forwarded')( | ||
elem('jabber:client','message', id=sent_token, from_='[email protected]/Pidgin', to='test@localhost')( | ||
elem('body')('oh btb') | ||
) | ||
) | ||
), | ||
elem('jabber:x:conference', 'x', jid='room@localhost') | ||
) | ||
stream.send(msg) | ||
event = q.expect('stream-iq', iq_type='get', query_ns='http://jabber.org/protocol/disco#info', to='room@localhost') | ||
|
||
# MUC Invite Attack execution | ||
msg = elem('message', from_='[email protected]/agent712')( | ||
elem(NS_CARBONS, 'received')( | ||
elem(NS_FORWARD, 'forwarded')( | ||
elem('jabber:client','message', id=sent_token, from_='[email protected]/Pidgin', to='test@localhost')( | ||
elem('body')('Nice party here, really') | ||
) | ||
) | ||
), | ||
elem('jabber:x:conference', 'x', jid='[email protected]') | ||
) | ||
stream.send(msg) | ||
try: | ||
event = q.expect('stream-iq', iq_type='get', query_ns='http://jabber.org/protocol/disco#info') | ||
assert not event, event.stanza | ||
except TimeoutError as e: | ||
pass | ||
|
||
|
||
if __name__ == '__main__': | ||
exec_test(test, protocol=CarbonStream, params={'message-carbons':True}) |