Skip to contentSkip to conversation

OpenEmbedded and known security issues

DISCUSSION Holger Hans Peter Freyther 2 participants 6 messages Jan 23, 2010 – Feb 28, 2010

lore
Share & tools
lore
#0 lore raw

Hi all,

the topic was brought up in another thread. Some of the software we are shipping as default is vulnerable to known security issues. It would take a full time position to subscribe to vendor security lists and make sure we are doing every security update as well. One example of currently vulnerable software in our repository is "libtool 2.2.6a" as it will dlopen a library from the $CWD... :)

Here is my proposal and it would be great to have some assistance. I'm using FreeBSD, and with FreeBSD there is huge ports tree (just like with the OE recipes), and since about 2003 there is this nice utility called portaudit..

1.) It offers to fetch a database from the FreeBSD servers. It is called "auditfile.tbz". The content of the file is quite simple, it has the projectname, the range of vulnerable versions, a link to the FreeBSD issue ticket, and the kind of vulnerability.

2.) The second mode of the script is to compare installed versions with the list of known vulnerabilities...

Now here comes the idea... Hack OE or bitbake to compare the PN to the PN of the database and the PV to the PV of known vulnerabilities.. and then mention a problem while parsing and then quit.

Known problems:
- Sometimes our PN and their PN might not match so we need a different mapping somewhere in OE
- The same might apply for the PV. specially with out -rX. So imagine 2.2.6a of libtool is vulnerable, and we apply the fix to it, we will still call it 2.2.6a... so we might need a second mapping in OE to claim where we have fixed known vulnerabilities..

so what do you guys think about the approach? Does someone care to hack this up? Would there be interest to sponsor a day or two for developing this?

regards
holger

#1 lore raw
Quoted 7 lines · On Saturday 23 January 2010 08:27:49 Holger Hans Peter Freyther wrote:

2.) The second mode of the script is to compare installed versions with the list of known vulnerabilities...

Now here comes the idea... Hack OE or bitbake to compare the PN to the PN of the database and the PV to the PV of known vulnerabilities.. and then mention a problem while parsing and then quit.

Hi,
I will try to hack something tomorrow on my flight to iceland... So we do have

1.) auditfile.tbz from FreeBSD (of course this will not help us with busg in udev and linux specific things)
2.) I use the output of bitbake -s
3.) I create a file that claims when a FreeBSD issue was fixed (the PR we did)

i try to merge that all with python and spit out a list of vulnerable software in our tree...

z.

#2 lore raw
Quoted 2 lines · On Friday 26 February 2010 21:00:19 Holger Hans Peter Freyther wrote:

i try to merge that all with python and spit out a list of vulnerable software in our tree...

I will probably rewrite this with GNU smalltalk in the next days but here is the first version of a python script...

It needs the output of "bitbake -s" (minus the first three lines), it needs the uncompressed/untared auditfiles.tbz and then it will list some stuff... It is not yet comparing the package versions...

#!/usr/bin/env python

def read_available(filename):
"""
Parses the output of bitbake -s
minus the first few lines
"""
f = open(filename)
packages = {}

for line in f:
# str.split can not be used as we have multiple whitespace first_space = line.find(" ")
package = line[0:first_space]
rest = line[first_space+1:]
pv = rest.strip().split(" ")[0]

packages[package] = pv
return packages

class freebsd_info:

    """
    Handles an entry like the one below:
    vulnerability-test-port>=2000<2010.02.26|http://cvsweb.freebsd.org/ports/security/vulnerability-test-port/|Not vulnerable, just a test port (database: 2010-02-26)
    """
    def __init__(self, line):
        split = line.split("|")
        for i in range(0, len(split[0])):
            c = split[0][i]
            if c != '<' and c != '=' and c != '>':
                continue
            self.name = split[0][0:i]
            self.versions = self.split_versions(split[0][i:])
            break

        self.link = split[1]
        self.kind = split[2]

    @classmethod
    def split_versions(self, input):
        """
        Split versions by <, >, >=, >=
        """
        versions = []
        last_pos = 0

        # Try to determine <, >, >=, <=
        # we will have to carry stuff on to find the
        # version..
        i = 0
        while i < len(input) - 1:
            c1 = input[i]
            c2 = input[i+1]
            if c1 != '<' and c1 != '>' and c1 != '=':
                i = i + 1
                continue

            # is a '=' coming behind it?
            next = i + 1
            if c2 == '=':
                next = next + 1

            # submit
            if last_pos != 0:
                versions.append((next_type, input[last_pos:i]))

            # remember stuff
            next_type = input[i:next]
            last_pos = next
            i = next

        assert last_pos != 0
        versions.append((next_type, input[last_pos:len(input)]))
        return versions

    def __repr__(self):
        return "%s: %s" % (self.name, self.versions)

