From owner-freebsd-bugs@freebsd.org Tue Mar 15 17:50:01 2016 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 633A0AD14C1 for ; Tue, 15 Mar 2016 17:50:01 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 482A51067 for ; Tue, 15 Mar 2016 17:50:01 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id u2FHo1cZ013642 for ; Tue, 15 Mar 2016 17:50:01 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 208035] IPFW firewall heap overflow Date: Tue, 15 Mar 2016 17:50:01 +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: 11.0-CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: cturt@hardenedbsd.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-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-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Mar 2016 17:50:01 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D208035 Bug ID: 208035 Summary: IPFW firewall heap overflow Product: Base System Version: 11.0-CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: cturt@hardenedbsd.org There is a heap overflow, triggerable as root only in the IPFW firewall handling code. sys/netpfil/ipfw/ip_fw_nat.c: static int ipfw_nat_cfg(struct sockopt *sopt) { struct cfg_nat_legacy *cfg; struct nat44_cfg_nat *ucfg; struct cfg_redir_legacy *rdir; struct nat44_cfg_redir *urdir; char *buf; size_t len, len2; int error, i; len =3D sopt->sopt_valsize; len2 =3D len + 128; /* * Allocate 2x buffer to store converted structures. * new redir_cfg has shrinked, so we're sure that * new buffer size is enough. */ buf =3D malloc(roundup2(len, 8) + len2, M_TEMP, M_WAITOK | M_ZERO); error =3D sooptcopyin(sopt, buf, len, sizeof(struct cfg_nat_legacy)= ); The size calculation passed to `malloc` can be overflown, resulting in heap overflow on `sooptcopyin`. This function is called when the `IP_FW_NAT_CFG` command is passed to `ipfw_ctl`: int ipfw_ctl(struct sockopt *sopt) { ... /* Save original valsize before it is altered via sooptcopyin() */ valsize =3D sopt->sopt_valsize; opt =3D sopt->sopt_name; ... switch (opt) { ... case IP_FW_NAT_CFG: if (IPFW_NAT_LOADED) error =3D ipfw_nat_cfg_ptr(sopt); else { printf("IP_FW_NAT_CFG: %s\n", "ipfw_nat not present, please load it"); error =3D EINVAL; } break; `ipfw_ctl` is only called by `ipfw_ctl3`, which is available only to root processes (must have `PRIV_NETINET_IPFW` privilege): int ipfw_ctl3(struct sockopt *sopt) { ... error =3D priv_check(sopt->sopt_td, PRIV_NETINET_IPFW); if (error !=3D 0) return (error); if (sopt->sopt_name !=3D IP_FW3) return (ipfw_ctl(sopt)); --=20 You are receiving this mail because: You are the assignee for the bug.=