Date: Tue, 10 Feb 2015 11:01:51 +0100 From: Mateusz Guzik <mjguzik@gmail.com> To: Rui Paulo <rpaulo@me.com> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Rui Paulo <rpaulo@FreeBSD.org> Subject: Re: svn commit: r278479 - in head: etc sys/kern Message-ID: <20150210100151.GA5994@dft-labs.eu> In-Reply-To: <EE5E14DC-D44C-495B-BB2B-ADFCC6B07B59@me.com> References: <201502092313.t19NDpoS083043@svn.freebsd.org> <20150210024317.GA21779@dft-labs.eu> <EE5E14DC-D44C-495B-BB2B-ADFCC6B07B59@me.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Feb 09, 2015 at 06:57:36PM -0800, Rui Paulo wrote: > On Feb 9, 2015, at 18:43, Mateusz Guzik <mjguzik@gmail.com> wrote: > > > > On Mon, Feb 09, 2015 at 11:13:51PM +0000, Rui Paulo wrote: > >> +notify 10 { > >> + match "system" "kernel"; > >> + match "subsystem" "signal"; > >> + match "type" "coredump"; > >> + action "logger $comm $core"; > >> +}; > >> + > >> */ > >> > > [..] > >> + if (vn_fullpath_global(td, p->p_textvp, &fullpath, &freepath) != 0) > >> + goto out; > >> + snprintf(data, len, "comm=%s", fullpath); > > > > I cannot test it right now, but it looks like immediate privilege > > escalation. > > > > Path is not sanitized in any way and devd passes it to 'sh -c'. > > > > So a file named "a.out; /bin/id; meh" or so should result in execution > > of aforementioned /bin/id. > > Well, you can't have a file name with "/" but you're right. > I mean the whole path. You are resolving the name along with all dirs, so it's just a matter of some mkdirs. > > Another note is that currently devctl is record oriented, but this may > > change at some point and free form userspace text could be used to forge > > new events. > > > > As such is trongly suggest we sanitize this somehow. Maybe a base64 or > > something. > > I was trying hard to avoid this issue in unpublished my crash helper, but I forgot that devd runs execl("sh -c", ....); :-( > > It might just be easier to inspect the path names and allow only [a-z][A-Z][0-9] and '/' before sending the devctl message. > I'm pretty sure sooner or later people will want something with a space, so I would prefer a reasonably complete solution. A hack like the one yu mention should suffice fr now though (with the addition of a dot). -- Mateusz Guzik <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150210100151.GA5994>