The vulnerability is a classic path traversal issue affecting multiple template loaders in the handlebars.java library. The root cause is the lack of input validation on the location parameter passed to the getResource method in FileTemplateLoader, ClassPathTemplateLoader, and ServletContextTemplateLoader. An attacker could provide a crafted path with traversal sequences (../) to read arbitrary files from the filesystem or the application's classpath.
The patch addresses this by introducing strict path validation. For FileTemplateLoader, it canonicalizes the base directory and the requested file path, ensuring the file's path starts with the base directory's path. For classpath-based loaders (ClassPathTemplateLoader and ServletContextTemplateLoader), a new method, classpathResource, was added to the parent URLTemplateLoader. This method normalizes the path and verifies that it remains within the configured base prefix, throwing an exception if an escape attempt is detected. The getResource methods in the subclasses were updated to call this new validation method.
By identifying the changes in the getResource methods of these three loader classes, we can pinpoint the exact functions that, when called with malicious input, would trigger the vulnerability. These functions are the runtime indicators of exploitation.