#0402
A web application dynamically loads HTML templates by name. The template loader concatenates a base templates directory with the user-supplied template name.
No path sanitisation is applied. An attacker passes ../../config/database.yml as the template name.
The server reads and returns the database credentials file instead of a template.
Template loaders are a common vector for LFI. Exposing arbitrary file reads via template names can leak credentials, private keys, and application source code.
loadTemplate so it rejects template names that escape the templates directory.'Invalid template path' when traversal is detected.loadTemplate('/app/templates', '../../config/db.yml')// → throws Error('Invalid template path')
loadTemplate('/app/templates', 'email/welcome.html')// → returns '/app/templates/email/welcome.html'