Skip to content

sniff_csv provides filesystem access even when enable_external_access is disabled in duckdb

High severity GitHub Reviewed Published Jul 24, 2024 in duckdb/duckdb

Package

pip duckdb (pip)

Affected versions

>= 1.0.0, < 1.1.0

Patched versions

1.1.0

Description

Summary

Content in filesystem is accessible for reading using sniff_csv, even with enable_external_access=false.

Details

During a pentest, a security researcher was able to access environment variable data and other system data by using the sniff_csv function, even though we set enable_external_access to false.

PoC

SET enable_external_access=false;
SET lock_configuration=true;

SELECT Columns FROM sniff_csv('/proc/self/environ');

Impact

Provides an attacker with access to filesystem even when access is expected to be disabled and other similar functions do NOT provide access.

For example select * from read_csv('/proc/self/environ') fails with a permission error.

There seems to be two vectors to this vulnerability:

  1. Access to files that should otherwise not be allowed. (We expect Permission Error: Scanning CSV files is disabled through configuration and not to provide any access to the file or even acknowledge that it exists).
  2. The content from a (non-csv?) file can be read (e.g. /etc/hosts, proc/self/environ, etc) even though that doesn't seem to be the intent of the sniff_csv function (my understanding is it's intending to provide information about the shape of the data, but not provide the data itself).

Workaround

It is possible to work around the issue by disabling the local file system using the disabled_filesystems setting:

SET disabled_filesystems='LocalFileSystem';
SET lock_configuration=true;

SELECT Columns FROM sniff_csv('/proc/self/environ');

will result in Permission Error: File system LocalFileSystem has been disabled by configuration.

Fix

A fix has been merged into the main branch (duckdb/duckdb#13133), and will be released with the next DuckDB release.

References

@hannes hannes published to duckdb/duckdb Jul 24, 2024
Published by the National Vulnerability Database Jul 24, 2024
Published to the GitHub Advisory Database Jan 21, 2025
Reviewed Jan 21, 2025

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

EPSS score

0.071%
(33rd percentile)

Weaknesses

CVE ID

CVE-2024-41672

GHSA ID

GHSA-w2gf-jxc9-pf2q

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.