From nobody Fri Jun 05 18:26:39 2026 X-Original-To: ports-bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gX8z34Xv1z6gHtx for ; Fri, 05 Jun 2026 18:26:39 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gX8z32Yn0z4LQw for ; Fri, 05 Jun 2026 18:26:39 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780683999; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MpIsa3PbDneCX+IJAW9tHGlXRehZ9El8v3D0P+i2lcs=; b=pIRRFsmmlAIcwKMpkbzfxzez19curSKPBzoJ+Ef0yzKGnt35xB/xbETZBz9XvTKZH61fmg EbpqaR0xN2zDg0pxXH/l98GYqhpZmVSBWw97glmJLs4Kl634T0eYJeb9UxK0viDO1GYTt9 Q9PoNUJ1dc2Bb102CROw5GiOST9yxrlq9xDbkLyP062HhexG7V+sfrBKa0XDimIxPB0An0 QPDCp0fF1hx8rLmujvcyfV61iRx/RkDxYH8a/HRr/sPjZ3QvFJ6+WfqjYo7aZBQxDFWOTx sb50OfUjp6zWV8+BuXnysgzMwwwy6lPjOMnwtlPEh8DrFB7G3uVNrdO8fWRb6Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780683999; a=rsa-sha256; cv=none; b=UERRuEIHfFxG+T/AoCBObcHwpqBmQG5UFaUtDIPeO4Y/KXUNHf9Pce8NLXNfEgqx1FXLqP Ri9QfuvMrykx3OiEKMPMokZNKQufFqLbDXvLMvmJJI8oD2jo0oNf7JSJg17oSr+qH8CXO3 e3XN2+YEQWx0+DyxfADjqTRqHll97yd76Kl8NpvrRhFHNIocdQentEnU84FiLUpALeoaR3 gWt4Jy9TzjVuXcwjHlF94gvxoviqWDUPpBODqXo6ChPW06kuy6vkxrq2I5CKQVI73Jw7vZ qc46nt/wgddnwhYh/4CVX4YB3PRW6x+oGfk7hUj/PpJ3gzII7lqzW8ljzwwfpw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780683999; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MpIsa3PbDneCX+IJAW9tHGlXRehZ9El8v3D0P+i2lcs=; b=ONRDEFk9yPN8Gvca/lJBXHyLFL+aq4v7nrNoLlojPvoK98CM4lCi52qBu/KInNaqvBHR4O Wp6qiuCgJ9cwny4Uy11MdsK/oFmKglLig8yB36oUELRuUQ2coXVpN6KbYw8b7TJGUlx3iV YExZ8RFIQqlXzkCRHRTnhXi48+v8D3yQUVfkipMpvdGT/mclqNSrVZ64sZEN5wrlynYH97 CbjnjV8ksIJucMEKqnkrIrlpb8PPXN1wkBzLXg/k0/FWTmpC/4zXQcxtOHxH7vRGT8PDh3 27/fVIhjwalvex0aIMKPYtWH7SfaD9FuTLzhTCb6YrOU7XgMtn5fQ2590QnTig== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4gX8z31Wcgzhkq for ; Fri, 05 Jun 2026 18:26:39 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 655IQcgV099207 for ; Fri, 5 Jun 2026 18:26:38 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 655IQcoO099206 for ports-bugs@FreeBSD.org; Fri, 5 Jun 2026 18:26:38 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: ports-bugs@FreeBSD.org Subject: [Bug 295882] www/seahub: seafdav does not log real client IP address Date: Fri, 05 Jun 2026 18:26:39 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Ports & Packages X-Bugzilla-Component: Individual Port(s) X-Bugzilla-Version: Latest X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: lloydsystems1@tpg.com.au X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: ports-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Ports bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-ports-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: freebsd-ports-bugs@freebsd.org Sender: owner-freebsd-ports-bugs@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D295882 Bug ID: 295882 Summary: www/seahub: seafdav does not log real client IP address Product: Ports & Packages Version: Latest Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: Individual Port(s) Assignee: ports-bugs@FreeBSD.org Reporter: lloydsystems1@tpg.com.au Seafile server version 11.0.12 running on FreeBSD 14 with WebDAV extension enabled. The seafdav.log file records all client requests as coming from 127.0.0.1 (= the Apache reverse proxy) rather than the real client IP address. Given that Seafile will be running behind an Apache or Nginx proxy 99% of the time, I can=E2=80=99t imagine any case where this would be at all useful. I have this in the Apache virtual host: ProxyPass http://127.0.0.1:8081/seafdav RequestHeader set X-Forwarded-Proto "https" RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s Expected behaviour is to look for and log the X-Forwarded-For header, but it does not. The Seafile manual recommends using Fail2Ban to protect the server. This sh= ould logically apply to the SeafDAV service also, but it needs the remote IP address. By searching the code I found the routine responsible for logging the client requests is /usr/local/www/haiwen/seafile-server/seahub/thirdpart/wsgidav/wsgidav_app.py and patched it to add xff as shown below. class WsgiDAVApp: ... def __call__(self, environ, start_response): # util.log(=E2=80=9CSCRIPT_NAME=3D{!r}, PATH_INFO=3D{!r}=E2=80=9D.forma= t( # environ.get(=E2=80=9CSCRIPT_NAME=E2=80=9D), environ.get(=E2=80=9CP= ATH_INFO=E2=80=9D))) path =3D environ["PATH_INFO"] # --- Added --- xff =3D environ.get("HTTP_X_FORWARDED_FOR") if xff: environ["REMOTE_ADDR"] =3D xff.split(",")[0].strip() # --- End --- Now seafdav.log shows the real client IP address, but more needs to be done= to properly protect SeafDAV with Fail2Ban. Due to the default behaviour of WebDAV, valid clients will generate =E2=80= =9C401 Not Authorized=E2=80=9D errors in the log before they authenticate. When proces= sed by Fail2Ban, these false positives could block legitimate users. A more reliab= le indicator for Fail2Ban would be the =E2=80=9CAuthentication (basic) failed = for user=E2=80=9D messages, but these do not include the IP address. The file /usr/local/www/haiwen/seafile-server/seahub/thirdpart/wsgidav/http_authenti= cator.py is responsible for logging authentication failures. The code was patched to read REMOTE_ADDR and append it to the log entries. class HTTPAuthenticator(BaseMiddleware): ... def handle_basic_auth_request(self, environ, start_response): realm =3D self.domain_controller.get_domain_realm(environ["PATH_INF= O"], environ) auth_header =3D environ["HTTP_AUTHORIZATION"] auth_value =3D "" try: auth_value =3D auth_header[len("Basic ") :].strip() except Exception: auth_value =3D "" auth_value =3D base64.decodebytes(util.to_bytes(auth_value)) auth_value =3D util.to_str(auth_value) user_name, password =3D auth_value.split(":", 1) # --- Get client IP --- client_ip =3D environ.get("REMOTE_ADDR", "unknown") if self.domain_controller.basic_auth_user(realm, user_name, passwor= d, environ): environ["wsgidav.auth.realm"] =3D realm environ["wsgidav.auth.user_name"] =3D user_name return self.next_app(environ, start_response) # --- Append client IP --- _logger.warning( "Authentication (basic) failed for user {!r}, realm {!r}, IP {!r}.".format( user_name, realm, client_ip The seafdav.log can now be parsed with a Fail2Ban filter like this: [Definition] failregex =3D ^.*WARNING\s+:\s+Authentication \([^)]*\) failed for user '[^= ']*', realm '[^']*', IP ''\.$ ignoreregex =3D=20 I think the SeafDAV code should be fixed to make the logging useful and workable for Fail2Ban, as it is recommended by Seafile. --=20 You are receiving this mail because: You are the assignee for the bug.=