CVE-2022-4590 (published 2022-12-17T19:15Z)

A vulnerability was found in mschaef toto up to 1.4.20. It has been classified as problematic. This affects an unknown part of the component Todo List Handler. The manipulation leads to cross site scripting. It is possible to initiate the attack remotely. Upgrading to version 1.4.21 is able to address this issue. The name of the patch is fdc825ac5249f40683377e8a526a06cdc6870125. It is recommended to upgrade the affected component. The identifier VDB-216177 was assigned to this vulnerability.

CVSS v3 base score: 6.1, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N)

Weakness information:
cwe_id: CWE-79
cwe_name: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
description: The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
extended_description: 
            Cross-site scripting (XSS) vulnerabilities occur when:
            
               Untrusted data enters a web application, typically from a web request.
               The web application dynamically generates a web page that contains this untrusted data.
               During page generation, the application does not prevent the data from containing content that is executable by a web browser, such as JavaScript, HTML tags, HTML attributes, mouse events, Flash, ActiveX, etc.
               A victim visits the generated web page through a web browser, which contains malicious script that was injected using the untrusted data.
               Since the script comes from a web page that was sent by the web server, the victim's web browser executes the malicious script in the context of the web server's domain.
               This effectively violates the intention of the web browser's same-origin policy, which states that scripts in one domain should not be able to access resources or run code in a different domain.
            
            There are three main kinds of XSS:
            
               
                  Type 1: Reflected XSS (or Non-Persistent) - 
         			The server reads data directly from the HTTP request and reflects it back in the HTTP response. Reflected XSS exploits occur when an attacker causes a victim to supply dangerous content to a vulnerable web application, which is then reflected back to the victim and executed by the web browser. The most common mechanism for delivering malicious content is to include it as a parameter in a URL that is posted publicly or e-mailed directly to the victim. URLs constructed in this manner constitute the core of many phishing schemes, whereby an attacker convinces a victim to visit a URL that refers to a vulnerable site. After the site reflects the attacker's content back to the victim, the content is executed by the victim's browser.
               
                  Type 2: Stored XSS (or Persistent) - 
               The application stores dangerous data in a database, message forum, visitor log, or other trusted data store. At a later time, the dangerous data is subsequently read back into the application and included in dynamic content. From an attacker's perspective, the optimal place to inject malicious content is in an area that is displayed to either many users or particularly interesting users. Interesting users typically have elevated privileges in the application or interact with sensitive data that is valuable to the attacker. If one of these users executes malicious content, the attacker may be able to perform privileged operations on behalf of the user or gain access to sensitive data belonging to the user. For example, the attacker might inject XSS into a log message, which might not be handled properly when an administrator views the logs.
            
               
                  Type 0: DOM-Based XSS - 
               In DOM-based XSS, the client performs the injection of XSS into the page; in the other types, the server performs the injection. DOM-based XSS generally involves server-controlled, trusted script that is sent to the client, such as Javascript that performs sanity checks on a form before the user submits it. If the server-supplied script processes user-supplied data and then injects it back into the web page (such as with dynamic HTML), then DOM-based XSS is possible.
            
            
            Once the malicious script is injected, the attacker can perform a variety of malicious activities. The attacker could transfer private information, such as cookies that may include session information, from the victim's machine to the attacker. The attacker could send malicious requests to a web site on behalf of the victim, which could be especially dangerous to the site if the victim has administrator privileges to manage that site. Phishing attacks could be used to emulate trusted web sites and trick the victim into entering a password, allowing the attacker to compromise the victim's account on that web site. Finally, the script could exploit a vulnerability in the web browser itself possibly taking over the victim's machine, sometimes referred to as "drive-by hacking."
            In many cases, the attack can be launched without the victim even being aware of it. Even with careful users, attackers frequently use a variety of methods to encode the malicious portion of the attack, such as URL encoding or Unicode, so the request looks less suspicious.
         
         

