CVE-2015-10072 (published 2023-02-04T04:15Z)

A vulnerability classified as problematic was found in NREL api-umbrella-web 0.7.1. This vulnerability affects unknown code of the component Flash Message Handler. The manipulation leads to cross site scripting. The attack can be initiated remotely. Upgrading to version 0.8.0 is able to address this issue. The name of the patch is bcc0e922c61d30367678c8f17a435950969315cd. It is recommended to upgrade the affected component. The identifier of this vulnerability is VDB-220060.

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/NREL/api-umbrella-web
commit_details: repo_url: https://github.com/NREL/api-umbrella-web
author: Nick Muerdter
author_date: 2015-04-10 11:26:16-06:00
msg: Fix additional XSS issues in the flash messages in the admin.

A follow-up to XSS issues first identified in
f53a9fb87e10c457f0f3dd4f2af24d3b2f21b3ca.

I've gone through the rest of the admin, and I believe this covers
everything.

This commit is a bit bigger, since it fixes some issues with how our
test elasticsearch database was being setup for this web app (the
database didn't have our actual mappings loaded, so some fields weren't
being indexes as the proper types). These test fixes allow us to now
properly test the analytics by users list, where some additional XSS
tests have been added.
repository: repo_url: https://github.com/NREL/api-umbrella-web
repo_name: NREL/api-umbrella-web
description: See the https://github.com/NREL/api-umbrella repository instead.
repo_language: Ruby
owner: NREL
file_changes: filename: Gemfile
change_type: ModificationType.MODIFY
diff: @@ -245,6 +245,10 @@ group :development, :test do
 
   # For parsing URLs in tests.
   gem "addressable", "~> 2.3.6"
+
+  # For caching external web requests
+  gem "vcr", "~> 2.9.3", :require => false
+  gem "webmock", "~> 1.21.0", :require => false
 end
 
 group :development do

programming_language: Ruby
filename: Gemfile.lock
change_type: ModificationType.MODIFY
diff: @@ -122,6 +122,8 @@ GEM
       simplecov (>= 0.7)
       term-ansicolor (= 1.2.2)
       thor (= 0.18.1)
+    crack (0.4.2)
+      safe_yaml (~> 1.0.0)
     css_parser (1.3.5)
       addressable
     csv_builder (2.1.1)
@@ -475,6 +477,7 @@ GEM
       execjs (>= 0.3.0)
       json (>= 1.8.0)
     uuidtools (2.1.5)
+    vcr (2.9.3)
     virtus (1.0.4)
       axiom-types (~> 0.1)
       coercible (~> 1.0)
@@ -482,6 +485,9 @@ GEM
       equalizer (~> 0.0, >= 0.0.9)
     warden (1.2.3)
       rack (>= 1.0)
+    webmock (1.21.0)
+      addressable (>= 2.3.6)
+      crack (>= 0.3.2)
     websocket-driver (0.4.0)
     websocket-driver (0.4.0-java)
     xpath (2.0.0)
@@ -588,3 +594,5 @@ DEPENDENCIES
   turbo-sprockets-rails3 (= 0.3.13)
   uglifier (~> 2.5.0)
   uuidtools (~> 2.1.4)
+  vcr (~> 2.9.3)
+  webmock (~> 1.21.0)

