Re: [jose] JWS signature verification and claims payload

Orie Steele <orie@transmute.industries> Thu, 12 October 2023 20:14 UTC

Return-Path: <orie@transmute.industries>
X-Original-To: jose@ietfa.amsl.com
Delivered-To: jose@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id AA031C151089 for <jose@ietfa.amsl.com>; Thu, 12 Oct 2023 13:14:25 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.086
X-Spam-Level:
X-Spam-Status: No, score=-2.086 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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_KAM_HTML_FONT_INVALID=0.01, T_REMOTE_IMAGE=0.01, T_SCC_BODY_TEXT_LINE=-0.01, 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 (2048-bit key) header.d=transmute.industries
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 shnLcDOuy91Q for <jose@ietfa.amsl.com>; Thu, 12 Oct 2023 13:14:22 -0700 (PDT)
Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 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 1475AC14CE4B for <jose@ietf.org>; Thu, 12 Oct 2023 13:14:22 -0700 (PDT)
Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-51e28cac164so5257809a12.1 for <jose@ietf.org>; Thu, 12 Oct 2023 13:14:21 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=transmute.industries; s=google; t=1697141660; x=1697746460; darn=ietf.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=njm7io7wSu2XJNTinLn3AP9yVuzIBWvJEoXeICVfbZ4=; b=XBtd2iV2GUkyIXH1KppE8lmrc3i3p24BQpW+dRZtneCEyz89n/6OK4gxnBz6UivDm2 Y/9lfF/1L6bpEiRDZx5sDSso163WJwyDFNCnwHxlvOOU/IARfjxnR1iQTfROyzzjf3TK 93wdEa6QpNbwyT+IqEAbRS2yCXiaZXKSLd40Kpwv9Es65lz0i60Vo6qKEc7bJKddGNzo b/gx61AUH/ma31KtF/PliLVKWJnOpLU6Ie7H6R+ctnhzbmbf4NsNnlX+A26+eVI3fXJ4 XmeiJh528Mqm73me/UxtlW7mrbsm0HzEL2Si68z03TdKVyqHzCJw1xLgIGWtGEDwXqDA Fvhg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697141660; x=1697746460; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=njm7io7wSu2XJNTinLn3AP9yVuzIBWvJEoXeICVfbZ4=; b=UIaGlWUpfcxYSUt18ksixu+gZeX+cu8I5GBVm3CjVoo7fl1o1omP/OU8USgpANggzj nEjYF6Y7tuRi6Grzpw9YQh2dtAWD2/07a9jjk9qeHvR19Tu3SOdCLgITeLV99K+mxZsk gjhm4OrfQoPnp2TRQNzYIXO2oQCDgmbtV1MqU/Hzj7phUEwjEY2CuVNuKi+h7Tcp85Ut BH8P8kVtsctSfv57t15zizgKy8iAnecz84Zsjb8rqvShSF1upKEyXuAwLYDLnYMVEhpE jny7NnsIhLLDJxbRZE8q4meyGWnOPhCH1w/OByFKQiA0rUuh0LFPmHWzv3olkcb0CFj5 bXrg==
X-Gm-Message-State: AOJu0YzyPpj1gZ8BIyAS4mUN6tyPfk4s2XeOORBELaOcuL1UrQyDGAoq 9DMchPbESnBUuZNmx17+8X7wJ0IWgp0aqi6PC0Yfag==
X-Google-Smtp-Source: AGHT+IE7MwbRid9CnLOEErpZo2SDZzUJ3T7hQW3zgOeCGJ/Lc8IwjFUbFiWVirzEVsDulNen3xsz0g/uQaAuguDkT4k=
X-Received: by 2002:a17:906:da82:b0:9ae:5f52:a491 with SMTP id xh2-20020a170906da8200b009ae5f52a491mr18314488ejb.8.1697141659812; Thu, 12 Oct 2023 13:14:19 -0700 (PDT)
MIME-Version: 1.0
References: <CACVbtYO28BkxPXoXKUojjV_XFGQOEV7EDs=d1TZ9ymcBhFicUQ@mail.gmail.com> <CAN8C-_L68Pay8nVjSxbjGo_q3kyggp1P-5_iruOaFPCsy5dw0Q@mail.gmail.com> <CACVbtYO+xOiXiYaZZ-+kspSAmxLHw0UKohmG-GksLT5Kcjsw=A@mail.gmail.com>
In-Reply-To: <CACVbtYO+xOiXiYaZZ-+kspSAmxLHw0UKohmG-GksLT5Kcjsw=A@mail.gmail.com>
From: Orie Steele <orie@transmute.industries>
Date: Thu, 12 Oct 2023 15:14:08 -0500
Message-ID: <CAN8C-_Jz5o9OO19eb2WG3iJfNcFKm2mN1eeD--Qy0bi3Y=nmxA@mail.gmail.com>
To: Les Hazlewood <lhazlewood@gmail.com>
Cc: jose@ietf.org
Content-Type: multipart/alternative; boundary="000000000000c4597406078a953b"
Archived-At: <https://mailarchive.ietf.org/arch/msg/jose/3w_qDvUNSDGKmofzIG1-0gndMGM>
Subject: Re: [jose] JWS signature verification and claims payload
X-BeenThere: jose@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: Javascript Object Signing and Encryption <jose.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/jose>, <mailto:jose-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/jose/>
List-Post: <mailto:jose@ietf.org>
List-Help: <mailto:jose-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/jose>, <mailto:jose-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 12 Oct 2023 20:14:25 -0000

On Thu, Oct 12, 2023 at 2:40 PM Les Hazlewood <lhazlewood@gmail.com> wrote:

> Thanks for the reply Orie.  I'm the primary author of JJWT:
> https://github.com/jwtk/jjwt, so my question is grounded in
> general-purpose library support and not protocol design/support.
>
> If you are building a library that has to support all / older protocols...
>> I recommend taking an approach that clearly distinguishes decoding from
>> verifying.
>>
>
> I (very respectfully) disagree.  Even just parsing untrusted payloads
> before cryptographic verification - before a library even has a chance to
> evaluate name/value pairs of a fully constructed JSON Object - can expose
> an application to security vulnerabilities.  Otherwise, yes, I'd agree that
> once JSON is (safely) converted to Object instances, verification and
> validation are separate concerns.
>

Yep, I agree with you but see my comments on "alg none" below.

I'd be cautious to avoid exposing an interface that looked like:
verify(jwt, publicKey)...
but where the public key was ignored when the JWT had "alg none"...
as this could result in exactly the type of security issues you are rightly
concerned about.

Make the developer choose to support "alg none" explicitly, for example:

https://github.com/panva/jose/blob/b27d69539b4a0bebb74964d3f729f6607c5bd2b1/src/types.d.ts#L492


>
> My question for the JOSE committee is whether payload parsing is even
> allowed before signature verification.
>

https://datatracker.ietf.org/doc/html/rfc7519#section-6

^ I think this answers your first question.

And if it is, are there explicitly documented caveats? (e.g. with RFC 2119
> Notational Convention terminology, SHOULD, SHOULD NOT, etc)?
>
>
I think this answers your second question:

https://datatracker.ietf.org/doc/html/rfc7519#section-7.2


> Or is it more "it's not explicitly prevented, and you should avoid it if
> possible, but feel free to support it if you want" ?
>
>
My understanding is that it's (unfortunately) encouraged (by the use of MAY
in section-6), and that it's also been a problem, see also search results
for "alg none".

Thanks again!
>
> Les
>


-- 


ORIE STEELE
Chief Technology Officer
www.transmute.industries

<https://transmute.industries>