Fix information:
repo_url: https://github.com/mschaef/toto
commit_details: repo_url: https://github.com/mschaef/toto
author: Mike Schaeffer
author_date: 2022-10-25 22:18:57-04:00
msg: Escape user entered HTML in several different locations throughout the UI, to help mitigate against XSS attacks.
repository: repo_url: https://github.com/mschaef/toto
repo_name: mschaef/toto
description: The toto to-do list manager.
repo_language: Clojure
owner: mschaef
file_changes: filename: todo_list.clj
change_type: ModificationType.MODIFY
diff: @@ -28,8 +28,8 @@
         toto.view.query
         toto.view.page)
   (:require [clojure.tools.logging :as log]
-            [hiccup.form :as form]
-            [hiccup.util :as util]
+            [hiccup.form :as hiccup-form]
+            [hiccup.util :as hiccup-util]
             [toto.data.data :as data]
             [toto.view.auth :as auth]
             [toto.view.request-date :as request-date]
@@ -42,8 +42,8 @@
 (defn- format-date [ date ]
   (.format pill-date-format date))
 
-(defn ensure-string-breakpoints [ s n ]
-  (clojure.string/join html-breakpoint (partition-string s n)))
+(defn- ensure-string-breakpoints [ s n ]
+  (clojure.string/join html-breakpoint (map hiccup-util/escape-html (partition-string s n))))
 
 (defn- ensure-string-breaks [ string at ]
   (clojure.string/replace string at (str at html-breakpoint)))
@@ -54,7 +54,7 @@
                   ":"
                   (if-let [authority (.getAuthority url)]
                     (str "//" authority)))]