def read_auditfile(filename):

    """
    Read an uncompressed audit file from freebsd
    """
    f = open(filename)
    packages = {}
    for line in f:
        if line.startswith("#"):
            continue

        info = freebsd_info(line)
        try:
            packages[info.name].append(info)
        except:
            packages[info.name] = []
            packages[info.name].append(info)
    return packages

def compare_versions(oe, freebsd, not_known):
for package in freebsd.keys():
if not package in oe:
print >> not_known, "%s is not in OE" % package continue

for ver in freebsd[package]:
str = []
for (cmp, ver) in ver.versions:
str.append("%s %s %s" % (package, cmp, ver))
print " && ".join(str)

oe_packages = read_available("available")
freebsd_vuln = read_auditfile("auditfile")
buggy = open("not_in_oe.bugs", "w+")

compare_versions(oe=oe_packages, freebsd=freebsd_vuln, not_known=buggy)

#3 lore raw
Quoted 3 lines · On Sunday 28 February 2010 14:08:03 Holger Hans Peter Freyther wrote:

It needs the output of "bitbake -s" (minus the first three lines), it needs the uncompressed/untared auditfiles.tbz and then it will list some stuff... It is not yet comparing the package versions...

Attached is the current script and the current output. I need to compare versions and bb.utils.vercmp doesn't like some of the BSD versions...

Here is a manual analysis and a list of vulnerable software:

gd needs to be upgraded to at least 2.0.35 + patch
unzip seems vulnerable
gnutls 2.4.42 needs to be upgraded to >2.6.6
dia 0.96.1 is vulnerable
fetchmail 6.3.8 is vulnerable
wireshark 1.0.2 is vulnerable
firefox 3.5.5 is vulnerable
vim 7.0 is vulnerable
wget 1.9.1 is vulnerable
perl 5.8.8 is vulnerable
mt-daapd 0.2.4.2 is vulnerable
cyrus-sasl 2.1.19 is vulnerable
gpdf 2.10.0 is vulnerable
ruby 1.8.7-p248 is vulnerable
pango-native is vulnerable
cscope 15.5 is vulnerable
freeciv 2.0.8 is vulnerable
openssl 0.9.8j is vulnerable
tor 0.1.1.26 is vulnerable
libghttpd 1.4.18 is vulnerable
ipsec-tools 0.6.7 is vulnerable
cyrus-imapd 2.2.12 is vulnerable
gallery 1.5.5. is vulnerable
thuunderbird 1.0.7 is vulnerable
findutils 4.2.29 is vulnerable
findutils-native 4.2.29 is vulernable
streamripper 1.61.10 is vulnerable
id3lib 3.8.3 is vulnerable
vorbis-tools 1.1.1 is vulnerable
libvorbius 1.2.3 is vulnerable (without a patch)
gftp 2.0.18 is vulnerable
gnupg 1.4.2.2 is vulnerable
screen 4.0.3 is vulnerable
wv 1.2.0 is vulnerable
libxine 1.1.16.3 is vulnerable
libcdaudio 0.99.12p2 is vulnerable
imlib 1.9.15 is vulnerable
bogofilter 0.96.0 is vulnerable
gdk-pixbuf maybe too
maradns 10.41 is vulnerable
cdrtools-native 2.01 is vulnerable
squit 2.6.STABLE14 is vulnerable (http://portaudit.FreeBSD.org/6eb580d7-
a29c-11dc-8919-001c2514716c.html)
pngcrush 1.6.4 is vulnerable
pngcrush-native 1.6.4 is vulnerable
gzip 1.3.5 is vulnerable
dnsmask 2.47 is vulnerable
apr 1.3.3 is vulnerable
socat 1.3.2.1 is vulnerable
unrar 3.4.3 is vulnerable
unrar-native 3.4.3 is vulnerable
bitlbee 1.0.4 is vulnerable
ctorrent is vulnerabe
postgressql 8.1.8 is vulnerable
libexif 0.6.17 is vulnerable
libwmf 0.2.8.4 might be vulnerable
libwmf-native same thing
git 1.6.0.4 is vulnerable
git-native 1.6.0.4 is vulernable
netatal 2.0.3 might be vulnerable
lubspf2 1.0.4 is vulnerable
curl-sdk 7.18.2 is vulnerable
bzip2 might be vulnerable
gnome-screensaver 2.28.0 is vulnerable

