Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to fix XMPP Client User Impersonation Vulnerability #47

Merged
merged 1 commit into from Jan 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Try to fix XMPP Client User Impersonation Vulnerability
  • Loading branch information
Vitozz committed Jan 25, 2017
commit 02e976d4426a1319a7af7d26d7aba9d8c6077570
14 changes: 9 additions & 5 deletions src/xmpp/xmpp-im/xmpp_tasks.cpp
Expand Up @@ -888,14 +888,18 @@ bool JT_PushMessage::take(const QDomElement &e)
QDomElement forward;
Message::CarbonDir cd = Message::NoCarbon;

Jid fromJid = Jid(e1.attribute(QLatin1String("from")));
// Check for Carbon
QDomNodeList list = e1.childNodes();
for (int i = 0; i < list.size(); ++i) {
QDomElement el = list.at(i).toElement();

if (el.attribute("xmlns") == QLatin1String("urn:xmpp:carbons:2") && (el.tagName() == QLatin1String("received") || el.tagName() == QLatin1String("sent"))) {
if (el.attribute("xmlns") == QLatin1String("urn:xmpp:carbons:2")
&& (el.tagName() == QLatin1String("received") || el.tagName() == QLatin1String("sent"))
&& fromJid.compare(Jid(e1.attribute(QLatin1String("to"))), false)) {
QDomElement el1 = el.firstChildElement();
if (el1.tagName() == QLatin1String("forwarded") && el1.attribute(QLatin1String("xmlns")) == QLatin1String("urn:xmpp:forward:0")) {
if (el1.tagName() == QLatin1String("forwarded")
&& el1.attribute(QLatin1String("xmlns")) == QLatin1String("urn:xmpp:forward:0")) {
QDomElement el2 = el1.firstChildElement(QLatin1String("message"));
if (!el2.isNull()) {
forward = el2;
Expand All @@ -904,7 +908,8 @@ bool JT_PushMessage::take(const QDomElement &e)
}
}
}
else if (el.tagName() == QLatin1String("forwarded") && el.attribute(QLatin1String("xmlns")) == QLatin1String("urn:xmpp:forward:0")) {
else if (el.tagName() == QLatin1String("forwarded")
&& el.attribute(QLatin1String("xmlns")) == QLatin1String("urn:xmpp:forward:0")) {
forward = el.firstChildElement(QLatin1String("message")); // currently only messages are supportted
// TODO <delay> element support
if (!forward.isNull()) {
Expand All @@ -913,7 +918,6 @@ bool JT_PushMessage::take(const QDomElement &e)
}
}

QString from = e1.attribute(QLatin1String("from"));
Stanza s = client()->stream().createStanza(addCorrectNS(forward.isNull()? e1 : forward));
if(s.isNull()) {
//printf("take: bad stanza??\n");
Expand All @@ -926,7 +930,7 @@ bool JT_PushMessage::take(const QDomElement &e)
return false;
}
if (!forward.isNull()) {
m.setForwardedFrom(Jid(from));
m.setForwardedFrom(fromJid);
m.setCarbonDirection(cd);
}

Expand Down