From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 8CemMj6VLWTukAAASxT56A (envelope-from ) for ; Wed, 05 Apr 2023 17:35:26 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id oCxbMj6VLWQmWwEAauVa8A (envelope-from ) for ; Wed, 05 Apr 2023 17:35:26 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 82205B28A for ; Wed, 5 Apr 2023 17:35:26 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pk5A9-00049n-1L; Wed, 05 Apr 2023 11:35:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pk5A7-00049e-Az for guix-patches@gnu.org; Wed, 05 Apr 2023 11:35:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pk5A7-0007m3-2I for guix-patches@gnu.org; Wed, 05 Apr 2023 11:35:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pk5A6-0007JL-Cv for guix-patches@gnu.org; Wed, 05 Apr 2023 11:35:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62678] [PATCH] services: nginx: Harden php-location settings. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 05 Apr 2023 15:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 62678 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62678@debbugs.gnu.org Cc: Bruno Victal X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.168070889428084 (code B ref -1); Wed, 05 Apr 2023 15:35:02 +0000 Received: (at submit) by debbugs.gnu.org; 5 Apr 2023 15:34:54 +0000 Received: from localhost ([127.0.0.1]:52459 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pk59j-0007Ia-IW for submit@debbugs.gnu.org; Wed, 05 Apr 2023 11:34:54 -0400 Received: from lists.gnu.org ([209.51.188.17]:49246) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pk59h-0007IT-On for submit@debbugs.gnu.org; Wed, 05 Apr 2023 11:34:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pk59h-00043G-7M for guix-patches@gnu.org; Wed, 05 Apr 2023 11:34:37 -0400 Received: from smtpmciv1.myservices.hosting ([185.26.107.237]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pk59f-0007ft-5U for guix-patches@gnu.org; Wed, 05 Apr 2023 11:34:36 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpmciv1.myservices.hosting (Postfix) with ESMTP id E7E4F2098E for ; Wed, 5 Apr 2023 17:34:25 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 9431E800AA; Wed, 5 Apr 2023 17:34:25 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 7AgZigszt7Uo; Wed, 5 Apr 2023 17:34:25 +0200 (CEST) Received: from guix-nuc.home.arpa (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id EA9A2800A9; Wed, 5 Apr 2023 17:34:24 +0200 (CEST) From: Bruno Victal Date: Wed, 5 Apr 2023 16:34:08 +0100 Message-Id: X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=185.26.107.237; envelope-from=mirai@makinata.eu; helo=smtpmciv1.myservices.hosting X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680708926; a=rsa-sha256; cv=none; b=DfxyNYUqMLTPJDYhp6pBxOjA7QGO3qjtH1rY3B6C/sNILqVf/LQivghMBIKLl4EcubONZh VnEwQDqLcB7O2YNZBZ4YilEwF8Ace/g28pnanY0oLfAMuoMvJTm5BlghCGUSiYr5IG/iuR PeCb5F9yt2JKRXgtMpKEJLmk6lTWa+przLUKW03dt392qu2J2OO7UNLNMl5ABm1jNeo3RZ 3GWYlDKs9LOxMnuk9/lJHLYWZYx/Zb0kDAfsT38ycszU1650i5LbM7nePw3MSO/35jh88k vBBjE+zN75YIFXxldaHqqvwnb1PIwoZQ3wtYLZbbkitnvtptplHI3ukdIms7/A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1680708926; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BNx5sBUPr7It8LDQak/IS8boNUt+WomTzxAGQTV+svA=; b=cZPuAEIfx6dEGMwAeMk4pGDcifCOmYL73kPOntD8zFtSB7tp3ynh91K0J7WL+Z51qaTmTP jeg/uve39bd9p0RIF4NzQVUoNRxYtA+lPsUVUmA7KwrkUHtfuuxhwYcFLmw5Y7HqYjDHNQ nqEYqEzgjhSRa+bbj5JJX7IX2+vuUZr6ESq458RhGhx1RL8mP3V/SRhnKC62o8gwMhAxce 4bSlBN4TcrwBWDtfMYjgIFZVZUYU8ChEVkpKKIUe8dXN27GYyMvgL3OrWt3+w7lHE7Nlqf UxFy+nIyzV08KvvHNzzcV5qdlXjzwM0V6YBm7+c1ygYTVdxPcY/ZJUom+xL+nA== X-Migadu-Spam-Score: -1.92 X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Spam-Score: -1.92 X-Migadu-Queue-Id: 82205B28A X-TUID: RoyUn6KX34NP Incorporate advice from [2], which mitigates httpoxy[1] vulnerability and disallows passing non-php files to the PHP backend. [1]: [2]: , note 4. * gnu/services/web.scm (nginx-php-location): Only pass existing php files to backend. Mitigate httpoxy vulnerability. --- Tested with: make check-system TESTS="nginx php-fpm" gnu/services/web.scm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gnu/services/web.scm b/gnu/services/web.scm index d56e893527..f5ed027bb4 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -1123,6 +1123,10 @@ (define* (nginx-php-location (uri "~ \\.php$") (body (list "fastcgi_split_path_info ^(.+\\.php)(/.+)$;" + ;; Mitigate https://httpoxy.org/ vulnerabilities + "fastcgi_param HTTP_PROXY \"\";" + ;; Only pass existing php files to the backend. + "if (!-f $document_root$fastcgi_script_name) { return 404; }" (string-append "fastcgi_pass unix:" socket ";") "fastcgi_index index.php;" (list "include " nginx-package "/share/nginx/conf/fastcgi.conf;"))))) base-commit: 6311493d7a6271bfbc51f4693857f9a12fe9965d -- 2.39.2