Closed iSnow closed 5 years ago
@iSnow Good catch. Relative paths were prohibited in the specs in the middle of the work on the library I think. Now it says:
SECURITY: / (absolute path) and ../ (relative parent path) are forbidden to avoid security vulnerabilities when implementing data package software. These limitations on resource path ensure that resource paths only point to files within the data package directory and its subdirectories. This prevents data package software being exploited by a malicious user to gain unintended access to sensitive information.
Fixed and added to the documentation at http://frictionlessdata.io/specs/data-resource/index.html#url-or-path
Overview
Problem Description
I believe there is a path construction weakness in
CsvDataSource
that can be exploited by a malicious DataPackage. It would be exploitable in a server setting where users can upload DataPackages and browse through the linked resources. Consequences would be data exfiltration of well-known system configuration files.CsvDataSource
reads and returns CSV files linked as resources. IngetCSVParser()
, it does the following:If a malicious DataPackage has a resource link like "/etc/passwd", it would be regarded as an absolute path, the check for existence would be true and the file contents would be returned (I believe /etc/passwd could be read as CSV with the right dialect settings, and others like an fstab file on Linux most certainly as well).
Problem Resolution
Absolute paths need to be disallowed for resources
Ideally, there would be a two-prong approach:
Check paths while reading from the
resources
entry of the package descriptor file ("datapackage.json") and filter out absolute paths or make them relative to the package descriptor file, disallowing paths construction outside of datapackage.json's directoryin CsvDataSource, the file needs to be made relative to the package descriptor file (in case someone uses the library outside of datapackage-java) again.
Please preserve this line to notify @georgeslabreche (lead of this repository).
@roll I don't think the tableschema-java lib is in widespread use, but this needs to be tackled. Also, other implementations might want to ensure they are handling malicious DataPackages like this well.