start	end	text
4850	9710	Apache TCA is an open source project hosted by the Apache Software Foundation.
9710	10770	It's been around for a while.
10770	14310	It is designed as the Babelfish for file format processing.
14310	17830	It allows just an API for putting in lots of different file types.
17830	24050	This is often a parser suite that is used behind the scenes and often people don't even know they're using it.
24050	33390	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.
33390	37010	Just to give a sense of what TCA can do, I will show you our app.
37010	43430	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.
43430	46530	It's a docx file, but it has an embedded zip file in it.
46550	49130	And inside that embedded zip file are further zip files.
49130	53810	So it's effectively a nested set of zip files inside of zip files inside of zip files.
53810	58190	Lots of people know that you can have embedded files, zip files have embedded files, and so on.
58530	62670	But one of the really fun things is you can often put embedded files in lots of other formats.
62670	68610	And that's part of the richness of TCA is that it parses through those embedded files and will give you that extracted content.
68610	72590	Let's look at what I view as the most important view of this.
72590	85030	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.
85030	94350	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.
94490	97610	And then we see that we have some content in here.
97670	101010	And remember, we saw those text files with embed1 and embed2.
101210	105390	In embed3, we actually have some real text in that text file.
105690	113450	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.
113490	117850	And then that's all at the root level, effectively, of that docx file.
117850	122610	So all of the embedded files with their metadata content is extracted here.
122610	126070	And then from this, applications could make that searchable.
126070	128470	They could look for specific keywords.
128470	135270	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.
135270	138470	Lots of different uses for why people would want text out of this.
138570	145730	So for Tika, the main vulnerabilities that I focus on were path traversal and then the other one's command injection.
145730	147630	The file that triggers this is a zip file.
147810	157490	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.
157490	166970	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.
166970	169470	And then it becomes active here.
169470	172650	And that gives us the ability to traverse out of that target directory.
172650	178530	Part of the challenge for this is that the CRS has to figure out what's going on with this third-party library.
178530	188330	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.
188330	191610	So simply moving this further up here would have solved the problem.
191610	194470	The next one is the favorite of what I've done.
194470	197030	It's going to be a doozy to fix.
197030	206350	So the way this works is, this is a command injection vulnerability, which means that the user controls what text goes into the command.
206350	214250	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.
214410	223010	This CPV hijacks the existing external parser that Tika already has, and then just modifies the command based on user data.
223010	228510	So the target file is an HTML file with an embedded JPEG file.
228790	237810	And if the HTML file has a metadata field called ExifToolPath, then this will configure the ExifTool, which sounds super awesome.
237810	240170	Now we can run Exif on the embedded JPEG file, right?
240170	250450	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.
250450	254890	It's finding that ExifTool parser that already exists that will call out to that external process.
254890	269290	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.
269290	277750	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.
277750	280470	It makes it a do-it-half-do-what-went-wrong.
