|
| 1 | +<!--- |
| 2 | + Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + or more contributor license agreements. See the NOTICE file |
| 4 | + distributed with this work for additional information |
| 5 | + regarding copyright ownership. The ASF licenses this file |
| 6 | + to you under the Apache License, Version 2.0 (the |
| 7 | + "License"); you may not use this file except in compliance |
| 8 | + with the License. You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | + Unless required by applicable law or agreed to in writing, |
| 13 | + software distributed under the License is distributed on an |
| 14 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + KIND, either express or implied. See the License for the |
| 16 | + specific language governing permissions and limitations |
| 17 | + under the License. |
| 18 | +--> |
| 19 | + |
| 20 | +# Security Policy |
| 21 | + |
| 22 | +This document outlines the security model for Apache DataFusion and how to |
| 23 | +report vulnerabilities. |
| 24 | + |
| 25 | +This model also applies to the [datafusion-cli] command line tool, which is |
| 26 | +a thin wrapper around the DataFusion library. |
| 27 | + |
| 28 | +## Security Model |
| 29 | + |
| 30 | +DataFusion is a low level library, designed to be embedded in applications |
| 31 | +that have their own security model. This section describes DataFusion's own |
| 32 | +model: what counts as a bug versus a vulnerability. |
| 33 | + |
| 34 | +In general, crashes, panics, hangs, and excessive resource consumption |
| 35 | +(memory, CPU, or disk) are treated as **bugs**, not vulnerabilities, unless |
| 36 | +they are **exploitable** and could let an attacker: |
| 37 | + |
| 38 | +* Execute arbitrary code (Remote Code Execution), or |
| 39 | +* Exfiltrate sensitive information from process memory (Information Disclosure). |
| 40 | + |
| 41 | +If the exploitation path is unclear, please report the issue as a bug rather |
| 42 | +than a vulnerability. The sections below describe what DataFusion treats as |
| 43 | +trusted input in a few specific areas. |
| 44 | + |
| 45 | +### SQL and DataFrame Queries |
| 46 | + |
| 47 | +SQL and DataFrame queries are executable code, comparable to a scripting |
| 48 | +language: a query can legitimately read files, open network connections |
| 49 | +(e.g. via `CREATE EXTERNAL TABLE`), and consume significant CPU, memory, or |
| 50 | +disk. Running such a query is not, on its own, a vulnerability. |
| 51 | + |
| 52 | +It is the embedding application's responsibility to decide whether a query is |
| 53 | +safe to run (e.g. validating externally supplied SQL text or URLs) and to |
| 54 | +sandbox untrusted queries at the OS/container level if needed. APIs such as |
| 55 | +[`SQLOptions::with_allow_dml`] can help restrict what a query is allowed to |
| 56 | +do, but do not guarantee that all input is safe to execute. |
| 57 | + |
| 58 | +### Data Files |
| 59 | + |
| 60 | +Format readers (e.g. Parquet, CSV, JSON, Avro, and Arrow IPC) assume a |
| 61 | +well-formed file from a trusted writer; use the [arrow validation APIs] to |
| 62 | +validate an untrusted file's structure. Issues due to malformed files, and |
| 63 | +well-formed files that contain unexpected or adversarial *data*, are bugs rather |
| 64 | +than vulnerabilities, as explained above. |
| 65 | + |
| 66 | +### Serialized Plans |
| 67 | + |
| 68 | +Serialized plans, such as [Substrait] and [`datafusion-proto`], are treated |
| 69 | +as trusted input. If received from an untrusted source, they should be |
| 70 | +validated before being passed to DataFusion for execution. |
| 71 | + |
| 72 | +### Extensions and Other Uses of Public APIs |
| 73 | + |
| 74 | +Code that uses DataFusion's public extension APIs (e.g. user defined functions, |
| 75 | +`TableProvider`, `ExecutionPlan`) is trusted to uphold their contracts (for |
| 76 | +example, that any `ArrayRef` is a valid Arrow array). Issues arising from |
| 77 | +violating the API contracts are not considered a DataFusion vulnerability. |
| 78 | + |
| 79 | +## Reporting a Bug |
| 80 | + |
| 81 | +We treat all bugs seriously and welcome help fixing them. If you find a bug |
| 82 | +that does not meet the criteria for a security vulnerability, please report it |
| 83 | +in the [public issue tracker](https://github.com/apache/datafusion/issues/). |
| 84 | + |
| 85 | +## Reporting a Vulnerability |
| 86 | + |
| 87 | +For security vulnerabilities **do not file a public issue.** Follow the [ASF |
| 88 | +security reporting process] by emailing |
| 89 | +[security@apache.org](mailto:security@apache.org). |
| 90 | + |
| 91 | +Include in your report: |
| 92 | + |
| 93 | +- A clear description and minimal reproducer. |
| 94 | +- Affected crates and versions. |
| 95 | +- Potential impact. |
| 96 | + |
| 97 | +[datafusion-cli]: https://datafusion.apache.org/user-guide/cli/index.html |
| 98 | +[`sqloptions::with_allow_dml`]: https://docs.rs/datafusion/latest/datafusion/execution/context/struct.SQLOptions.html#method.with_allow_dml |
| 99 | +[arrow validation apis]: https://docs.rs/arrow/latest/arrow/array/struct.ArrayData.html#method.validate_full |
| 100 | +[substrait]: https://docs.rs/datafusion-substrait/latest/datafusion_substrait/ |
| 101 | +[`datafusion-proto`]: https://docs.rs/datafusion-proto/latest/datafusion_proto/ |
| 102 | +[asf security reporting process]: https://www.apache.org/security/#reporting-a-vulnerability |
0 commit comments