Re: ctags(1) command execution vulnerability

From: Michael Hamburg (hamburg_at_fas.harvard.edu)
Date: 05/04/04

  • Next message: Alex V Eustrop: "Re: Sendmail issues; possible exploit?"
    Date: Tue, 4 May 2004 02:44:05 -0400
    To: freebsd-security@freebsd.org
    
    

    While I don't think that's much of a vulnerability (you can only really
    attack your own account), your patch doesn't fix it. You can still
    executed code with:

    ctags -u -f "'; echo hi '" *.c

    To remove this "vulnerability," you'd have to either escape the string,
    then quote it, or even better, do the system call with a vector. It
    probably isn't worth the bother, but if you want to patch it, patch it
    right...

    Mike Hamburg

    On May 4, 2004, at 1:49 AM, Roman Bogorodskiy wrote:

    > Hello,
    >
    > ctags(1) uses external application sort(1) for sorting the tags file.
    > It calls it via system(3) function.
    >
    > Look at the /usr/src/usr.bin/ctags/ctags.c file, there are such lines
    > here:
    >
    > if (uflag) {
    > (void)asprintf(&cmd, "sort -o %s %s",
    > outfile, outfile);
    > if (cmd == NULL)
    > err(1, "out of space");
    > system(cmd);
    > free(cmd);
    > cmd = NULL;
    > }
    >
    > This code will be executed when "-u" arg was given. So, if we'll
    > execute
    > ctags in a such way:
    >
    > ctags -u -f ';echo hi' *.c
    >
    > we get the following:
    >
    > Syntax error: ";" unexpected
    > sort: option requires an argument -- o
    > Try `sort --help' for more information.
    > hi
    > hi
    >
    > We can put any command instead of 'echo hi' and it would be executed
    > (for two times).
    >
    > I understand that ctags(1) is not a suid application and this
    > vulnerability probably could not be exploited. Never the less, this is
    > a
    > bad behavior for any kind of program.
    >
    > Solution:
    >
    > --- usr.bin/ctags/ctags.c.orig Tue May 4 09:23:30 2004
    > +++ usr.bin/ctags/ctags.c Tue May 4 09:25:48 2004
    > @@ -166,7 +166,7 @@
    > if (uflag) {
    > for (step = 0; step < argc; step++) {
    > (void)asprintf(&cmd,
    > - "mv %s OTAGS; fgrep -v '\t%s\t' OTAGS >%s; rm OTAGS",
    > + "mv '%s' OTAGS; fgrep -v '\t%s\t' OTAGS >'%s'; rm OTAGS",
    > outfile, argv[step], outfile);
    > if (cmd == NULL)
    > err(1, "out of space");
    > @@ -181,7 +181,7 @@
    > put_entries(head);
    > (void)fclose(outf);
    > if (uflag) {
    > - (void)asprintf(&cmd, "sort -o %s %s",
    > + (void)asprintf(&cmd, "sort -o '%s' '%s'",
    > outfile, outfile);
    > if (cmd == NULL)
    > err(1, "out of space");
    >
    >
    > -Roman Bogorodskiy
    >

    _______________________________________________
    freebsd-security@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-security
    To unsubscribe, send any mail to "freebsd-security-unsubscribe@freebsd.org"


  • Next message: Alex V Eustrop: "Re: Sendmail issues; possible exploit?"

    Relevant Pages

    • [NEWS] Multiple Vulnerabilities in Oracle Database Server (40 Issues)
      ... Multiple buffer overflow and denial of service vulnerabilities exist ... DBMS_REPCAT_INSTANTIATE package ... To reproduce the overflow, execute the next PL/SQL: ... Oracle database user can exploit this vulnerability. ...
      (Securiteam)
    • [UNIX] Trend Micro VirusWall Buffer Overflow in VSAPI Library
      ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... buffer overflow vulnerability in VSAPI library allows arbitrary code ... is called "vscan" which is set suid root by default. ... permissions and thus granted all local users the privilege to execute the ...
      (Securiteam)
    • Re: Download.ject - commentary - LONG
      ... > patch recently released by Microsoft. ... > vulnerability in question, but instead is just a partial workaround. ... > Granted these are known security best practices related to Internet ... > a new default browser to users and hope that it will be safe enough. ...
      (microsoft.public.win2000.security)
    • Microsoft Security Bulletin MS01-044
      ... Subject: Microsoft Security Bulletin MS01-044 ... 15 August 2001 Cumulative Patch for IIS ... - A denial of service vulnerability that could enable an attacker ...
      (Bugtraq)
    • Vulnerability Details for MS02-012
      ... Microsoft released a patch for a denial of service ... vulnerability in the Windows 2000 SMTP component. ... This bug affects all Windows 2000 systems running the SMTP service that have ...
      (Bugtraq)