lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date: Sun, 23 Nov 2014 15:07:33 -0800
From: Michal Zalewski <lcamtuf@...edump.cx>
To: "fulldisclosure@...lists.org" <fulldisclosure@...lists.org>
Subject: [FD] on Linux, 'less' can probably get you owned

Many Linux distributions ship with the 'less' command automagically
interfaced to 'lesspipe'-type scripts, usually invoked via LESSOPEN.
This is certainly the case for CentOS and Ubuntu.

Unfortunately, many of these scripts appear to call a rather large
number of third-party tools that likely have not been designed with
malicious inputs in mind. On CentOS, lesspipe appears to include
things such as groff + troff + grotty, man, and cpio. On Ubuntu,
there's isoinfo (?!), ar from binutils, and so on. Ancient and obscure
compression utilities and doc converters crop up, too. Some other
folks have expressed their disbelief in the past:

https://twitter.com/solardiz/status/526008283690455040

But even ignoring the most suspect tools and grabbing something as
seemingly innocuous as cpio, a short spin with afl-fuzz (or, probably,
anything else) will immediately yield this:

http://lcamtuf.coredump.cx/afl/vulns/lesspipe-cpio-bad-write.cpio

It's a file with declared block length of 0xffffffff. That gets us
here, with the value populated to c_filesize (copyin.c, list_file()):

  link_name = (char *) xmalloc ((unsigned int) file_hdr->c_filesize + 1);
  link_name[file_hdr->c_filesize] = '\0';

...where we end up allocating a zero-byte buffer and then promptly
writing out of bounds (just under the buffer on 32-bit systems or
somewhere above it on 64-bit).

While it's a single bug in cpio, I have no doubt that many of the
other lesspipe programs are equally problematic or worse. In a thread
yesterday, people immediately started pointing out other issues, say:

http://seclists.org/oss-sec/2014/q4/773

The saving grace is that lesspipe scripts make most of their routing
decisions based on file extensions. Alas, many of these extensions
will be completely alien and meaningless to all but the most seasoned
users (.cpi, .raw, .r42, .ear, .zoo, .a). And there are some instances
of utilities being called on * (e.g., iconv, fileutils).

Ultimately, I think that there's an expectation that running less on a
downloaded file won't lead to RCE, and the lesspipe behavior in many
distros is almost certainly violating that. I'm also not sure if the
automation actually scratches any real itch - I doubt that people try
to run 'less' on CD images or 'ar' archives when knowingly working
with files of that sort.

At this point, my best advice would be for users to unset LESSOPEN and
LESSCLOSE if set by their distros.

/mz

_______________________________________________
Sent through the Full Disclosure mailing list
http://nmap.org/mailman/listinfo/fulldisclosure
Web Archives & RSS: http://seclists.org/fulldisclosure/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