From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9C1AB38560B9; Sat, 16 Sep 2023 00:50:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C1AB38560B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694825403; bh=XPnt1OpuLTIE3gKEw6IyAznCJTpBcAbFcBvSv1Tf6Hs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YIqD3iGLxQaPdjqXGPlTWjzi+PAr2TfxzACl+QVXwpFpfy+S+J1fTMaagmva2peAQ DCLqmEruRHUpzZjyEbnqFCPwGzSdeW9aMdfawpmwmhCAiImajt5K32cHZ9Zv3vwk2I J+cdiHk9jCAz6FA1S3b0I6XQSSQDLvditM+GfdT8= From: "cvs-commit at gcc dot gnu.org" To: glibc-bugs@sourceware.org Subject: [Bug network/30843] potential use-after-free in getcanonname (CVE-2023-4806) Date: Sat, 16 Sep 2023 00:50:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: network X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: siddhesh at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: security+ X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30843 --- Comment #10 from cvs-commit at gcc dot gnu.org --- The release/2.34/master branch has been updated by Siddhesh Poyarekar : https://sourceware.org/git/gitweb.cgi?p=3Dglibc.git;h=3De09ee267c03e3150c2c= 9ba28625ab130705a485e commit e09ee267c03e3150c2c9ba28625ab130705a485e Author: Siddhesh Poyarekar Date: Fri Sep 15 13:51:12 2023 -0400 getaddrinfo: Fix use after free in getcanonname (CVE-2023-4806) When an NSS plugin only implements the _gethostbyname2_r and _getcanonname_r callbacks, getaddrinfo could use memory that was freed during tmpbuf resizing, through h_name in a previous query response. The backing store for res->at->name when doing a query with gethostbyname3_r or gethostbyname2_r is tmpbuf, which is reallocated in gethosts during the query. For AF_INET6 lookup with AI_ALL | AI_V4MAPPED, gethosts gets called twice, once for a v6 lookup and second for a v4 lookup. In this case, if the first call reallocates tmpbuf enough number of times, resulting in a malloc, th->h_name (that res->at->name refers to) ends up on a heap allocated storage in tmpbuf. Now if the second call to gethosts also causes the plugin callback to return NSS_STATUS_TRYAGAIN, tmpbuf will get freed, resulting in a UAF reference in res->at->name. This then gets dereferenced in the getcanonname_r plugin call, resulting in the use after free. Fix this by copying h_name over and freeing it at the end. This resolves BZ #30843, which is assigned CVE-2023-4806. Signed-off-by: Siddhesh Poyarekar (cherry picked from commit 973fe93a5675c42798b2161c6f29c01b0e243994) --=20 You are receiving this mail because: You are on the CC list for the bug.=