Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 123417 - app-office/mdbtools: multiple heap overflows
Summary: app-office/mdbtools: multiple heap overflows
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Auditing (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Security
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-19 14:30 UTC by Stefan Cornelius (RETIRED)
Modified: 2009-03-18 22:17 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Cornelius (RETIRED) gentoo-dev 2006-02-19 14:30:55 UTC
No real time to analyze this, but i think there are several heap overflows in mdbtools.
Example:
--------------------------------------------
	rownum = mdb->pg_buf[fmt->tab_usage_map_offset];
	mdb_read_alt_pg(mdb, mdb_get_int24(mdb, fmt->tab_usage_map_offset + 1)); 
	mdb_swap_pgbuf(mdb);
	row_start = mdb_get_int16(mdb, (fmt->row_count_offset + 2) + (rownum*2));
   row_end = mdb_find_end_of_row(mdb, rownum);
	table->map_sz = row_end - row_start + 1;
	table->usage_map = malloc(table->map_sz);
	memcpy(table->usage_map, &mdb->pg_buf[row_start], table->map_sz);
--------------------------------------------
Unfortunately, when supplying a malformed file, row_start can be bigger then row_end, resulting in a negative map_sz to be allocated -> segfault when memcpy. There seem to be more issues similar to this one in mdbtools.

Version 0.6pre1 seems to catch certain malformed files, but I can still cause segfaults (Didn't investigate any further). What do you think about this?
Comment 1 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2006-04-07 23:21:57 UTC
Auditing any news on this one?
Comment 2 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2006-06-16 11:10:20 UTC
Auditing any news on this one?
Comment 3 Matthias Geerdsen (RETIRED) gentoo-dev 2006-12-13 03:30:18 UTC
Has anyone looked at this again in the last nearly ten months?
Comment 4 Pierre-Yves Rofes (RETIRED) gentoo-dev 2009-03-17 21:42:34 UTC
Stefan, I contacted you on #oss-security some months ago, are you (or Secunia) still interested in keeping this confidential?
Comment 5 Stefan Cornelius 2009-03-18 15:52:13 UTC
Hey guys!

First of all, I'm really sorry for letting this take so long, my apologies.

I think this is a nonissue and the bug can finally be closed :)

Well, I probably fell for the fact that after the wrap around to positive (since malloc() wants size_t and table->map_sz is a negative int) the amount of memory to be allocated is _huge_ and most likely going to fail, resulting in table->usage_map being NULL, causing the memcpy to segfault - which I must have mistaken as the result of a heap overflow (... I was a stupid kid back then ...).

But even if malloc() does not return 0, table->map_sz is used for both the malloc() and memcpy() and both accept size_t, thus there shouldn't be an overflow.

In case you guys want to play around with this yourself, get the mdb file http://www.haneng.com/Lessons/20/Sample.mdb and mess around with the bytes at offsets 0x300A and 0x300B.

Have a nice time and take care,
Stefan
Comment 6 Pierre-Yves Rofes (RETIRED) gentoo-dev 2009-03-18 19:20:25 UTC
Stefan, thanks for the clarification. Do you mind if I make the bug public? No need to keep this classified if it's a non issue.
Comment 7 Stefan Cornelius 2009-03-18 20:27:12 UTC
As you said, no reason to keep this secret, except that I'm ashamed of my (soon to be publicly documented) f*ckup ;)

Just go ahead with the usual procedure, should be fine.

Thanks!