love

	z.

#!/usr/bin/env python

import bb.utils

def read_available(filename):
"""
Parses the output of bitbake -s minus the first few lines """
f = open(filename) packages = {}

for line in f:
# str.split can not be used as we have multiple whitespace first_space = line.find(" ")
package = line[0:first_space]
rest = line[first_space+1:]
pv = rest.strip().split(" ")[0]

packages[package] = pv
return packages

class freebsd_info:

    """
    Handles an entry like the one below:
    vulnerability-test-port>=2000<2010.02.26|http://cvsweb.freebsd.org/ports/security/vulnerability-test-port/|Not vulnerable, just a test port (database: 2010-02-26)
    """
    def __init__(self, line):
        split = line.split("|")
        for i in range(0, len(split[0])):
            c = split[0][i]
            if c != '<' and c != '=' and c != '>':
                continue
            self.name = split[0][0:i]
            self.versions = self.split_versions(split[0][i:])
            break

        self.link = split[1]
        self.kind = split[2]

    @classmethod
    def split_versions(self, input):
        """
        Split versions by <, >, >=, >=
        """
        versions = []
        last_pos = 0

        # Try to determine <, >, >=, <=
        # we will have to carry stuff on to find the
        # version..
        i = 0
        while i < len(input) - 1:
            c1 = input[i]
            c2 = input[i+1]
            if c1 != '<' and c1 != '>' and c1 != '=':
                i = i + 1
                continue

            # is a '=' coming behind it?
            next = i + 1
            if c2 == '=':
                next = next + 1

            # submit
            if last_pos != 0:
                versions.append((next_type, input[last_pos:i]))

            # remember stuff
            next_type = input[i:next]
            last_pos = next
            i = next

        assert last_pos != 0
        versions.append((next_type, input[last_pos:len(input)]))
        return versions

    def __repr__(self):
        return "%s: %s" % (self.name, self.versions)

def read_auditfile(filename):

    """
    Read an uncompressed audit file from freebsd
    """
    f = open(filename)
    packages = {}
    for line in f:
        if line.startswith("#"):
            continue

        info = freebsd_info(line)
        try:
            packages[info.name].append(info)
        except:
            packages[info.name] = []
            packages[info.name].append(info)
    return packages

def strip_oe_version(oe_version):

    """
    We need to strip the package epoch... and the PR to compare
    it to the FreeBSD versions. Also FreeBSD seems to use _N as
    PR so we might need to do more..
    """
    split = oe_version.split(':', 1)
    ver = split[1]

    split = ver.rsplit('-r', 1)
    ver = split[0]
    return ver

def strip_bsd_version(bsd_version):

    """
    FreeBSD is adding ,1 for revisions.. remove that
    """
    split = bsd_version.rsplit(',', 1)
    return split[0]

def compare_versions(oe, freebsd, not_known):
def handle_package(oe_name, bsd_name):
if not oe_name in oe:
if oe_name == bsd_name:
print >> not_known, "%s is not in OE" % oe_name
return

oe_version = strip_oe_version(oe[oe_name])
for ver in freebsd[bsd_name]:
str = []
for (cmp, ver) in ver.versions:
bsd_ver = strip_bsd_version(ver)
str.append("%s %s %s %s" % (oe_name, oe_version, cmp, bsd_ver))
print " && ".join(str)

for package in freebsd.keys():
# handle the various versions of OE packages handle_package(package, package) handle_package("%s-native" % package, package) handle_package("%s-full-native" % package, package) handle_package("%s-sdk" % package, package)

# read the input data
oe_packages = read_available("available")
freebsd_vuln = read_auditfile("auditfile")
buggy = open("not_in_oe.bugs", "w+")

compare_versions(oe=oe_packages, freebsd=freebsd_vuln, not_known=buggy)

#4 lore raw

Could your provide a link to the current auditfile.tbz ?

ftp://ftp.freebsd.org/pub/FreeBSD/ports/local-distfiles/eik/ is outdated? The webpage located at
http://www.freebsd.org/ports/portaudit/ seems a lot more up to date (although it doesn't contain a link to an auditfile)

Regards,
Michael