The vulnerability is a classic stored Cross-Site Scripting (XSS) issue within the HTML reports generated by Memray. The root cause is the failure to escape the command line of the profiled process, which is included in the report's metadata section. The fixing commit ba6e4e2e9930f9641bed7adfdf43c8e2545ce249 clearly shows the patch in the Jinja2 template src/memray/reporters/templates/base.html. The change from {{ metadata.command_line }} to {{ metadata.command_line|e }} adds the necessary HTML escaping.
The function responsible for orchestrating the report generation is render_report, located in the memray.reporters.templates module. This is confirmed by the new test case test_html_report_escaping added in tests/unit/test_templates.py, which directly calls render_report to test the fix. When an exploit occurs (i.e., a malicious report is generated), the render_report function would be present in the execution stack as it is responsible for processing the untrusted data (the command line) and passing it to the vulnerable template. Therefore, render_report is the key function to monitor for this vulnerability.