From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 15AC61FF0E3 for ; Tue, 04 Aug 2026 11:08:29 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id EF76D215C9; Tue, 04 Aug 2026 11:08:24 +0200 (CEST) From: Dietmar Maurer To: pve-devel@lists.proxmox.com Subject: [PATCH storage 3/7] iscsi: validate target names with a dedicated format Date: Tue, 4 Aug 2026 11:08:15 +0200 Message-ID: <20260804090819.2136483-4-dietmar@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260804090819.2136483-1-dietmar@proxmox.com> References: <20260804090819.2136483-1-dietmar@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 2 AWL -0.122 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: FPJUQQGXNLVI7KTGUBABODII47O2DMPJ X-Message-ID-Hash: FPJUQQGXNLVI7KTGUBABODII47O2DMPJ X-MailFrom: dietmar@zilli.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The target property accepted any string, so typos or pasted portal addresses were only caught later when iscsiadm fails. Validate against the iSCSI name grammar from RFC 7143 (iqn, eui and naa types, 223 byte limit). Accept uppercase letters even where the grammar only permits lowercase, because such admin-typed names exist in the wild and work, and rejecting them would break existing setups on upgrade. This also covers the iSCSI direct and ZFS over iSCSI plugins, which share the property. Signed-off-by: Dietmar Maurer --- src/PVE/Storage/ISCSIPlugin.pm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm index 9944806..0165a58 100644 --- a/src/PVE/Storage/ISCSIPlugin.pm +++ b/src/PVE/Storage/ISCSIPlugin.pm @@ -334,6 +334,27 @@ sub iscsi_device_list { # Configuration +# Name grammar from RFC 7143 section 6.1: iqn, eui and naa types with a +# 223 byte limit. The IQN grammar only permits lowercase, but accept any +# case because admin-typed names with uppercase letters exist and work. +sub verify_iscsi_target { + my ($target, $noerr) = @_; + + if ( + length($target) > 223 + || $target !~ m/^(?: + iqn\.\d{4}-\d{2}(?:\.[a-z0-9-]+)+(?::[a-z0-9.:-]+)? + |eui\.[0-9a-f]{16} + |naa\.(?:[0-9a-f]{16}|[0-9a-f]{32}) + )$/xi + ) { + return undef if $noerr; + die "value does not look like a valid iSCSI target name\n"; + } + return $target; +} +PVE::JSONSchema::register_format('pve-storage-iscsi-target', \&verify_iscsi_target); + sub type { return 'iscsi'; } @@ -351,6 +372,7 @@ sub properties { target => { description => "iSCSI target.", type => 'string', + format => 'pve-storage-iscsi-target', }, portal => { description => "iSCSI portal (IP or DNS name with optional port).", -- 2.47.3