- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 623
 
Description
Describe the bug
This issue is manifesting itself through flask-socketio, but I believe the source of the issue belongs here. When a client connects using a namespace that is not declared, the namespace is simply added and the client connects with no ability to execute code against the connection in order to reject it.
The end result is that it is possible to pollute the connection pool with phantom clients, and the server cannot detect when new clients connect.
The source of issue I believe is here:
python-socketio/src/socketio/base_manager.py
Line 119 in 3bd1357
| if namespace not in self.rooms: | 
To Reproduce
- Stand up a bare bones server instance.
 - Define an on_connect handler for '/'
 - Define zero or more class based namespaces and register them
 - Connect a client using a namespace that the server is not aware of.
 - Client connection is blindly accepted, regardless of 
always_connectvalue. 
Expected behavior
One of:
- Connections to namespaces that do not exist are flat out rejected; or
 - Connections to namespaces that do not exist produce an exception; or
 - Connect event is delegated to to 
/namespaceconnect, with relevant details on the namespace attempted to connect to. 
In all cases, it is also expected that the / namespace connect event fires, which is also not occurring.
Logs
(58685) wsgi starting up on http://0.0.0.0:5000
(58685) accepted ('127.0.0.1', 50507)
1_szfyPlEneUJwA3AAAA: Sending packet OPEN data {'sid': '1_szfyPlEneUJwA3AAAA', 'upgrades': [], 'pingTimeout': 20000, 'pingInterval': 25000}
kombu backend initialized.
1_szfyPlEneUJwA3AAAA: Received request to upgrade to websocket
1_szfyPlEneUJwA3AAAA: Upgrade to websocket successful
1_szfyPlEneUJwA3AAAA: Received packet MESSAGE data 0/celery,{"authToken":"bGVlQHRvcnVzb2Z0LmNvbTo2MUE1MUI1NTrMnz4SGR56ssXsYgxiiGHGa5ck6g"}
/celery
1_szfyPlEneUJwA3AAAA: Sending packet MESSAGE data 0/celery,{"sid":"hOsZtTCikRL7RTIfAAAB"}
(58685) accepted ('192.168.0.60', 50513)
DTnpUXYe8iuRM0UdAAAC: Sending packet OPEN data {'sid': 'DTnpUXYe8iuRM0UdAAAC', 'upgrades': [], 'pingTimeout': 20000, 'pingInterval': 25000}
DTnpUXYe8iuRM0UdAAAC: Received request to upgrade to websocket
DTnpUXYe8iuRM0UdAAAC: Upgrade to websocket successful
DTnpUXYe8iuRM0UdAAAC: Received packet MESSAGE data 0/remote,{"authToken":"bGVlQHRvcnVzb2Z0LmNvbTo2MUE1MUI1NTrMnz4SGR56ssXsYgxiiGHGa5ck6g","userCtx":{"name":"[email protected]","roles":["confide-analytics","emmit-admin","confide-admin"]}}
/remote
DTnpUXYe8iuRM0UdAAAC: Sending packet MESSAGE data 0/remote,{"sid":"DhB9khVI587ck8pjAAAD"}
(58685) accepted ('192.168.0.60', 50558)
Additional context
If this is not intended behaviour, a possible easy solution is to add an else to to the if else if block of Server._trigger_event
If more detail is required, please let me know!