CVE-2022-24921
authorGo Compiler Team <team+go-compiler@tracker.debian.org>
Thu, 20 Apr 2023 14:32:58 +0000 (15:32 +0100)
committerSylvain Beucler <beuc@debian.org>
Thu, 20 Apr 2023 14:32:58 +0000 (15:32 +0100)
commit39236d709ee08f754937c62b3f5d549f88d1a9aa
treee6da9fe4476ad0e3381d96c184ab6a64e35b8e04
parent6b2abfb91385dd54226298d3deb290ffdbe2f114
CVE-2022-24921

Origin: https://github.com/golang/go/commit/2b65cde5868d8245ef8a0b8eba1e361440252d3b
Reviewed-by: Sylvain Beucler <beuc@debian.org>
Last-Update: 2023-04-18

From 2b65cde5868d8245ef8a0b8eba1e361440252d3b Mon Sep 17 00:00:00 2001
From: Russ Cox <rsc@golang.org>
Date: Wed, 2 Feb 2022 16:41:32 -0500
Subject: [PATCH] [release-branch.go1.16] regexp/syntax: reject very deeply
 nested regexps in Parse
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The regexp code assumes it can recurse over the structure of
a regexp safely. Go's growable stacks make that reasonable
for all plausible regexps, but implausible ones can reach the
“infinite recursion?” stack limit.

This CL limits the depth of any parsed regexp to 1000.
That is, the depth of the parse tree is required to be ≤ 1000.
Regexps that require deeper parse trees will return ErrInternalError.
A future CL will change the error to ErrInvalidDepth,
but using ErrInternalError for now avoids introducing new API
in point releases when this is backported.

Fixes #51112.
Fixes #51117.

Change-Id: I97d2cd82195946eb43a4ea8561f5b95f91fb14c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/384616
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/384855

Gbp-Pq: Name CVE-2022-24921.patch
src/regexp/syntax/parse.go
src/regexp/syntax/parse_test.go