-    (-> (util/escape-html
+    (-> (hiccup-util/escape-html
          (str base
               (string-leftmost (.getPath url)
                                (max 0 (- (- target-length 3) (.length base)))
@@ -99,22 +99,23 @@
 
 (defn- render-new-item-form [ list-id editing-item? ]
   (let [ sublists (data/get-view-sublists (auth/current-user-id) list-id)]
-    (form/form-to
+    (hiccup-form/form-to
      {:class "new-item-form"}
      [:post (shref "/list/" list-id)]
      (if (= (count sublists) 0)
-       (form/hidden-field "item-list-id" list-id)
+       (hiccup-form/hidden-field "item-list-id" list-id)
        [:select {:id "item-list-id" :name "item-list-id"}
-        (form/select-options (map (fn [ sublist ]
-                                    [ (:desc sublist) (:sublist_id sublist)])
+        (hiccup-form/select-options (map (fn [ sublist ]
+                                           [(hiccup-util/escape-html (:desc sublist))
+                                            (:sublist_id sublist)])
                                   sublists))])
-     (form/text-field (cond-> {:maxlength "1024"
+     (hiccup-form/text-field (cond-> {:maxlength "1024"
                                :placeholder "New Item Description"
                                :autocomplete "off"
                                :onkeydown "window._toto.onNewItemInputKeydown(event)"}
                         (not editing-item?) (assoc "autofocus" "on"))
                       "item-description")
-     (form/hidden-field "item-priority" "0")
+     (hiccup-form/hidden-field "item-priority" "0")
      [:button.high-priority-submit {:type "button"
                                     :onclick "window._toto.submitHighPriority()"}
       img-star-yellow])))
@@ -200,14 +201,15 @@
                                              ", snoozed: " (format-date snoozed-until)))])
            (when (not (= created-by-id (auth/current-user-id)))
              [:span.pill { :title created-by-email }
-              created-by-name])]))]
+              (hiccup-util/escape-html
+               created-by-name)])]))]
      [:div.item-control.priority.right
       (render-item-priority-control item-id priority writable?)]
      (item-drag-handle "right" item-info)]))
 
 (defn- render-query-select [ id current-value ]
   [:select { :id id :name id :onchange "this.form.submit()"}
-   (form/select-options [[ "-" "-"]
+   (hiccup-form/select-options [[ "-" "-"]
                          ["1d" "1"]
                          ["7d" "7"]
                          ["30d" "30"]
@@ -218,7 +220,7 @@
 
 (defn- render-todo-list-query-settings [ list-id completed-within-days snoozed-for-days ]
   [:div.query-settings
-   (form/form-to { :class "embedded "} [:get (shref "/list/" list-id)]
+   (hiccup-form/form-to { :class "embedded "} [:get (shref "/list/" list-id)]
                  [:div.control-segment
                   [:a {:href (shref "/list/" list-id {:view "completions"})}
                    "[recently completed]"]]
@@ -237,7 +239,7 @@
 
 (defn- render-todo-list-completion-query-settings [ list-id completed-within-days ]
   [:div.query-settings
-   (form/form-to { :class "embedded "} [:get (shref "/list/" list-id "/completions")]
+   (hiccup-form/form-to { :class "embedded "} [:get (shref "/list/" list-id "/completions")]
                  [:div.control-segment
                   [:a {:href (shref "/list/" list-id "/details")}
                    "[list details]"]]
@@ -306,7 +308,8 @@
        [:h2
         [:a
          {:href (shref "/list/" (:sublist_id sublist-details))}
-         (:desc sublist-details)]]
+         (hiccup-util/escape-html
+          (:desc sublist-details))]]
        items])))
 
 (defn- render-todo-list-view [ list-id edit-item-id writable? completed-within-days snoozed-for-days ]
@@ -433,11 +436,13 @@
 
 (defn- render-list-select [ id excluded-list-id ]
   [:select { :id id :name id }
-   (form/select-options (map (fn [ list-info ]
-                               [ (:desc list-info) (:todo_list_id list-info)])
-                             (remove
-                              #(= excluded-list-id (:todo_list_id %))
-                              (data/get-todo-lists-by-user (auth/current-user-id)))))])
+   (hiccup-form/select-options
+    (map (fn [ list-info ]
+           [(hiccup-util/escape-html (:desc list-info))
+            (:todo_list_id list-info)])
+         (remove
+          #(= excluded-list-id (:todo_list_id %))
+          (data/get-todo-lists-by-user (auth/current-user-id)))))])
 
 (defn render-update-from-modal [ params list-id ]
   (render-modal

programming_language: Markdown
filename: todo_list_manager.clj
change_type: ModificationType.MODIFY
diff: @@ -28,7 +28,8 @@
         toto.view.query
         toto.view.page)
   (:require [clojure.tools.logging :as log]
-            [hiccup.form :as form]
+            [hiccup.form :as hiccup-form]
+            [hiccup.util :as hiccup-util]
             [toto.data.data :as data]
             [toto.view.auth :as auth]
             [toto.todo.sidebar-view :as sidebar-view]))
@@ -50,15 +51,15 @@
     (list-priority-button list-id 0 img-arrow-blue)))
 
 (defn render-new-list-form [ ]
-  (form/form-to
+  (hiccup-form/form-to
    {:class "new-item-form"}
    [:post (shref "/list")]
-   (form/text-field {:maxlength "32"
+   (hiccup-form/text-field {:maxlength "32"
                      :placeholder "New List Name"
                      :autofocus "autofocus"}
                     "list-description")
    [:div
-    (form/check-box "is-view" false "Y")
+    (hiccup-form/check-box "is-view" false "Y")
     [:label {:for "is-view"} "View"]]))
 
 (defn render-list-list-page []
@@ -89,10 +90,10 @@
 (defn- render-sort-list-panel [ list-id ]
   [:div.config-panel
    [:h1 "Sort List"]
-   (form/form-to {} [:post (shref "/list/" list-id "/sort")]
+   (hiccup-form/form-to {} [:post (shref "/list/" list-id "/sort")]
     [:input {:type "submit" :value "Sort By"}]
     [:select {:id "sort-by" :name "sort-by"}
-     (form/select-options [["Description" "desc"]
+     (hiccup-form/select-options [["Description" "desc"]
                            ["Created Date" "created-on"]
                            ["Updated Date" "updated-on"]
                            ["Snoozed Until" "snoozed-until"]])])])
@@ -119,7 +120,7 @@
      [:div.config-panel
       [:h1  "List Permissions:"]
       [:div
-       (form/check-box "is-public" (:is_public list-details))
+       (hiccup-form/check-box "is-public" (:is_public list-details))
        [:label {:for "is-public"} "List publically visible?"]]]
      [:div.config-panel
       [:h1  "List Owners:"]
@@ -131,8 +132,8 @@
                    (if (= (auth/current-user-id) user-id)
                      [:div.self-owner
                       "&nbsp;"
-                      (form/hidden-field user-parameter-name "on")]
-                     (form/check-box user-parameter-name (in? list-owners user-id)))
+                      (hiccup-form/hidden-field user-parameter-name "on")]
+                     (hiccup-form/check-box user-parameter-name (in? list-owners user-id)))
                    [:label {:for user-parameter-name}
                     user-email-addr
                     (when (= (auth/current-user-id) user-id)
@@ -158,9 +159,10 @@
       (map (fn [ todo-list ]
              (let [ list-id (:todo_list_id todo-list) ]
                [:div
-                (form/check-box (str "list_" list-id)
-                                (in? view-sublist-ids list-id))
-                (:desc todo-list)]))
+                (hiccup-form/check-box (str "list_" list-id)
+                                       (in? view-sublist-ids list-id))
+                (hiccup-util/escape-html
+                 (:desc todo-list))]))
            (remove #(:is_view %) todo-lists))]]))
 
 (defn render-todo-list-details-page [ list-id min-list-priority & { :keys [ error-message ]}]
@@ -169,19 +171,19 @@
         is-view (:is_view list-details)
         list-type (if is-view "View" "List")]
     (render-page
-     {:title (str list-type " Details: " list-name)
+     {:title (str list-type " Details: " (hiccup-util/escape-html list-name))
       :sidebar (sidebar-view/render-sidebar-list-list list-id min-list-priority 0)}
      (scroll-column
       'todo-list-details-column
       [:h3
        [:a { :href (str "/list/" list-id ) } img-back-arrow]
-       "List Details: " list-name]
-      (form/form-to
+       "List Details: " (hiccup-util/escape-html list-name)]
+      (hiccup-form/form-to
        {:class "details"}
        [:post (shref "/list/" list-id "/details")]
        [:div.config-panel
         [:h1 (str list-type " Name:")]
-        (form/text-field { :maxlength "32" } "list-name" list-name)]
+        (hiccup-form/text-field { :maxlength "32" } "list-name" list-name)]
        (if is-view
          (render-todo-list-view-editor list-id)
          (render-todo-list-permissions list-id error-message))

programming_language: Markdown
filename: page.clj
change_type: ModificationType.MODIFY
diff: @@ -27,8 +27,9 @@
         toto.view.query
         toto.view.components)
   (:require [clojure.tools.logging :as log]
-            [hiccup.page :as page]
-            [hiccup.form :as form]
+            [hiccup.page :as hiccup-page]
+            [hiccup.form :as hiccup-form]
+            [hiccup.util :as hiccup-util]
             [toto.view.auth :as auth]))
 
 (defn session-controls []
@@ -54,7 +55,7 @@
       [:div.cancel
        [:a {:href escape-url} img-window-close]]
       (if-let [ form-post-to (:form-post-to attrs)]
-        (form/form-to [:post form-post-to] contents)
+        (hiccup-form/form-to [:post form-post-to] contents)
         contents)]]))
 
 (defn- render-support-modal [ ]
@@ -64,12 +65,12 @@
       :form-post-to "/support-message"}
      [:div.config-panel
       [:h1 "Contact Information"]
-      (form/text-field {:maxlength "128"
+      (hiccup-form/text-field {:maxlength "128"
                         :placeholder "Full Name"
                         :autocomplete "off"
                         :autofocus "on"}
                        "full-name")
-      (form/text-field (cond-> {:maxlength "128"
+      (hiccup-form/text-field (cond-> {:maxlength "128"
                                 :placeholder "E-Mail Address"
                                 :value user-identity}
                          user-identity (assoc :readonly "readonly"))
@@ -77,12 +78,12 @@
      (render-verify-question)
      [:div.config-panel
       [:h1 "Message"]
-      (form/text-area {:maxlength "4096"
+      (hiccup-form/text-area {:maxlength "4096"
                        :rows "12"
                        :cols "64"
                        :autocomplete "off"}
                       "message-text")]
-     (form/hidden-field "current-uri" (shref))
+     (hiccup-form/hidden-field "current-uri" (shref))
      [:input {:type "submit" :value "Send Message"}])))
 
 (defn contact-support-button [ ]
@@ -95,10 +96,10 @@
            :content "width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0"}]
    [:title (when *dev-mode* "DEV - ") (:name (:app *config*)) (when title (str " - " title))]
    [:link { :rel "shortcut icon" :href (resource "favicon.ico")}]
-   (page/include-css (resource "toto.css")
+   (hiccup-page/include-css (resource "toto.css")
                      (resource "font-awesome.min.css"))
    [:script {:type "module" :src (resource "toto.js")}]
-   (page/include-js (resource "DragDropTouch.js"))])
+   (hiccup-page/include-js (resource "DragDropTouch.js"))])
 
 (defn- render-header [ page-title show-menu? ]
   (let [ username (auth/current-identity)]
@@ -107,7 +108,7 @@
        [:span.toggle-menu img-show-list "&nbsp;"])
      [:span.app-name
       [:a { :href "/" } (:name (:app *config*))] " - "]
-     page-title
+     (hiccup-util/escape-html page-title)
      (when *dev-mode*
        [:span.pill.dev "DEV"])
      (session-controls)]))
@@ -149,7 +150,7 @@
       contents]]))
 
 (defn render-page [ attrs & contents]
-  (page/html5
+  (hiccup-page/html5
    [:html
     (render-standard-header (:title attrs))
     (render-page-body attrs contents)]))

programming_language: Markdown