Subject: | Possible security bug in POE |
Date: | Tue, 2 May 2006 22:15:54 +0200 |
To: | bug-poe [...] rt.cpan.org |
From: | dazjorz <sjorsgielen [...] gmail.com> |
(The test case is also downloadable from http://www.dazjorz.com/testcase.tar.gz)
Hi,
I think I've found a security bug in POE. The attached file contains
two scripts, main.pl and functions.pl. I've stripped out everything
that's not needed and made a simple test case.
The program first makes a SocketFactory, and in the Accepted event it
makes a Wheel::ReadWrite. The incoming data subroutine then calls a
'cmd_quit' subroutine which is supposed to leave a message and close
the socket.
Because Wheel::ReadWrite has no flush method, and otherwise the
"bye-bye" message wouldn't ever reach the user, the cmd_quit sub sets
a kill_after_flush in the HEAP (as described in
http://poe.perl.org/?POE_Cookbook/Graceful_Wheel_Shutdown). Then in
the flushed event, if this variable is set, it closes the socket.
After that, it's _supposed_ to destroy the session, and the HEAP with
it, and also the kill_after_flush variable.
The first time I connect to the server, this completely works. When I
type anything, it says 'Bye-bye!' and closes the socket.
But the second time I connect, it gives the welcome message and then
closes directly after that. After I added a print statement to the
flushed event, I saw that the kill_after_flush variable is still set.
Log of the telnets:
server:~/testcase# telnet localhost 24680
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
001 (Here comes a message, it's removed in this test case)
exit
007 Bye-bye!
Connection closed by foreign host.
server:~/testcase# telnet localhost 24680
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
001 (Here comes a message, it's removed in this test case)
Connection closed by foreign host.
server:~/testcase# telnet localhost 24680
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
001 (Here comes a message, it's removed in this test case)
Connection closed by foreign host.
Underwhile, the server runs in another window:
server:~/testcase# perl main.pl
Running.
Shutdown bit set, closing connection.
Shutdown bit set, closing connection.
Shutdown bit set, closing connection.
I'm not sure if this is really a bug in POE, or that I've just done
something wrong in my program.
DaZjorz
Message body not shown because it is not plain text.