IPED icon indicating copy to clipboard operation
IPED copied to clipboard

Folders inside a forensic image with more than 1 million files being ignored

Open wladimirleite opened this issue 11 months ago • 18 comments

This was found by @hugohmk and I was able to reproduce it. A folder with one million files in a NTFS (inside a E01) was silently ignored (no error, but its content was not added to the case). A similar folder, with 600,000 files, was processed correctly.

To identify the problem's cause, I ran the standalone "tsk_loaddb.exe" and observed the same behavior, using TSK 4.12.0 and 4.12.1. However, when I tried 4.11.1 (the version before 4.12.0), it worked fine.

Having such a huge number of files in the same folder should be an extremely unusual situation, but it is possible and allowed by NTFS.

wladimirleite avatar Mar 19 '24 23:03 wladimirleite

Well, unfortunately, that was an intentional Sleuthkit change... I'll search for the related issue and post it here.

lfcnassif avatar Mar 20 '24 00:03 lfcnassif

https://github.com/sleuthkit/sleuthkit/pull/2787

I agree with those stating it should at least be configurable, e.g. with an environment variable parameter.

We can patch our Sleuthkit fork to implement that, I'm not happy to maintain a fork...

lfcnassif avatar Mar 20 '24 00:03 lfcnassif

@wladimirleite, while running your tests, did you see big memory consumption issues or excessive slowness?

lfcnassif avatar Mar 20 '24 00:03 lfcnassif

@wladimirleite, while running your tests, did you see big memory consumption issues or excessive slowness?

Using 4.11.1, tsk_loaddb.exe took a while (~40 minutes), but I didn't monitor memory. With IPED processing (and tsk_loaddb.exe 4.12.0), it was very fast (only a minute or so), but the folder and all its files were ignored.

wladimirleite avatar Mar 20 '24 00:03 wladimirleite

I agree with those stating it should at least be configurable, e.g. with an environment variable parameter.

Indeed. And maybe an option to abort with an error, instead of just silently ignoring.

We can patch our Sleuthkit fork to implement that, I'm not happy to maintain a fork...

I don't think it is worth the effort to maintain a fork. Since @hugohmk provided a E01 with a folder with 3 million files, I will try to raise the hardcoded limit in TSK and see what happens in terms of memory consumption and slowness. As I said, this should be very rare, but once we try to process a disk image with such a condition, it can be very dangerous, as a lot of files will be ignored without any clear warning.

wladimirleite avatar Mar 20 '24 00:03 wladimirleite

As I said, this should be very rare, but once we try to process a disk image with such a condition, it can be very dangerous, as a lot of files will be ignored without any clear warning.

Has tsk_loaddb.exe 4.12+ written some warning/error in the Console? If yes, was that logged in IPED logs? PS: Today we use the java bindings, which output can be different than tsk_loaddb, we try to detect critical errors from TSK java binding output, log some of them and redirect others to IPED console, maybe we are failing in the error detection part...

lfcnassif avatar Mar 20 '24 00:03 lfcnassif

Using 4.11.1, tsk_loaddb.exe took a while (~40 minutes), but I didn't monitor memory.

Well, I have seen a few cases taking a similar or more time in tsk_loaddb to decode the FS tree, not sure if they are related to this issue...

lfcnassif avatar Mar 20 '24 00:03 lfcnassif

No output in the console using tsk_loaddb. I later saw some messages using its verbose command line option, but it generated several GB of log, so it wasn't possible to identify what was going on.

wladimirleite avatar Mar 20 '24 00:03 wladimirleite

@markmckinnon if we send a PR to Sleuthkit making that hard coded limit configurable, will it be reviewed?

lfcnassif avatar Mar 20 '24 10:03 lfcnassif

@lfcnassif it should be reviewed and implemented as this can also effect Autopsy as well.

markmckinnon avatar Mar 21 '24 20:03 markmckinnon

Thanks @markmckinnon, we will try to propose a PR to Sleuthkit repo then.

lfcnassif avatar Mar 21 '24 20:03 lfcnassif

Do you think using an environment variable, like TSK_MAX_ENTRIES_PER_FOLDER is a good approach? If not set, keep current limit. If set, use the configured value. If set to -1, disable the limit. Looks fine?

lfcnassif avatar Mar 21 '24 20:03 lfcnassif

So each tool that wants to make a new limit or no limit will have to set an environment variable in what ever OS they are running in instead of using a command line argument?

markmckinnon avatar Mar 21 '24 20:03 markmckinnon

Yes, that would work for us, and minor code changes would be needed, with no TSK API or internal data structures changes. But I understand that would be a global system configuration that would affect all TSK depending tools, and maybe different tools would need a different configuration...

lfcnassif avatar Mar 21 '24 21:03 lfcnassif

@wladimirleite did this happen with a real world image or the triggering image was an artificial one?

lfcnassif avatar May 02 '24 20:05 lfcnassif

I confirmed with @hugohmk a while ago, it was in an artificial image (generated to test another unrelated possible performance issue). I planned to investigate it a bit more, maybe suggesting a better solution inside TSK, but couldn't find time so far, as I am not familiar with its code.

wladimirleite avatar May 02 '24 20:05 wladimirleite

I can implement the environment variable workaround in our fork, but I'm asking to check the priority of this fix, if it should go into 4.2.0 or not, so seems it is not critical...

lfcnassif avatar May 02 '24 20:05 lfcnassif

No, I don't think it is critical.

wladimirleite avatar May 02 '24 21:05 wladimirleite