odbc apache airflow provider code execution vulnerability
The OdbcHook in Apache Airflow's ODBC provider allowed a user to set the ODBC driver path via connection extra parameters, which could load an arbitrary dynamic library and execute code. An attacker with the ability to configure a connection could run commands on the Airflow worker.
- Triaged in 3 hours
- Fixed in 15 days
- Paid in 15 days
- Disclosed after 45 days
Summary by the program
CVE-2023-34395: Apache Airflow ODBC Provider: Remote code execution vulnerability Severity: moderate
Affected versions:
- Apache Airflow ODBC Provider before 4.0.0
Description: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection') vulnerability in Apache Software Foundation Apache Airflow ODBC Provider. In OdbcHook, A privilege escalation vulnerability exists in a system due to controllable ODBC driver parameters that allow the loading of arbitrary dynamic-link libraries, resulting in command execution. Starting version 4.0.0 driver can be set only from the hook constructor. This issue affects Apache Airflow ODBC Provider: before 4.0.0.
Credit: KmhlYXJ0 (finder)
Security Advisory: https://lists.apache.org/thread/l26yykftzbhc9tgcph8cso88bc2lqwwd
The report
In airflow.providers.odbc.hooks.odbc.OdbcHook, A privilege escalation vulnerability exists in a system due to controllable ODBC driver parameters that allow the loading of arbitrary dynamic-link libraries, resulting in command execution.
Vulnerability reproduction steps:
- get a malicious dynamic-link library driver
A simple way to obtain a malicious dynamic-link library driver is to obtain the driver source code, add malicious code into the driver code and compile it. So I download a mysql-odbc-driver from https://cdn.mysql.com//Downloads/Connector-ODBC/8.0/mysql-connector-odbc-8.0.33-src.tar.gz,add I add system('touch /tmp/apache-ariflow-odbc') in driver.ansi.SQLDriverConnect function. After Compilation, I get a dynamic library libmyodbc8a.so.
- config odbc connection
Go to the Connection configuration page. Add a driver parameter in the extra location, with the parameter being the file path of the previously obtained dynamic-link library file.
- click on the test button
Click on the test button and it can be observed that the command is executed and a file named apache-ariflow-odbc is generated in the /tmp directory.
This is a screenshot of my email exchange with Airflow developers: █████ █████
Impact
Upgrade any local user to Airflow user privileges.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The OdbcHook accepted the ODBC driver path from user-controlled connection extra parameters instead of restricting it to the hook constructor.
Impact
A user who can configure an Airflow connection could execute arbitrary commands with the privileges of the Airflow process, escalating from a local user to Airflow user privileges.
What the attacker needed
Access to configure an Airflow connection; ability to supply a malicious driver file
How it was found
- Obtain or build a malicious ODBC driver dynamic library.
- In the Airflow connection configuration, add a driver parameter in the extra field pointing to that library.
- Click the test button to trigger loading of the driver and execution of its code.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Apache Airflow is a tool for scheduling data jobs. Its ODBC provider lets Airflow talk to databases using a 'driver' file. The bug meant a user could point that driver setting at their own malicious file, and when Airflow tested the connection, the file's code ran on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.