The vulnerability is a Redis connection leak in NiceGUI, allowing an unauthenticated attacker to cause a denial of service by exhausting Redis connections. The root cause lies in the client disconnection logic. When a browser tab is closed, the nicegui.client.Client.handle_disconnect function is triggered. In vulnerable versions, this function prematurely nullifies the tab_id before the resource cleanup process can use it. Each tab using Redis storage has an associated RedisPersistentDict object, created via its __init__ method, which establishes connections to Redis. The cleanup process is supposed to call the RedisPersistentDict.close method to release these connections. However, because the tab_id is already gone, the system cannot find the correct RedisPersistentDict object to close. Consequently, the connections are never released. The patch addresses this by saving the tab_id before it's cleared and ensuring the close method on the corresponding storage object is called. The patch also includes a more robust implementation of RedisPersistentDict.close to ensure the background connection tasks are properly terminated.
Client.handle_disconnectnicegui/client.py
RedisPersistentDict.__init__nicegui/persistence/redis_persistent_dict.py
RedisPersistentDict.closenicegui/persistence/redis_persistent_dict.py
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| nicegui | pip | >= 2.10.0, <= 3.4.1 | 3.5.0 |