aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGordon Tetlow <gordon@FreeBSD.org>2020-09-15 21:47:44 +0000
committerGordon Tetlow <gordon@FreeBSD.org>2020-09-15 21:47:44 +0000
commit7fbd0babb9860eb94b9af72b8a3dcd30547498fb (patch)
treecaa95a1bc6f81947b5ff05c99da11107c9ee36e2
parentae90c99ed866ad63a270286100c30980c4018474 (diff)
downloadsrc-7fbd0babb9860eb94b9af72b8a3dcd30547498fb.tar.gz
src-7fbd0babb9860eb94b9af72b8a3dcd30547498fb.zip
Fix ftpd privilege escalation via ftpchroot.
Approved by: so Approved by: re (implicit for releng/12.2) Security: FreeBSD-SA-20:30.ftpd Security: CVE-2020-7468
Notes
Notes: svn path=/releng/12.1/; revision=365781
-rw-r--r--libexec/ftpd/ftpd.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 38fc9ebb4778..043c896406fd 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -1595,13 +1595,20 @@ skip:
* (uid 0 has no root power over NFS if not mapped explicitly.)
*/
if (seteuid(pw->pw_uid) < 0) {
- reply(550, "Can't set uid.");
- goto bad;
+ if (guest || dochroot) {
+ fatalerror("Can't set uid.");
+ } else {
+ reply(550, "Can't set uid.");
+ goto bad;
+ }
}
+ /*
+ * Do not allow the session to live if we're chroot()'ed and chdir()
+ * fails. Otherwise the chroot jail can be escaped.
+ */
if (chdir(homedir) < 0) {
if (guest || dochroot) {
- reply(550, "Can't change to base directory.");
- goto bad;
+ fatalerror("Can't change to base directory.");
} else {
if (chdir("/") < 0) {
reply(550, "Root is inaccessible.");