The vulnerability is a stored Cross-Site Scripting (XSS) issue within the _genai/_evals_visualization component of the Google Cloud Vertex AI SDK. The root cause is the unsafe embedding of model evaluation results or dataset JSON data directly into HTML templates that are rendered in Jupyter or Colab environments.
The analysis of the patch commit 8a00d43dbd24e95dbab6ea32c63ce0a5a1849480 reveals that three internal functions, _get_evaluation_html, _get_comparison_html, and _get_inference_html in the vertexai/_genai/_evals_visualization.py file were responsible for this vulnerability.
Before the patch, these functions used Python's f-strings to inject a JSON string directly into a <script> tag within the generated HTML. For example: <script>var vizData_vertex_eval_sdk = {eval_result_json};</script>. An attacker could craft a malicious payload within the eval_result_json or dataframe_json (e.g., by including script tags in the data) which would then be executed in the context of the victim's browser session.
The patch addresses this by Base64 encoding the JSON data on the server-side using a new _encode_to_base64 function and then decoding it on the client-side within the JavaScript using atob() and TextDecoder. This ensures that the data is treated as a string and not as executable code by the browser, effectively neutralizing the XSS vector.
The identified vulnerable functions are the ones that construct the HTML and were modified to include this encoding/decoding mechanism. During exploitation, a call to display an evaluation result, comparison, or inference data would lead to one of these functions being called, which would then render the malicious script.