[Git][security-tracker-team/security-tracker][master] 2 commits: web_support.py: harden against persistent DoS

Emilio Pozuelo Monfort (@pochu) pochu at debian.org
Tue Nov 24 09:59:52 GMT 2026



Emilio Pozuelo Monfort pushed to branch master at Debian Security Tracker / security-tracker


Commits:
5581b07c by Helmut Grohne at 2026-11-23T20:31:30+01:00
web_support.py: harden against persistent DoS

Consider a database access taking long. This can happen for a variety of
reasons. The database may be locked (in WAL mode, closing can take an
exclusive lock) or slow or request processing may be slow. When any of
this happens, other connections are stuck waiting for the Python lock.
By the time the lock is released, many clients may be gone but Python is
still processing their requests and then notices that it cannot write
the response. This can result in a situation where all requests
permanently time out. Newly arriving requests are queued so long that
the Python has no chance of catching up before the client disconnects.

We can mitigate this somewhat by actively failing connections. If we
cannot get a database lock within 30 seconds, chances are high that the
client will be gone by the time we deliver a response. On the flip side,
this also means that we don't get to generate the response in the first
place, so other connections can actually receive a reply in time. The
timeout turns the DoS condition recoverable. Once the flood of requests
stops, a few more will receive 503 and then things turn back to normal.

- - - - -
55ebd1e7 by Emilio Pozuelo Monfort at 2026-11-24T09:59:47+00:00
Merge branch 'helmutg/harden-dos' into 'master'

web_support.py: harden against persistent DoS

See merge request security-tracker-team/security-tracker!351
- - - - -


1 changed file:

- lib/python/web_support.py


Changes:

=====================================
lib/python/web_support.py
=====================================
@@ -676,11 +676,20 @@ class WebServiceHTTPAdapter:
                                  path, params,
                                  secure=adapter_self.secure)
 
-                with adapter_self.lock:
-                    r = method(remaining, params, url)
-                    assert isinstance(r, Result), repr(r)
-                    result = r.flatten_later()
-                result(self)
+                if adapter_self.lock.acquire(timeout=30):
+                    try:
+                        r = method(remaining, params, url)
+                        assert isinstance(r, Result), repr(r)
+                        result = r.flatten_later()
+                    finally:
+                        adapter_self.lock.release()
+                    result(self)
+                else:
+                    # If the database is blocked, fail fast to avoid piling up
+                    # requests and answering them after the other side has gone
+                    # away.
+                    self.send_response(503)
+                    self.end_headers()
             do_HEAD = do_GET
 
             def __parse_path(self) -> tuple[str, Params]:



View it on GitLab: https://salsa.debian.org/security-tracker-team/security-tracker/-/compare/02a5a6fff43b200fcd313b6294a7c4088fb2d07f...55ebd1e7a39c5f4250cc9fba1d228472d3442516

-- 
View it on GitLab: https://salsa.debian.org/security-tracker-team/security-tracker/-/compare/02a5a6fff43b200fcd313b6294a7c4088fb2d07f...55ebd1e7a39c5f4250cc9fba1d228472d3442516
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-security-tracker-commits/attachments/20261124/374ea3f5/attachment-0001.htm>


More information about the debian-security-tracker-commits mailing list