pkgconf/libpkgconf
Tobias Stoeckmann fb9acedcad libpkgconf: dependency: fix out of boundary write
It is possible to trigger an out of boundary write in function
pkgconf_dependency_parse_str if a dependency line contains a very
long comparator. The comparator is stored in a temporary buffer which
has a size of PKGCONF_ITEM_SIZE.

The line which is parsed can be up to PKGCONF_BUFSIZE characters long,
which is larger than PKGCONF_ITEM_SIZE (although it depends on PATH_MAX).

Having a comparator which is longer than PKGCONF_ITEM_SIZE therefore
leads to an out of boundary write. Although it is undefined behaviour,
this can lead to an overridden compare variable, which in turn can lead
to an invalid instruction pointer, i.e. most likely a crash or code
execution (very unlikely).

Proof of concept:

$ echo "Requires: x " > poc.pc
$ dd if=/dev/zero bs=1 count=65535 | tr '\0' '<' >> poc.pc
$ pkgconf poc.pc

Eiter compile pkgconf with address sanitizer or run pkgconf multiple
times, eventually it might crash (assuming that ASLR is in place).

In order to fix this, I decided to use an end pointer to avoid OOB write.
Alternative would be to increase the buffer size, but I try to avoid that
since this would be additional ~60 KB stack space for a very unlikely
situation.
2020-05-26 14:03:55 -06:00
..
argvsplit.c libpkgconf: argvsplit: fix escape handling in tokenizer (closes #163) 2017-12-14 22:41:14 -06:00
audit.c libpkgconf: document audit module 2016-12-10 19:28:34 -06:00
bsdstubs.c Minimal tweaks to compile with Visual C 2015 2017-06-04 19:19:55 -07:00
bsdstubs.h normalize include guards. closes #33 2019-05-25 16:00:09 -05:00
cache.c libpkgconf: cache: fix refcount issue exposed by recent depgraph solver changes 2017-12-08 13:39:40 -06:00
client.c fix the order of header includes 2019-06-08 04:55:52 +03:00
config.h.meson Fix build on windows with meson 2018-09-17 15:41:27 +02:00
dependency.c libpkgconf: dependency: fix out of boundary write 2020-05-26 14:03:55 -06:00
fileio.c libpkgconf: fileio: prevent buffer overflow. 2020-05-24 14:09:44 -06:00
fragment.c add support for the PKGCONF_PKG_PKGF_DONT_MERGE_SPECIAL_FRAGMENTS flag used in build2. 2020-05-24 14:40:47 -06:00
iter.h normalize include guards. closes #33 2019-05-25 16:00:09 -05:00
libpkgconf-api.h normalize include guards. closes #33 2019-05-25 16:00:09 -05:00
libpkgconf.h pkgconf 1.7.0. 2020-05-24 14:55:02 -06:00
meson.build Experiment to build with Meson (#119) 2017-06-19 19:03:00 -05:00
parser.c libpkgconf: parser: fix out of boundary access 2020-05-24 14:10:18 -06:00
path.c libpkgconf: path: fix memory leak when deduping paths (closes #39) 2019-07-11 03:43:18 -05:00
personality.c libpkgconf: personality: fix out of boundary access 2020-05-25 05:55:39 -06:00
pkg.c libpkgconf: pkg: use a second pointer for demunging windows paths 2020-05-26 13:42:39 -06:00
queue.c libpkgconf: dependency: allow dependency nodes to be colored with traits 2018-03-18 18:03:33 -05:00
stdinc.h normalize include guards. closes #33 2019-05-25 16:00:09 -05:00
tuple.c libpkgconf: tuple: tighten quoting logic a bit 2019-03-23 22:34:11 -05:00
win-dirent.h normalize include guards. closes #33 2019-05-25 16:00:09 -05:00