Project

General

Profile

Message Router infinite loop recognition

Behnam Hatami
Added almost 4 years ago

Hi, As I examined this part of code in "MessageRouter.java" for recognizing loop is incorrect.

if (((packet.getType() == StanzaType.error) && (packet.getFrom() != null) && packet
                .getFrom().equals(packet.getTo()))) {
            if (log.isLoggable(Level.FINEST)) {
                log.log(Level.FINEST, "Possible infinite loop, dropping packet: {0}", packet);
            }

            return;
        }

for example consider a packet is going from one user to another. in the first phase it will be processed by a plugin with source address session (by plugins), then if it is forwarded, it will be processed by destination address session (by plugins), in this phase, packet.to and packet.from are equal to sess-man. if in this phase we want to result back an error, the error recognized as infinite loop and droped, that is not proper.

I think u should remove this code, or at least setting packetTo to null in "packet.errorResult()".


Replies (4)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam almost 4 years ago

Thank you for in-depth code analysis. Could you please confirm empirically with some tests that your analysis conclusion is correct? I am asking because, normally when the plugin returns an error, it should set packetTo to the connection ID, not the SM id.

Added by Behnam Hatami almost 4 years ago

I just create result with "Authorization.FEATURE_NOT_IMPLEMENTED.getResponseMessage" (for example), I'm on vacation right now, I will attach a sample plugin that this case accure and I try to write test for this. (I already write the sample test plugin that I believe this situation accure but I haven't a working tigase machine right now and I'll complete it after vacation)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam almost 4 years ago

I understand now. However, in such a case my position on this is that this is the plugin code bug not MessageRouter. If the plugin sets incorrect fields in the packet (from and to in this case) then we cannot guarantee correct processing and/or delivery. I think that no matter what we do in MR, we can always write a plugin generating packets which fall in an infinite loop inside Tigase. And this is actually an easy thing to do.

Added by Behnam Hatami almost 4 years ago

I know it can be packet creator bug, but I think when I use helper methods from Tigase, it can be more intelligent(for example by getting session as argument) and handles this situation.

Thanks for your reply

    (1-4/4)