[OAUTH-WG] Re: Security Bug | Unintended usage of "state" parameter can lead to Header Injection Attacks
Chaitanya Reddy <nchaitreddyutilities@gmail.com> Mon, 01 July 2024 13:31 UTC
Return-Path: <nchaitreddyutilities@gmail.com>
X-Original-To: oauth@ietfa.amsl.com
Delivered-To: oauth@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 72A11C15106E for <oauth@ietfa.amsl.com>; Mon, 1 Jul 2024 06:31:42 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.107
X-Spam-Level:
X-Spam-Status: No, score=-2.107 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, FREEMAIL_FROM=0.001, 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_SCC_BODY_TEXT_LINE=-0.01] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
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 ciX5H_vbEG5J for <oauth@ietfa.amsl.com>; Mon, 1 Jul 2024 06:31:41 -0700 (PDT)
Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) (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 AB6D6C14F6EC for <oauth@ietf.org>; Mon, 1 Jul 2024 06:31:41 -0700 (PDT)
Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-64f4c11d2c9so3545817b3.2 for <oauth@ietf.org>; Mon, 01 Jul 2024 06:31:41 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719840701; x=1720445501; 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=ln5j6NUeRgy0zc3GasiE5lQ8u9hkzkRfbW3djYCnGc4=; b=NQIt1a3YPClbSx2bS3K9I+g4hgpmF1QL87hUIzFb7CvIA+Wpk4bY3HsTD0aTViyszk /tWg6PSYPaZduVtrqTtBCm924AHLdSb73uzqV8aL3gdOcLNaepawIZ08puKRGEpR89i/ aZQKydWPGZN4fyTQphNU+N7mIaFvSO/jYWRB4u104fhUnTx0neEdOTmRFl1yzXAkc6lr KQpUS3sgRFwk86YV48E5LFswT+XqU1sJ8Gtj+RN9akFPOOYphbzd8hVk0Q7+WxQgwb18 HTtGb33ulLfw/sRoPXeFlZZdwkyjt5BxN4Qci9qOPB+i34bAVIm2h4PP6oVLWnclBCoY OsCQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719840701; x=1720445501; 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=ln5j6NUeRgy0zc3GasiE5lQ8u9hkzkRfbW3djYCnGc4=; b=QZ+e5+189vu67g7PTgo6QogG6IceN6d3HIRAM3u6A7AzoBoVql2Oz8uROS/7wm+MGy IuSVgVkLsXZpEewaWSDaV4dp+Fd6qTiGyeCjgoUG2a8IpwV023pUGex6Hqfh6FfXSWds c1VaCFVoTnzBny+edeo8VJG7u+KFvQZwMtxzKC/VrMWRu1Hry+ZDSWZ212Nm8+IN1ycv YIRaK5G/q8+llLSlfjp0G2uYaw9tbHiLaTBMNRhgd0925BUPmQdklbqxa4+OxoLnF3v0 UEUEZOog7348cKtE0yQqk+21V8zJ8ZIqZmOSZgg1ZJzfiIuJbMpgAd6XZ39DdVACAh+7 /Fdg==
X-Gm-Message-State: AOJu0YzQbGpWr3Ab9OTzIi0rjO3efSpBu9/iPvbWT21bcjFoJWE9dGsN 4t1wxZRI6OX369hJ5n4+vPLEEZnlrTOLV60ei+95GVadXnPltREcw0FaY35aAclWD7dDVUnAP9T 0g1BtP3o1nDh8zbHJ/CCsH+O8MhECtex2ojk=
X-Google-Smtp-Source: AGHT+IH7E/CJGb8YwXctdB68MMvZG+JPgpZN3bzbClj+kWyLdOmyJt5NR8I2k2E6YEhhK7edT+/V9o3e8SbR+U96zLo=
X-Received: by 2002:a81:9254:0:b0:627:d23a:44ff with SMTP id 00721157ae682-64e1ba95180mr33269417b3.3.1719840700477; Mon, 01 Jul 2024 06:31:40 -0700 (PDT)
MIME-Version: 1.0
References: <CAMsdJ+igzBuXf2HRhkLKQyRy7J2JqT9rTu0REe0nhcj0UNyXXg@mail.gmail.com> <1D426623-14DF-4609-87EB-ACD9F8A8D132@gmail.com> <CAMsdJ+iWONmd-+QP=oeL4+TRf-DVnxhBmbr8k1WttGJndwbGwg@mail.gmail.com>
In-Reply-To: <CAMsdJ+iWONmd-+QP=oeL4+TRf-DVnxhBmbr8k1WttGJndwbGwg@mail.gmail.com>
From: Chaitanya Reddy <nchaitreddyutilities@gmail.com>
Date: Mon, 01 Jul 2024 19:01:29 +0530
Message-ID: <CAMsdJ+jyX9uiGRQ2g8mNgJokEUuwtt0yVfbM8oWRkYhb2Fymqg@mail.gmail.com>
To: Neil Madden <neil.e.madden@gmail.com>
Content-Type: multipart/alternative; boundary="00000000000005b877061c2f9e4b"
Message-ID-Hash: JD7BTPZSYZ2IVGVIS2FSIVWQGKZBKTIL
X-Message-ID-Hash: JD7BTPZSYZ2IVGVIS2FSIVWQGKZBKTIL
X-MailFrom: nchaitreddyutilities@gmail.com
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-oauth.ietf.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
CC: oauth@ietf.org
X-Mailman-Version: 3.3.9rc4
Precedence: list
Subject: [OAUTH-WG] Re: Security Bug | Unintended usage of "state" parameter can lead to Header Injection Attacks
List-Id: OAUTH WG <oauth.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/oauth/HVpdGQPoD8XTDb_CyMWpKa8JK-s>
List-Archive: <https://mailarchive.ietf.org/arch/browse/oauth>
List-Help: <mailto:oauth-request@ietf.org?subject=help>
List-Owner: <mailto:oauth-owner@ietf.org>
List-Post: <mailto:oauth@ietf.org>
List-Subscribe: <mailto:oauth-join@ietf.org>
List-Unsubscribe: <mailto:oauth-leave@ietf.org>
Hi Neil and Filip, Thank you so much for the quick revert. Neil, in the last statement you mentioned "I would say in this case the onus falls on the client to validate the state value before blindly copying it into the Location header." since the state can contain anything in it. Yes, I do agree that the client should be the one validating the state. I already informed them of the same. But when i found that another client is vulnerable to open redirection due to this, I realised that instead of multiple clients validating the state value, wouldn't it be better if the Authorization server does this? One fix from google and all the vulnerable clients would already be free from this vulnerability. Filip, in terms of implementing it securely, since authorization server is the one explicitly mentioning it to use for redirection, shouldn't authorization server also have measures to sanitize the issue? My only point of asking this is i believe the authorization server should have also validated the state but they haven't. Regards, Chaitanya Reddy On Mon, Jul 1, 2024 at 6:33 PM Chaitanya Reddy < nchaitreddyutilities@gmail.com> wrote: > Hi Neil and Filip, > > Thank you so much for the quick revert. > > Neil, in the last statement you mentioned "I would say in this case the > onus falls on the client to validate the state value before blindly copying > it into the Location header." since the state can contain anything in it. > Yes, I do agree that the client should be the one validating the state. I > already informed them of the same. > But when i found that another client is vulnerable to open redirection due > to this, I realised that instead of multiple clients validating the state > value, wouldn't it be better if the Authorization server does this? One fix > from google and all the vulnerable clients would already be free from this > vulnerability. > > Filip, in terms of implementing it securely, since authorization server is > the one explicitly mentioning it to use for redirection, shouldn't > authorization server also have measures to sanitize the issue? > My only point of asking this is i believe the authorization server should > have also validated the state but they haven't. > > Regards, > Chaitanya Reddy > > On Mon, Jul 1, 2024 at 6:09 PM Neil Madden <neil.e.madden@gmail.com> > wrote: > >> Section 3.1.2.2 of RFC 6749 says: >> >> >> The authorization server SHOULD require the client to provide the >> complete redirection URI (*the client MAY use the "state" request >> parameter to achieve per-request customization*) >> >> >> So I’d say it is allowed to use the state parameter to hold a URI to >> redirect to after the flow completes. But note also the requirement in >> section 10.14: >> >> >> The authorization server and client MUST sanitize (and validate when >> possible) any value received -- in particular, the value of the >> "state" and "redirect_uri" parameters. >> >> >> Given that there is almost no restriction on what “state” can contain, I >> would say in this case the onus falls on the client to validate the state >> value before blindly copying it into the Location header. It sounds like >> those clients have an open redirect vulnerability and need to implement >> some kind of allow-list of acceptable URIs. >> >> — Neil >> >> On 1 Jul 2024, at 05:50, Chaitanya Reddy <nchaitreddyutilities@gmail.com> >> wrote: >> >> Hi Team, >> >> Hope you are doing well! >> >> I am writing this mail regarding the discussion of usage of *state* >> parameter in the OAuth implementation. >> >> As per the RFC 6749, "*An opaque value is used by the client to maintain >> state between the request and callback. And it should be used to prevent >> cross-site request forgery*". Since it's an opaque value, OAuth >> implementors usually don't sanitize the value. >> >> One of the OAuth 2.0 implementors (Google) have defined state as "*You >> can use this parameter for several purposes, such as directing the user to >> the correct resource in your application, sending nonces, and mitigating >> cross-site request forgery*" >> >> The issue arries here due to the fact that Google allows the use of state >> parameter for directing the users to the correct resource. Since the value >> in RFC is defined as *opaque, *they are not sanitizing the value for any >> possible malicious values. I have observed two instances where clients >> using Google's OAuth service directly use the state parameter value in *Location >> header *to redirect the users hence resulting in header injection >> attacks. >> >> As per my understanding, this issue arises due to the fact that: >> 1. Google allows state parameter to be used for purpose not defined in >> RFC. >> 2. Google is not sanitizing the state paramater on their end. >> 3. Client is also not sanitizing the state paramater and directly using >> it in the *Location* header. >> >> I have raised this issue to google via google VRP but after weeks of >> communication over the ticket, the engineer feels like they are not in >> disagreement with the spec and have requested me to discuss it further with >> your team and hence i am reaching out to you. >> >> Please let me know your thoughts about this. >> >> Regards, >> Chaitanya Reddy >> _______________________________________________ >> OAuth mailing list -- oauth@ietf.org >> To unsubscribe send an email to oauth-leave@ietf.org >> >> >>
- [OAUTH-WG] Security Bug | Unintended usage of "st… Chaitanya Reddy
- [OAUTH-WG] Re: Security Bug | Unintended usage of… Neil Madden
- [OAUTH-WG] Re: Security Bug | Unintended usage of… Chaitanya Reddy
- [OAUTH-WG] Re: Security Bug | Unintended usage of… Neil Madden
- [OAUTH-WG] Re: Security Bug | Unintended usage of… Filip Skokan
- [OAUTH-WG] Re: Security Bug | Unintended usage of… Aaron Parecki
- [OAUTH-WG] Re: Security Bug | Unintended usage of… Tom Jones
- [OAUTH-WG] Re: Security Bug | Unintended usage of… David Waite