programming_language: Python
filename: form_controller.js
change_type: ModificationType.MODIFY
diff: @@ -11,7 +11,7 @@ Admin.AdminGroupsFormController = Ember.ObjectController.extend(Admin.Save, {
     submit: function() {
       this.save({
         transitionToRoute: 'admin_groups',
-        message: 'Successfully saved the admin group "' + this.get('model.name') + '"',
+        message: 'Successfully saved the admin group "' + _.escape(this.get('model.name')) + '"',
       });
     },
   },

programming_language: JavaScript
filename: form_controller.js
change_type: ModificationType.MODIFY
diff: @@ -11,7 +11,7 @@ Admin.AdminsFormController = Ember.ObjectController.extend(Admin.Save, {
     submit: function() {
       this.save({
         transitionToRoute: 'admins',
-        message: 'Successfully saved the admin "' + this.get('model.username') + '"',
+        message: 'Successfully saved the admin "' + _.escape(this.get('model.username')) + '"',
       });
     },
   },

programming_language: JavaScript
filename: form_controller.js
change_type: ModificationType.MODIFY
diff: @@ -3,7 +3,7 @@ Admin.ApiScopesFormController = Ember.ObjectController.extend(Admin.Save, {
     submit: function() {
       this.save({
         transitionToRoute: 'api_scopes',
-        message: 'Successfully saved the API scope "' + this.get('model.name') + '"',
+        message: 'Successfully saved the API scope "' + _.escape(this.get('model.name')) + '"',
       });
     },
   },

programming_language: JavaScript
filename: form_controller.js
change_type: ModificationType.MODIFY
diff: @@ -20,9 +20,9 @@ Admin.ApiUsersFormController = Ember.ObjectController.extend(Admin.Save, {
       this.save({
         transitionToRoute: 'api_users',
         message: function(model) {
-          var message = 'Successfully saved the user "' + model.get('email') + '"';
+          var message = 'Successfully saved the user "' + _.escape(model.get('email')) + '"';
           if(model.get('apiKey')) {
-            message += '<br>API Key: <code>' + model.get('apiKey') + '</code>';
+            message += '<br>API Key: <code>' + _.escape(model.get('apiKey')) + '</code>';
           }
 
           return message;

programming_language: JavaScript
filename: apis_form_controller.js
change_type: ModificationType.MODIFY
diff: @@ -21,7 +21,7 @@ Admin.ApisFormController = Ember.ObjectController.extend(Admin.Save, {
     submit: function() {
       this.save({
         transitionToRoute: 'apis',
-        message: 'Successfully saved the "' + this.get('model.name') + '" API backend<br><strong>Note:</strong> Your changes are not yet live. <a href="/admin/#/config/publish">Publish Changes</a> to send your updates live.',
+        message: 'Successfully saved the "' + _.escape(this.get('model.name')) + '" API backend<br><strong>Note:</strong> Your changes are not yet live. <a href="/admin/#/config/publish">Publish Changes</a> to send your updates live.',
       });
     },
 

programming_language: JavaScript
filename: form_controller.js
change_type: ModificationType.MODIFY
diff: @@ -22,7 +22,7 @@ Admin.WebsiteBackendsFormController = Ember.ObjectController.extend(Admin.Save,
     submit: function() {
       this.save({
         transitionToRoute: 'website_backends',
-        message: 'Successfully saved the "' + this.get('model.frontendHost') + '" website backend<br><strong>Note:</strong> Your changes are not yet live. <a href="/admin/#/config/publish">Publish Changes</a> to send your updates live.',
+        message: 'Successfully saved the "' + _.escape(this.get('model.frontendHost')) + '" website backend<br><strong>Note:</strong> Your changes are not yet live. <a href="/admin/#/config/publish">Publish Changes</a> to send your updates live.',
       });
     },
 

programming_language: JavaScript
filename: elasticsearch_templates.yml
change_type: ModificationType.ADD
diff: @@ -0,0 +1,221 @@
+---
+http_interactions:
+- request:
+    method: get
+    uri: https://raw.githubusercontent.com/NREL/api-umbrella-router/master/config/elasticsearch_templates.json
+    body:
+      encoding: US-ASCII
+      string: ''
+    headers:
+      Accept:
+      - "*/*; q=0.5, application/xml"
+      Accept-Encoding:
+      - gzip, deflate
+      User-Agent:
+      - Ruby
+  response:
+    status:
+      code: 200
+      message: OK
+    headers:
+      Date:
+      - Fri, 10 Apr 2015 17:17:38 GMT
+      Server:
+      - Apache
+      Access-Control-Allow-Origin:
+      - https://render.githubusercontent.com
+      Content-Security-Policy:
+      - default-src 'none'
+      X-Xss-Protection:
+      - 1; mode=block
+      X-Frame-Options:
+      - deny
+      X-Content-Type-Options:
+      - nosniff
+      Strict-Transport-Security:
+      - max-age=31536000
+      Etag:
+      - '"d426630bd78408d97d4ae86d0d7a7c224849d203"'
+      Content-Type:
+      - text/plain; charset=utf-8
+      Cache-Control:
+      - max-age=300
+      Content-Length:
+      - '3937'
+      Accept-Ranges:
+      - bytes
+      Via:
+      - 1.1 varnish
+      X-Served-By:
+      - cache-mia1323-MIA
+      X-Cache:
+      - MISS
+      X-Cache-Hits:
+      - '0'
+      Vary:
+      - Authorization,Accept-Encoding
+      Expires:
+      - Fri, 10 Apr 2015 17:22:38 GMT
+      Source-Age:
+      - '0'
+    body:
+      encoding: ASCII-8BIT
+      string: |
+        [
+          {
+            "id": "api-umbrella-template",
+            "template": {
+              "template": "api-umbrella",
+              "mappings": {
+                "city": {
+                  "_all": {
+                    "enabled": false
+                  },
+                  "_timestamp": {
+                    "enabled": true,
+                    "path": "updated_at"
+                  },
+                  "properties": {
+                    "country": {
+                      "type": "string",
+                      "index": "not_analyzed"
+                    },
+                    "region": {
+                      "type": "string",
+                      "index": "not_analyzed"
+                    },
+                    "city": {
+                      "type": "string",
+                      "index": "not_analyzed"
+                    },
+                    "location": {
+                      "type": "geo_point",
+                      "lat_lon": true
+                    }
+                  }
+                }
+              }
+            }
+          },
+          {
+            "id": "api-umbrella-log-v1-template",
+            "template": {
+              "template": "api-umbrella-logs-v1-*",
+              "settings": {
+                "index": {
+                  "number_of_shards": 3
+                },
+                "analysis": {
+                  "analyzer": {
+                    "keyword_lowercase": {
+                      "type": "custom",
+                      "tokenizer": "keyword",
+                      "filter": ["lowercase"]
+                    },
+                    "path_hierarchy_lowercase": {
+                      "type": "custom",
+                      "tokenizer": "path_hierarchy",
+                      "filter": ["lowercase"]
+                    }
+                  }
+                }
+              },
+              "mappings": {
+                "log": {
+                  "_all": {
+                    "enabled": false
+                  },
+                  "_timestamp": {
+                    "enabled": true,
+                    "path": "request_at"
+                  },
+                  "date_detection": false,
+                  "numeric_detection": false,
+                  "dynamic_templates": [
+                    {
+                      "string_template": {
+                        "match": "*",
+                        "match_mapping_type": "string",
+                        "mapping": {
+                          "type": "string",
+                          "index": "analyzed",
+                          "analyzer": "keyword_lowercase"
+                        }
+                      }
+                    }
+                  ],
+                  "properties": {
+                    "api_key": {
+                      "type": "string",
+                      "index": "not_analyzed"
+                    },
+                    "user_id": {
+                      "type": "string",
+                      "index": "not_analyzed"
+                    },
+                    "request_at": {
+                      "type": "date"
+                    },
+                    "request_ip": {
+                      "type": "string",
+                      "index": "not_analyzed"
+                    },
+                    "request_ip_country": {
+                      "type": "string",
+                      "index": "not_analyzed"
+                    },
+                    "request_ip_region": {
+                      "type": "string",
+                      "index": "not_analyzed"
+                    },
+                    "request_ip_city": {
+                      "type": "string",
+                      "index": "not_analyzed"
+                    },
+                    "request_path_hierarchy": {
+                      "type": "string",
+                      "analyzer": "path_hierarchy_lowercase"
+                    },
+                    "request_size": {
+                      "type": "integer"
+                    },
+                    "response_status": {
+                      "type": "short"
+                    },
+                    "response_age": {
+                      "type": "integer"
+                    },
+                    "response_content_length": {
+                      "type": "integer"
+                    },
+                    "response_size": {
+                      "type": "integer"
+                    },
+                    "response_time": {
+                      "type": "integer"
+                    },
+                    "backend_response_time": {
+                      "type": "integer"
+                    },
+                    "proxy_overhead": {
+                      "type": "integer"
+                    },
+                    "internal_response_time": {
+                      "type": "float"
+                    },
+                    "internal_gatekeeper_time": {
+                      "type": "float"
+                    },
+                    "request_ip_location": {
+                      "type": "geo_point",
+                      "lat_lon": true
+                    }
+                  }
+                }
+              }
+            }
+          }
+        ]
+    http_version: 
+  recorded_at: Fri, 10 Apr 2015 07:01:09 GMT
+recorded_with: VCR 2.9.3

programming_language: Python
filename: stats_controller_spec.rb
change_type: ModificationType.MODIFY
diff: @@ -4,10 +4,11 @@ describe Admin::StatsController do
   login_admin
 
   before(:each) do
-    begin
-      LogItem.gateway.client.indices.delete :index => LogItem.index_name
-    rescue Elasticsearch::Transport::Transport::Errors::NotFound # rubocop:disable Lint/HandleExceptions
-    end
+    LogItem.gateway.client.delete_by_query :index => LogItem.index_name, :body => {
+      :query => {
+        :match_all => {},
+      },
+    }
   end
 
   describe "GET logs" do

programming_language: Ruby
filename: api_users.rb
change_type: ModificationType.MODIFY
diff: @@ -13,6 +13,7 @@ FactoryGirl.define do
     end
 
     factory :xss_api_user do
+      email 'a@"><script class="xss-test">alert("Hello first_name");</script>.com'
       first_name '"><script class="xss-test">alert("Hello first_name");</script>'
       last_name '"><script class="xss-test">alert("Hello last_name");</script>'
       use_description '"><script class="xss-test">alert("Hello use_description");</script>'

programming_language: Ruby
filename: log_items.rb
change_type: ModificationType.MODIFY
diff: @@ -3,13 +3,14 @@ require "elasticsearch/persistence/model"
 class LogItem
   include Elasticsearch::Persistence::Model
 
-  index_name "api-umbrella-logs-2015-01"
+  index_name "api-umbrella-logs-write-2015-01"
+  document_type "log"
 
   attribute :api_key, String
-  attribute :backend_response_time, Float
+  attribute :backend_response_time, Integer
   attribute :internal_gatekeeper_time, Float
   attribute :internal_response_time, Float
-  attribute :proxy_overhead, Float
+  attribute :proxy_overhead, Integer
   attribute :request_accept_encoding, String
   attribute :request_at, Time
   attribute :request_hierarchy, Array
@@ -33,7 +34,7 @@ class LogItem
   attribute :response_server, String
   attribute :response_size, Integer
   attribute :response_status, Integer
-  attribute :response_time, Float
+  attribute :response_time, Integer
   attribute :user_email, String
   attribute :user_id, String
   attribute :user_registration_source, String

programming_language: Ruby
filename: api_users_spec.rb
change_type: ModificationType.MODIFY
diff: @@ -13,22 +13,32 @@ describe "api users form", :js => true do
       visit "/admin/#/api_users"
 
       page.should have_content(@user.email)
-      page.should_not have_selector(".xss-test", :visible => :all)
       page.should have_content(@user.first_name)
       page.should have_content(@user.last_name)
       page.should have_content(@user.use_description)
       page.should have_content(@user.registration_source)
+      page.should_not have_selector(".xss-test", :visible => :all)
     end
 
     it "escapes html entities in the form" do
       visit "/admin/#/api_users/#{@user.id}/edit"
 
       find_field("E-mail").value.should eql(@user.email)
-      page.should_not have_selector(".xss-test", :visible => :all)
       find_field("First Name").value.should eql(@user.first_name)
       find_field("Last Name").value.should eql(@user.last_name)
       find_field("Purpose").value.should eql(@user.use_description)
       page.should have_content(@user.registration_source)
+      page.should_not have_selector(".xss-test", :visible => :all)
+    end
+
+    it "escapes html entities in flash confirmation message" do
+      visit "/admin/#/api_users/#{@user.id}/edit"
+
+      fill_in "Last Name", :with => "Doe"
+      click_button("Save")
+
+      page.should have_content("Successfully saved the user \"#{@user.email}\"")
+      page.should_not have_selector(".xss-test", :visible => :all)
     end
   end
 

programming_language: Ruby
filename: stats_logs_spec.rb
change_type: ModificationType.MODIFY
diff: @@ -1,14 +1,15 @@
 require "spec_helper"
 require "addressable/uri"
 
-describe "apis", :js => true do
+describe "analytics filter logs", :js => true do
   login_admin
 
   before(:each) do
-    begin
-      LogItem.gateway.client.indices.delete :index => LogItem.index_name
-    rescue Elasticsearch::Transport::Transport::Errors::NotFound # rubocop:disable Lint/HandleExceptions
-    end
+    LogItem.gateway.client.delete_by_query :index => LogItem.index_name, :body => {
+      :query => {
+        :match_all => {},
+      },
+    }
   end
 
   describe "xss" do
@@ -19,7 +20,6 @@ describe "apis", :js => true do
       visit "/admin/#/stats/logs/tz=America%2FDenver&search=&start_at=2015-01-12&end_at=2015-01-18&interval=day"
 
       page.should have_content(log.request_method)
-      page.should_not have_selector(".xss-test", :visible => :all)
       page.should have_content(log.request_accept_encoding)
       page.should have_content(log.request_ip_city)
       page.should have_content(log.request_ip_country)
@@ -27,6 +27,7 @@ describe "apis", :js => true do
       page.should have_content(log.request_user_agent)
       page.should have_content(log.response_content_type)
       page.should have_content(log.user_email)
+      page.should_not have_selector(".xss-test", :visible => :all)
     end
   end
 

programming_language: Ruby
filename: stats_users_spec.rb
change_type: ModificationType.ADD
diff: @@ -0,0 +1,29 @@
+require "spec_helper"
+
+describe "analytics by users", :js => true do
+  login_admin
+
+  before(:each) do
+    LogItem.gateway.client.delete_by_query :index => LogItem.index_name, :body => {
+      :query => {
+        :match_all => {},
+      },
+    }
+  end
+
+  describe "xss" do
+    it "escapes html entities in the table" do
+      user = FactoryGirl.create(:xss_api_user)
+      FactoryGirl.create(:xss_log_item, :request_at => Time.parse("2015-01-16T06:06:28.816Z"), :api_key => user.api_key, :user_id => user.id, :user_email => user.email, :user_registration_source => user.registration_source)
+      LogItem.gateway.refresh_index!
+
+      visit "/admin/#/stats/users/tz=America%2FDenver&search=&start_at=2015-01-12&end_at=2015-01-18&interval=day"
+
+      page.should have_content(user.email)
+      page.should have_content(user.first_name)
+      page.should have_content(user.last_name)
+      page.should have_content(user.use_description)
+      page.should_not have_selector(".xss-test", :visible => :all)
+    end
+  end
+end

programming_language: Ruby
filename: elasticsearch.rb
change_type: ModificationType.ADD
diff: @@ -0,0 +1,32 @@
+require "support/vcr"
+
+client = Elasticsearch::Client.new
+
+# Fetch the elasticsearch template file from the router project. Cache it with
+# VCR, but periodically re-record it to make sure we stay up-to-date.
+VCR.use_cassette("elasticsearch_templates", :re_record_interval => 1.day) do
+  templates = MultiJson.load(RestClient.get("https://raw.githubusercontent.com/NREL/api-umbrella-router/master/config/elasticsearch_templates.json"))
+  templates.each do |template|
+    client.indices.put_template({
+      :name => template["id"],
+      :body => template["template"],
+    })
+  end
+end
+
+# For simplicity sake, we're assuming our tests only deal with the 2015-01
+# index currently. First delete any existing indexes.
+%w(api-umbrella-logs-v1-2015-01 api-umbrella-logs-2015-01 api-umbrella-logs-write-2015-01).each do |index_name|
+  begin
+    client.indices.delete :index => index_name
+  rescue Elasticsearch::Transport::Transport::Errors::NotFound # rubocop:disable Lint/HandleExceptions
+  end
+end
+
+# Create the index with proper aliases setup.
+client.indices.create(:index => "api-umbrella-logs-v1-2015-01", :body => {
+  :aliases => {
+    "api-umbrella-logs-2015-01" => {},
+    "api-umbrella-logs-write-2015-01" => {},
+  },
+})

programming_language: Ruby
filename: vcr.rb
change_type: ModificationType.ADD
diff: @@ -0,0 +1,20 @@
+require "vcr"
+
+VCR.configure do |c|
+  c.cassette_library_dir = "#{::Rails.root}/spec/cassettes"
+  c.hook_into :webmock
+  c.default_cassette_options = {
+    :record => :new_episodes,
+
+    # Store gzip responses as plaintext in the YAML.
+    :decode_compressed_response => true,
+
+    # Allow the same response to be used multiple times in a single test.
+    :allow_playback_repeats => true,
+  }
+
+  # Allow localhost connections for ElasticSearch.
+  c.ignore_localhost = true
+
+  c.configure_rspec_metadata!
+end

programming_language: Ruby