The vulnerability is a stored Cross-Site Scripting (XSS) issue in the public share page of gtsteffaniak/filebrowser. The root cause is the use of Go's text/template package instead of the more secure html/template package for rendering HTML. The text/template package does not perform any HTML escaping, allowing user-provided data to be rendered as raw HTML.
The analysis of the commits between the vulnerable version (v1.2.1-stable) and the patched version (v1.2.2-stable) revealed the fixing commit 82c0182c2286b01b55944b7c01608b85d015257b. This commit explicitly replaces the text/template import with html/template in backend/http/static.go and backend/http/httpRouter.go.
The function handleWithStaticData in backend/http/static.go is identified as the main vulnerable function. It is responsible for gathering the data to be rendered on the public share page, including user-controlled share metadata like title and description. This data was then passed to the insecure TemplateRenderer.Render function, which used text/template to generate the HTML, leading to the execution of any embedded JavaScript.
The patch addresses this by not only switching to html/template but also by correctly typing the data passed to the template using template.CSS and template.JS, ensuring that user-supplied content is safely rendered.