From owner-freebsd-hackers@freebsd.org Tue Feb 19 21:25:00 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B253414DA097 for ; Tue, 19 Feb 2019 21:25:00 +0000 (UTC) (envelope-from fjwcash@gmail.com) Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8C82D74A75 for ; Tue, 19 Feb 2019 21:24:59 +0000 (UTC) (envelope-from fjwcash@gmail.com) Received: by mail-lf1-x131.google.com with SMTP id g2so15890610lfh.11 for ; Tue, 19 Feb 2019 13:24:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xcAmJw7OPYkfkSQon5sA54UZXYsMazG73HUG6EAHOB8=; b=UpDeURHt1fvsG3GCZ1FJOIDl3sNfYextoX/j3OQFanfJBlYngrWgkGeyynG4O3uXZH JbkmlImxO0XzXuXLgQrZidkxr00W8H+UBUR0hUlmP01rcJ94p3QSDZFj3f99Q9c49mHI DlZ2vVclNS48SaNUoEOe2WVxr8IqWK/iUFFGt/NeJOMvNUCQ9lHH91H0IzyUt/e4CEFW QFrS/AetmR5WWlbWfEFoU/xBqE5iEZTslIV1sIKNKZ+EO5mRPuav0NoYPEwyQTnhfoL4 g4tr7pKbeJeHvNT62FksFMc/jsfdByE1NuA3fLetRdML2lujJqB692+d1l2x+UF+1sri sVyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xcAmJw7OPYkfkSQon5sA54UZXYsMazG73HUG6EAHOB8=; b=a2VcwWmwKYg9kCiV2Q9NwcNBV4dJlGK5La+XlpRte6FmQZRVQeJC/grCfG/BxoBnUw jOvYkPPsFd8v/GXrOV8QfCsR5M7lT8D3RLMGCv79LObv8sPZz25VZLJV0erWPd55LcAx pYsR7mPEp7aM5AYbPyx8Kzs2GH7Y9mnmsOCmFi7/Jze58fWkP7OhuWu4adyQV38BqA3S I47tF4KTEeYQmHhI7LNQdfG+w6GFBfZ0JvZY99rbAnUhlmT3seXUx97wjbYuj4dm3EUS +kRWdakB2N4UEujohY/lP0iRC2FR6a5Eqfb1hYmAzT14yxR37oIDWSnhHp7eeilK+KYa ejIw== X-Gm-Message-State: AHQUAuYbi7NNnFpvBe3yyfD+NguEr9po/aCcN8QJMtYbP2iVJ3C42Qxg VdYQ7BNAPTBHu2rE8WbH4m1YnDlDMh9oVYpNXVBBTg== X-Google-Smtp-Source: AHgI3Ibq8MYdox3BhlVgNcGqr5a5HTMyX3gXSq8Gxiba0EPOPGzgxfn8tdeuczChcWUiH9NOWVGzGe+/CSD4P1nyHJQ= X-Received: by 2002:a19:4b8c:: with SMTP id y134mr16311250lfa.73.1550611497941; Tue, 19 Feb 2019 13:24:57 -0800 (PST) MIME-Version: 1.0 References: <1550610819543-0.post@n6.nabble.com> In-Reply-To: <1550610819543-0.post@n6.nabble.com> From: Freddie Cash Date: Tue, 19 Feb 2019 13:24:46 -0800 Message-ID: Subject: Re: userland process rpc.lockd opens untraceable ports...is something wrong here? To: BBlister Cc: FreeBSD Hackers X-Rspamd-Queue-Id: 8C82D74A75 X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=UpDeURHt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of fjwcash@gmail.com designates 2a00:1450:4864:20::131 as permitted sender) smtp.mailfrom=fjwcash@gmail.com X-Spamd-Result: default: False [-5.65 / 15.00]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.92)[-0.922,0]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; SUBJECT_ENDS_QUESTION(1.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[1.3.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.5.4.1.0.0.a.2.list.dnswl.org : 127.0.5.0]; MIME_TRACE(0.00)[0:+,1:+]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(-2.71)[ip: (-9.25), ipnet: 2a00:1450::/32(-2.27), asn: 15169(-1.99), country: US(-0.07)] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Feb 2019 21:25:00 -0000 On Tue, Feb 19, 2019 at 1:15 PM BBlister wrote: > During a security auditing on one FreeBSD 11.2 server I noticed that > something was listening on a tcp4 and tcp6 port. This could not be traced > back using lsof or sockstat. sockstat returned ? for the process name, and > lsof did not list the port opened. The port was opened because i could > telnet to it. > > I opened a thread at freebsd-questions (Cannot identify process of > listening > port 600/tcp6). You can find the archive of that thread here: > > http://freebsd.1045724.x6.nabble.com/Cannot-identify-process-of-listening-port-600-tcp6-td6314916.html > > After many trials, I found out that these ports were opened by rpc.locked. > Killing that process removed the two listening ports. Restarting the > process, opened two new random ports bellow 1024 that could not be traced > back using all FreeBSD tools that I know to the userland process. > > And here is my question: How is this happening? What magic trick did > rpc.lockd process utilizes and hides itself from security auditing tools > like lsof or sockstat? Why rpc.lockd is the only process that hides itself > from locating what ports it has opened? Is there any other tool except > lsof/sockstat that can backtrace the listening port to the process > rpc.locked? > > but the most important question: Can this trickery being exploited by a > malicious process and open listening ports without being traced using > lsof/sockstat? > While it doesn't take you from a socket/port to a process, does procstat at least show you the sockets that rpc.lockd has open? Something like: procstat -f Although, one could probably run the following to get from the socket/port number to the process: procstat -f -a | grep 600 -- Freddie Cash fjwcash@gmail.com