From nobody Tue Oct 04 20:39:31 2022 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 4MhqLq4Z5Pz4dfp7 for ; Tue, 4 Oct 2022 20:39:31 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MhqLq2VV7z3D6B for ; Tue, 4 Oct 2022 20:39:31 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) 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 4MhqLq1ZLyzgs4 for ; Tue, 4 Oct 2022 20:39:31 +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 294KdVPL083004 for ; Tue, 4 Oct 2022 20:39:31 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 294KdVsE083003 for bugs@FreeBSD.org; Tue, 4 Oct 2022 20:39:31 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 266827] corrupt message can cause wild pointer read in hastd Date: Tue, 04 Oct 2022 20:39:31 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: rtm@lcs.mit.edu 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 attachments.mimetype attachments.created 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 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664915971; 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=i3StgLY57m8ws2H0vb2l5v3P+6++wxE39RvtCGWU8dQ=; b=k+UDLvdBkp8PVcHTUcXdt/BZHd0oCNqvgyjaFBC/1X+K5oq34QjZQiKElX9JoJ27kjJfdA 7gNmH9XmO3BqaXl69d8O83vuWYNrXxH+9UoKOsAHboJ0IIGCxDXCTkkR1D4FEJ9xNvqaMm yh69fd8BrJPhDpYZpc0W8Ju+29UdaHAtoeN2HRzW1Do/G8uqr/NJRJEZuWoPwANNi9m31o iMsYpT9tboqi3CFaQ2nOPMQ3KtUtAG5ecmdcHlxqe2YEus0b7W7iJMvsARuY2Dy8YsG3TA lB+DJBFn+O5qJazyZsmilrideMuse2JXDzxMpQ8SbA/gX1VTHiyQ7B8KHHuXWg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664915971; a=rsa-sha256; cv=none; b=Lm4YGEQKKnta9v0jsvMtONTWkJ8uS/pF0Mh0mc4BcvU1iDT8QEdnn42lzo2bPAlBi4B89P qUqO9MwSCf04WXESC13YG6/h/eBDyIMs1MefQZTrv0dIY3N0w1OLTIepC1bvDBOBVU1aoS R6JeHF7N94S4MPmMaD+0cAZWO1ywK36RBpu16U6DhC9SF7oElwtbQ+w7AeFvVNzgQV3TkA tDtEh+FBNlASVBqgOIH29PxsrF0G3/UIw2kMnL+z/aVrZaYUmyDFYnze0pTuPBPiX/QTQ+ 7ztGrkilFnljfaJxSWSx2Z65oBnwCA5bDHQIn0+VqcCplrXAkggpwwNKbhxRIA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D266827 Bug ID: 266827 Summary: corrupt message can cause wild pointer read in hastd Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: rtm@lcs.mit.edu Attachment #237079 text/plain mime type: Created attachment 237079 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D237079&action= =3Dedit crash a hastd server with a bad nv string dsize hastd's nv_validate() uses a value from a received packet as an array index without sufficient checking: dsize =3D NVH_DSIZE(nvh); ... case NV_TYPE_STRING: data =3D NVH_DATA(nvh); if (data[dsize - 1] !=3D '\0') { I've attached a demo that passes 2^32-1 as dsize: # cat hast.conf=20 listen tcp://0.0.0.0 resource r { on myhostname { local /tmp/hast.data remote tcp://127.0.0.1 } } # touch /tmp/hast.data # sudo /sbin/hastd -F -d -c hast.conf & # cc hastd1a.c # ./a.out # wait [1] Segmentation fault /sbin/hastd -F -d -c hast.conf Program received signal SIGSEGV, Segmentation fault. Address not mapped to object. nv_validate (nv=3D0x80183d000, extrap=3Dextrap@entry=3D0x7fffffffe518) at /usr/src/sbin/hastd/nv.c:312 312 if (data[dsize - 1] !=3D '\0') { (gdb) where #0 nv_validate (nv=3D0x80183d000, extrap=3Dextrap@entry=3D0x7fffffffe518) at /usr/src/sbin/hastd/nv.c:312 #1 0x000000000103b38c in nv_ntoh (eb=3Deb@entry=3D0x801863000) at /usr/src/sbin/hastd/nv.c:390 #2 0x00000000010360f8 in hast_proto_recv_hdr (conn=3D0x801853040,=20 nvp=3Dnvp@entry=3D0x7fffffffe5b0) at /usr/src/sbin/hastd/hast_proto.c:1= 61 #3 0x0000000001037932 in listen_accept (lst=3Dlst@entry=3D0x80183e000) at /usr/src/sbin/hastd/hastd.c:790 #4 0x0000000001037325 in main_loop () at /usr/src/sbin/hastd/hastd.c:1148 #5 0x0000000001036f68 in main (argc=3D, argv=3D) at /usr/src/sbin/hastd/hastd.c:1337 --=20 You are receiving this mail because: You are the assignee for the bug.=