You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2025/11/14 20:58:34 UTC

(spark) branch branch-4.0 updated: [SPARK-53337][UI] XSS: Ensure the application name in historypage get escaped

This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new f9fc4dbdabf4 [SPARK-53337][UI] XSS: Ensure the application name in historypage get escaped
f9fc4dbdabf4 is described below

commit f9fc4dbdabf4aac1cf6396a0fdd8a62e103bafef
Author: ibenchhida <ib...@linagora.com>
AuthorDate: Fri Nov 14 12:57:59 2025 -0800

    [SPARK-53337][UI] XSS: Ensure the application name in historypage get escaped
    
    ### What changes were proposed in this pull request?
    In history Server main dashboard, the application name need to be escaped.
    
    ### Why are the changes needed?
    Not escaped app name could lead to XSS
    Exemple:
    cat << EOF > script.py
    from pyspark.sql import SparkSession
    if __name__ == "__main__":
       spark = SparkSession \
           .builder \
           .appName("<img src=x onerror=alert(/jedi master/)><script>alert(/Hello there/)</script>") \
           .getOrCreate()
       print(spark.range(1000 * 1000 * 1000).count())
       spark.stop()
    EOF
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    Tests already exist, it was manually tested.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    No
    
    Closes #52851 from Chhida/Fix_issue_master.
    
    Authored-by: ibenchhida <ib...@linagora.com>
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
    (cherry picked from commit e739b7d349dbd41b78d49bc8086cab63db057e14)
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 .../main/resources/org/apache/spark/ui/static/historypage.js | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/core/src/main/resources/org/apache/spark/ui/static/historypage.js b/core/src/main/resources/org/apache/spark/ui/static/historypage.js
index 8961140a4019..d847efa2f7ff 100644
--- a/core/src/main/resources/org/apache/spark/ui/static/historypage.js
+++ b/core/src/main/resources/org/apache/spark/ui/static/historypage.js
@@ -27,6 +27,16 @@ var appLimit = -1;
 function setAppLimit(val) {
   appLimit = val;
 }
+/* escape XSS  */
+function escapeHtml(text) {
+  if (typeof text !== 'string') return text;
+  return text
+    .replace(/&/g, "&amp;")
+    .replace(/</g, "&lt;")
+    .replace(/>/g, "&gt;")
+    .replace(/"/g, "&quot;")
+    .replace(/'/g, "&#039;");
+}
 /* eslint-enable no-unused-vars*/
 
 function makeIdNumeric(id) {
@@ -151,7 +161,7 @@ $(document).ready(function() {
         attempt["durationMillisec"] = attempt["duration"];
         attempt["duration"] = formatDuration(attempt["duration"]);
         attempt["id"] = id;
-        attempt["name"] = name;
+        attempt["name"] = escapeHtml(name);
         attempt["version"] = version;
         attempt["attemptUrl"] = uiRoot + "/history/" + id + "/" +
           (attempt.hasOwnProperty("attemptId") ? attempt["attemptId"] + "/" : "") + "jobs/";


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org