Re: [netmod] Strictness of Base64classic in RFC 7950/7951

Ladislav Lhotka <ladislav.lhotka@nic.cz> Mon, 27 February 2023 14:04 UTC

Return-Path: <ladislav.lhotka@nic.cz>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id B5DFFC151B02 for <netmod@ietfa.amsl.com>; Mon, 27 Feb 2023 06:04:28 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.097
X-Spam-Level:
X-Spam-Status: No, score=-2.097 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=nic.cz
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I7Wu9Cbnrj9i for <netmod@ietfa.amsl.com>; Mon, 27 Feb 2023 06:04:24 -0800 (PST)
Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 4E999C1526FB for <netmod@ietf.org>; Mon, 27 Feb 2023 06:04:23 -0800 (PST)
Received: from [IPV6:2001:1488:fffe:6:a8c6:1fff:fec3:5de1] (unknown [IPv6:2001:1488:fffe:6:a8c6:1fff:fec3:5de1]) by mail.nic.cz (Postfix) with ESMTPSA id CCC3F1C183B; Mon, 27 Feb 2023 15:04:19 +0100 (CET)
Authentication-Results: mail.nic.cz; auth=pass smtp.auth=ladislav.lhotka@nic.cz smtp.mailfrom=ladislav.lhotka@nic.cz
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1677506659; bh=RE4MjC04Bsz4Sug6T8IjRD/VCXuUgI+7v8KzMc+Df68=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Reply-To: Subject:To:Cc; b=ZkHesSmIKrkBWd3IZ739jS7/pKlaahf24dFdpqwfA1uFjzjatggS3OfgdzgSGOZaj KNDZ8aJABroZYX89m+NcdjRT1EDjcE2v24wq/wMZfpP1NM8bQGDjalsOlfKHVTN2SJ qfska8EyxGLnjlEwHdXVmRyqdcZ8YuktCgEmPKJo=
Message-ID: <6a0ac8c0-e0c9-32bc-cdd6-09ef57b8193b@nic.cz>
Date: Mon, 27 Feb 2023 15:04:19 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0
Content-Language: en-US
To: Carsten Bormann <cabo@tzi.org>
Cc: netmod@ietf.org
References: <C4CA45AE-4294-48FF-9210-16783A4B6FEC@tzi.org> <877cw3jp7w.fsf@nic.cz> <0DC09E3A-D200-4C25-BBF9-4CA43FBA2DFD@tzi.org>
From: Ladislav Lhotka <ladislav.lhotka@nic.cz>
In-Reply-To: <0DC09E3A-D200-4C25-BBF9-4CA43FBA2DFD@tzi.org>
Content-Type: text/plain; charset="UTF-8"; format="flowed"
Content-Transfer-Encoding: 8bit
X-Virus-Scanned: clamav-milter 0.103.7 at mail
X-Virus-Status: Clean
X-Spamd-Result: default: False [-0.10 / 20.00]; MIME_GOOD(-0.10)[text/plain]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; WHITELISTED_IP(0.00)[2001:1488:fffe:6:a8c6:1fff:fec3:5de1]; FROM_HAS_DN(0.00)[]; ASN(0.00)[asn:25192, ipnet:2001:1488::/32, country:CZ]
X-Rspamd-Pre-Result: action=no action; module=multimap; Matched map: WHITELISTED_IP
X-Rspamd-Action: no action
X-Spamd-Bar: /
X-Rspamd-Server: mail
X-Rspamd-Queue-Id: CCC3F1C183B
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/r0DHFcPIIWOc6XE3180Pjjt8yjU>
Subject: Re: [netmod] Strictness of Base64classic in RFC 7950/7951
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 27 Feb 2023 14:04:28 -0000

Dne 27. 02. 23 v 14:31 Carsten Bormann napsal(a):
> 
> On 2023-02-27, at 12:57, Ladislav Lhotka <ladislav.lhotka@nic.cz> wrote:
>>
>>> I this YANG-JSON valid for a `binary`?
>>>
>>> "base64encodedvalue==“
>>
>> Strictly speaking it isn't because it's out of range of the base64 encoding function.
> 
> Right.
> 
>> I think though it is OK to be liberal in what we accept here because "base64encodedvaluQ==" is clearly the canonical value in this case, so there is no ambiguity e.g. regarding string equality.
> 
> Well, this is the essence of my question (not sure about the part about string equality, though).
> 
> draft-iab-protocol-maintenance [0] takes the position that the Postel principle, while historically a good way to implement protocols and get interoperability going, is not to be misunderstood as a mandate for the evolution of protocol ecosystems — protocols are free to be strict, lest they turn into soup (“Protocol Decay” [1]: “...a chain reaction that can create interoperability problems over time”).

Section 9.1 in RFC 7950: "values in the data tree are conceptually 
stored in the canonical representation", and also "XPath expression 
evaluations are done using the canonical form". If implementations obey 
these rules, and since the canonical form for the binary type is 
unambiguous, I don't see much potential for interoperability problems. 
In essence, it's like representing number 17 as +17.

> 
> I’d like to know whether, on issues like this, YANG is more on the strict side or on the soup side — what do YANG implementations actually do, and what do we want YANG implementations to do?  Is there an implicit “MAY send invalid last character”, which is no different from a “MUST accept invalid last character”?

Unlike non-alphabet characters, RFC 4648 doesn't say that such a 
character in encoded data is invalid.

FWIW, my implementation (Yangson) uses Python standard library base64 
that accepts it without complaints even with validation turned on:

 >>> import base64
 >>> base64.b64decode("ue==", validate=True)
b'\xb9'

So I assume the authors consider this input valid, and I saw no reason 
to be concerned about it.

Lada

> 
> Background: I’m proposing to add a few control operators to CDDL, including for handling base64classic [2], and in my PoC implementation was of course implementing a strict interpretation, only to be struck by the first example in an RFC I was pointed to.
> 
> Grüße, Carsten
> 
> [0]: https://www.ietf.org/archive/id/draft-bormann-cbor-cddl-more-control-00.html#name-byte-strings-base16-hex-bas
> [1]: https://www.ietf.org/archive/id/draft-iab-protocol-maintenance-12.html#name-harmful-consequences-of-tol
> 

-- 
Ladislav Lhotka, CZ.NIC
PGP Key ID: 0xB8F92B08A9F76C67