CVE-2021-41128 (published 2021-10-06T18:15Z)

Hygeia is an application for collecting and processing personal and case data in connection with communicable diseases. In affected versions all CSV Exports (Statistics & BAG MED) contain a CSV Injection Vulnerability. Users of the system are able to submit formula as exported fields which then get executed upon ingestion of the exported file. There is no validation or sanitization of these formula fields and so malicious may construct malicious code. This vulnerability has been resolved in version 1.30.4. There are no workarounds and all users are advised to upgrade their package.

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

Weakness information:
cwe_id: CWE-74
cwe_name: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
description: The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
extended_description: Software or other automated logic has certain assumptions about what constitutes data and control respectively. It is the lack of verification of these assumptions for user-controlled input that leads to injection problems. Injection problems encompass a wide variety of issues -- all mitigated in very different ways and usually attempted in order to alter the control flow of the process. For this reason, the most effective way to discuss these weaknesses is to note the distinct features that classify them as injection weaknesses. The most important issue to note is that all injection problems share one thing in common -- i.e., they allow for the injection of control plane data into the user-controlled data plane. This means that the execution of the process may be altered by sending code in through legitimate data channels, using no other mechanism. While buffer overflows, and many other flaws, involve the use of some further issue to gain execution, injection problems need only for the data to be parsed.
         

Fix information:
repo_url: https://github.com/jshmrtn/hygeia
commit_details: repo_url: https://github.com/jshmrtn/hygeia
author: Jonatan Männchen
author_date: 2021-10-06 11:58:57+01:00
msg: Merge pull request from GHSA-8pwv-jhj2-2369
repository: repo_url: https://github.com/jshmrtn/hygeia
repo_name: jshmrtn/hygeia
description: COVID-19 Tracing
repo_language: Elixir
owner: jshmrtn
file_changes: filename: case_context.ex
change_type: ModificationType.MODIFY
diff: @@ -1116,7 +1116,7 @@ defmodule Hygeia.CaseContext do
 
     [@bag_med_16122020_case_fields]
     |> Stream.concat(cases)
-    |> CSV.encode()
+    |> CSV.encode(escape_formulas: true)
   end
 
   @bag_med_16122020_contact_fields [
@@ -1802,7 +1802,7 @@ defmodule Hygeia.CaseContext do
         end)
       end
 
-    CSV.encode(export)
+    CSV.encode(export, escape_formulas: true)
   end
 
   defp normalize_boolean_field(row, field_number) do

programming_language: Ruby
filename: statistics_context.ex
change_type: ModificationType.MODIFY
diff: @@ -634,7 +634,7 @@ defmodule Hygeia.StatisticsContext do
         )
       )
     )
-    |> CSV.encode()
+    |> CSV.encode(escape_formulas: true)
   end
 
   @spec export(
@@ -657,7 +657,7 @@ defmodule Hygeia.StatisticsContext do
         )
       )
     )
-    |> CSV.encode()
+    |> CSV.encode(escape_formulas: true)
   end
 
   @spec export(
@@ -679,7 +679,7 @@ defmodule Hygeia.StatisticsContext do
         )
       )
     )
-    |> CSV.encode()
+    |> CSV.encode(escape_formulas: true)
   end
 
   @spec export(
@@ -703,7 +703,7 @@ defmodule Hygeia.StatisticsContext do
         )
       )
     )
-    |> CSV.encode()
+    |> CSV.encode(escape_formulas: true)
   end
 
   @spec export(
@@ -726,7 +726,7 @@ defmodule Hygeia.StatisticsContext do
         )
       )
     )
-    |> CSV.encode()
+    |> CSV.encode(escape_formulas: true)
   end
 
   @spec export(
@@ -752,7 +752,7 @@ defmodule Hygeia.StatisticsContext do
         )
       )
     )
-    |> CSV.encode()
+    |> CSV.encode(escape_formulas: true)
   end
 
   @spec export(
@@ -779,7 +779,7 @@ defmodule Hygeia.StatisticsContext do
         )
       )
     )
-    |> CSV.encode()
+    |> CSV.encode(escape_formulas: true)
   end
 
   @spec export(
@@ -806,7 +806,7 @@ defmodule Hygeia.StatisticsContext do
         )
       )
     )
-    |> CSV.encode()
+    |> CSV.encode(escape_formulas: true)
   end
 
   @spec export(
@@ -833,7 +833,7 @@ defmodule Hygeia.StatisticsContext do
         )
       )
     )
-    |> CSV.encode()
+    |> CSV.encode(escape_formulas: true)
   end
 
   # Export for only "from" day !
@@ -864,7 +864,7 @@ defmodule Hygeia.StatisticsContext do
         end
       )
     )
-    |> CSV.encode()
+    |> CSV.encode(escape_formulas: true)
   end
 
   defp list_active_cases_per_day_organisation_division_kind_query(

programming_language: Ruby
filename: mix.exs
change_type: ModificationType.MODIFY
diff: @@ -59,7 +59,10 @@ defmodule Hygeia.MixProject do
     [
       {:cadastre, "~> 0.2.0"},
       {:crontab, "~> 1.1"},
-      {:csv, "~> 2.4"},
+      # TODO: Revert back to the released version when the following PR is
+      # merged and released:
+      # - https://github.com/beatrichartz/csv/pull/104
+      {:csv, "~> 2.4", github: "jshmrtn/csv", branch: "formular_escaping"},
       {:ecto_boot_migration, "~> 0.2"},
       {:ecto_enum, "~> 1.4"},
       {:ecto, "~> 3.7"},

programming_language: Ruby
filename: mix.lock
change_type: ModificationType.MODIFY
diff: @@ -14,7 +14,7 @@
   "cowlib": {:hex, :cowlib, "2.8.0", "fd0ff1787db84ac415b8211573e9a30a3ebe71b5cbff7f720089972b2319c8a4", [:rebar3], [], "hexpm", "79f954a7021b302186a950a32869dbc185523d99d3e44ce430cd1f3289f41ed4"},
   "credo": {:hex, :credo, "1.5.6", "e04cc0fdc236fefbb578e0c04bd01a471081616e741d386909e527ac146016c6", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "4b52a3e558bd64e30de62a648518a5ea2b6e3e5d2b164ef5296244753fc7eb17"},
   "crontab": {:hex, :crontab, "1.1.10", "dc9bb1f4299138d47bce38341f5dcbee0aa6c205e864fba7bc847f3b5cb48241", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm", "1347d889d1a0eda997990876b4894359e34bfbbd688acbb0ba28a2795ca40685"},
-  "csv": {:hex, :csv, "2.4.1", "50e32749953b6bf9818dbfed81cf1190e38cdf24f95891303108087486c5925e", [:mix], [{:parallel_stream, "~> 1.0.4", [hex: :parallel_stream, repo: "hexpm", optional: false]}], "hexpm", "54508938ac67e27966b10ef49606e3ad5995d665d7fc2688efb3eab1307c9079"},
+  "csv": {:git, "https://github.com/jshmrtn/csv.git", "faef83ef956e132911c4b44891ce0d48904577c0", [branch: "formular_escaping"]},
   "db_connection": {:hex, :db_connection, "2.4.0", "d04b1b73795dae60cead94189f1b8a51cc9e1f911c234cc23074017c43c031e5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ad416c21ad9f61b3103d254a71b63696ecadb6a917b36f563921e0de00d7d7c8"},
   "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
   "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},

programming_language: Erlang