CVE-2023-43640 (published 2023-09-22T18:15Z)

TaxonWorks is a web-based workbench designed for taxonomists and biodiversity scientists. Prior to version 0.34.0, a SQL injection vulnerability was found in TaxonWorks that allows authenticated attackers to extract arbitrary data from the TaxonWorks database (including the users table). This issue may lead to information disclosure. Version 0.34.0 contains a fix for the issue.\n

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

Weakness information:
cwe_id: CWE-89
cwe_name: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
description: The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.
extended_description: 
            
            
         
         

Fix information:
repo_url: https://github.com/SpeciesFileGroup/taxonworks
commit_details: repo_url: https://github.com/SpeciesFileGroup/taxonworks
author: Hernán Lucas Pereira
author_date: 2023-06-29 14:24:25-03:00
msg: Optimized several find_for_autocomplete by removing redundant expressions
repository: repo_url: https://github.com/SpeciesFileGroup/taxonworks
repo_name: SpeciesFileGroup/taxonworks
description: Workbench for biodiversity informatics.
repo_language: Ruby
owner: SpeciesFileGroup
file_changes: filename: collection_object_observation.rb
change_type: ModificationType.MODIFY
diff: @@ -34,8 +34,7 @@ class CollectionObjectObservation < ApplicationRecord
   # @param [ActionController::Parameters] params
   # @return [Scope]
   def self.find_for_autocomplete(params)
-    term = "#{params[:term]}%"
-    where('data LIKE ? OR data ILIKE ? OR data = ?', term, "#{term}%", '%term')
+    where('data ILIKE ? OR data = ?', "#{params[:term]}%", params[:term])
       .where(project_id: params[:project_id])
   end
 

programming_language: Ruby
filename: content.rb
change_type: ModificationType.MODIFY
diff: @@ -92,7 +92,7 @@ class Content < ApplicationRecord
   end
 
   def self.find_for_autocomplete(params)
-    where('text ILIKE ? OR text ILIKE ?', "#{params[:term]}%", "%#{params[:term]}%")
+    where('text ILIKE ?', "%#{params[:term]}%")
   end
 
   def self.used_recently(user_id, project_id)

programming_language: Ruby
filename: language.rb
change_type: ModificationType.MODIFY
diff: @@ -52,8 +52,7 @@ class Language < ApplicationRecord
   end
 
   def self.find_for_autocomplete(params)
-    term = "#{params[:term]}%"
-    where('english_name ILIKE ? OR english_name = ?', term, params[:term])
+    where('english_name ILIKE ? OR english_name = ?', "#{params[:term]}%", params[:term])
   end
 
   # @param klass ['Source' || 'Serial']

programming_language: Ruby
filename: topic.rb
change_type: ModificationType.MODIFY
diff: @@ -24,9 +24,10 @@ class Topic < ControlledVocabularyTerm
 
   # TODO: Deprecate for CVT + params (if not already done)
   def self.find_for_autocomplete(params)
-    term = "#{params[:term]}%"
-    where_string = "name LIKE '#{term}' OR name ILIKE '%#{term}' OR name = '#{term}' OR definition ILIKE '%#{term}'"
-    ControlledVocabularyTerm.where(where_string).where(project_id: params[:project_id], type: 'Topic')
+    term = params[:term]
+    ControlledVocabularyTerm
+      .where('name ILIKE ? OR name = ? OR definition ILIKE ?', "%#{term}%", term, "%#{term}%")
+      .where(project_id: params[:project_id], type: 'Topic')
   end
 
   # @param used_on [String] one of `Citation` (default) or `Content`

programming_language: Ruby