[00:04.850 --> 00:09.710] Apache TCA is an open source project hosted by the Apache Software Foundation. [00:09.710 --> 00:10.770] It's been around for a while. [00:10.770 --> 00:14.310] It is designed as the Babelfish for file format processing. [00:14.310 --> 00:17.830] It allows just an API for putting in lots of different file types. [00:17.830 --> 00:24.050] This is often a parser suite that is used behind the scenes and often people don't even know they're using it. [00:24.050 --> 00:33.390] So it's embedded in major projects such as Elasticsearch, OpenSearch, Apache Solr, major search systems that need to take files and make text searchable. [00:33.390 --> 00:37.010] Just to give a sense of what TCA can do, I will show you our app. [00:37.010 --> 00:43.430] It's not how most people would use TCA in an application, but it does allow you to explore some of the content within a single file. [00:43.430 --> 00:46.530] It's a docx file, but it has an embedded zip file in it. [00:46.550 --> 00:49.130] And inside that embedded zip file are further zip files. [00:49.130 --> 00:53.810] So it's effectively a nested set of zip files inside of zip files inside of zip files. [00:53.810 --> 00:58.190] Lots of people know that you can have embedded files, zip files have embedded files, and so on. [00:58.530 --> 01:02.670] But one of the really fun things is you can often put embedded files in lots of other formats. [01:02.670 --> 01:08.610] And that's part of the richness of TCA is that it parses through those embedded files and will give you that extracted content. [01:08.610 --> 01:12.590] Let's look at what I view as the most important view of this. [01:12.590 --> 01:25.030] And that's this JSON file format view of the data where you have a map of all the metadata objects, but it's a list of those where the first object is the container file, that docx file. [01:25.030 --> 01:34.350] And then you can see down here we have an embedded file inside of that, which is an emf, which effectively is just the image for that zip file inside that docx file. [01:34.490 --> 01:37.610] And then we see that we have some content in here. [01:37.670 --> 01:41.010] And remember, we saw those text files with embed1 and embed2. [01:41.210 --> 01:45.390] In embed3, we actually have some real text in that text file. [01:45.690 --> 01:53.450] And we can see that the embedded resource path for that file is embed3 text inside of a zip file, inside of a zip file, inside of a zip file. [01:53.490 --> 01:57.850] And then that's all at the root level, effectively, of that docx file. [01:57.850 --> 02:02.610] So all of the embedded files with their metadata content is extracted here. [02:02.610 --> 02:06.070] And then from this, applications could make that searchable. [02:06.070 --> 02:08.470] They could look for specific keywords. [02:08.470 --> 02:15.270] They could run natural language processing on it to pull out human names or phone numbers or social security numbers, any of the other things that people care about. [02:15.270 --> 02:18.470] Lots of different uses for why people would want text out of this. [02:18.570 --> 02:25.730] So for Tika, the main vulnerabilities that I focus on were path traversal and then the other one's command injection. [02:25.730 --> 02:27.630] The file that triggers this is a zip file. [02:27.810 --> 02:37.490] And inside that zip file, there's a file called dot dot, the URL encoding for the slash, and then dot dot, and then the URL encoding for that slash. [02:37.490 --> 02:46.970] So all of the work in file name utils to warn against that dot dot slash are totally nullified because that has passed through here. [02:46.970 --> 02:49.470] And then it becomes active here. [02:49.470 --> 02:52.650] And that gives us the ability to traverse out of that target directory. [02:52.650 --> 02:58.530] Part of the challenge for this is that the CRS has to figure out what's going on with this third-party library. [02:58.530 --> 03:08.330] And then it has to realize that this line should have happened up here, so that all of the protections would have been in place when that decoding had already happened. [03:08.330 --> 03:11.610] So simply moving this further up here would have solved the problem. [03:11.610 --> 03:14.470] The next one is the favorite of what I've done. [03:14.470 --> 03:17.030] It's going to be a doozy to fix. [03:17.030 --> 03:26.350] So the way this works is, this is a command injection vulnerability, which means that the user controls what text goes into the command. [03:26.350 --> 03:34.250] With the right input file, this will run a user-generated command on the command line for the system it's running on, which is really bad. [03:34.410 --> 03:43.010] This CPV hijacks the existing external parser that Tika already has, and then just modifies the command based on user data. [03:43.010 --> 03:48.510] So the target file is an HTML file with an embedded JPEG file. [03:48.790 --> 03:57.810] And if the HTML file has a metadata field called ExifToolPath, then this will configure the ExifTool, which sounds super awesome. [03:57.810 --> 04:00.170] Now we can run Exif on the embedded JPEG file, right? [04:00.170 --> 04:10.450] What this is doing is going through and saying, along the list of parsers, find a composite external parser, which is the thing that we use to call external code. [04:10.450 --> 04:14.890] It's finding that ExifTool parser that already exists that will call out to that external process. [04:14.890 --> 04:29.290] It's taking it, changing what command is going to be called based on the metadata inside that HTML file, and then if there is a JPEG or some other image file format that the ExifTool would process, then it runs that command. [04:29.290 --> 04:37.750] And then the other thing this does is that it then resets the ExifTool so it tries to conceal the fact that it changed the underlying parser at parse time. [04:37.750 --> 04:40.470] It makes it a do-it-half-do-what-went-wrong.