CVE-2021-40331

8.1 HIGH

📋 TL;DR

This vulnerability in Apache Ranger Hive Plugin allows users with only SELECT privilege on a database to alter table ownership in Hive when the plugin is enabled. This affects Apache Ranger Hive Plugin versions 2.0.0 through 2.3.0, potentially enabling privilege escalation and unauthorized data access.

💻 Affected Systems

Products:
  • Apache Ranger Hive Plugin
Versions: 2.0.0 through 2.3.0
Operating Systems: All platforms running Apache Ranger Hive Plugin
Default Config Vulnerable: ⚠️ Yes
Notes: Only vulnerable when Apache Ranger Hive Plugin is enabled and configured. Hive installations without the Ranger plugin are not affected.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

An attacker with SELECT privilege could take ownership of critical tables, modify data, grant themselves additional privileges, or disrupt Hive operations across the entire database.

🟠

Likely Case

Malicious or compromised users with legitimate SELECT access could escalate privileges to modify or delete data they shouldn't have access to, potentially leading to data integrity issues.

🟢

If Mitigated

With proper access controls and monitoring, impact is limited to users who already have SELECT access, but they could still perform unauthorized ownership changes.

🌐 Internet-Facing: MEDIUM - While the vulnerability requires authentication, internet-facing Hive instances with the vulnerable plugin could be targeted by attackers who obtain SELECT credentials.
🏢 Internal Only: HIGH - Internal users with SELECT privileges could exploit this to escalate privileges and compromise data integrity across the organization.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: LOW - Requires only SELECT privilege and knowledge of Hive commands.

Exploitation requires authenticated access with SELECT privilege. The vulnerability is in the permission validation logic of the Ranger plugin.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 2.4.0 or later

Vendor Advisory: https://lists.apache.org/thread/s68yls6cnkdmzn1k4hqt50vs6wjvt2rn

Restart Required: Yes

Instructions:

1. Download Apache Ranger 2.4.0 or later. 2. Stop Hive services. 3. Replace the Ranger Hive Plugin with the patched version. 4. Restart Hive services. 5. Verify the plugin version and functionality.

🔧 Temporary Workarounds

Disable Ranger Hive Plugin

all

Temporarily disable the vulnerable plugin until patching can be completed.

# Remove or rename the Ranger plugin JAR files from Hive classpath
# Example: mv /path/to/ranger-hive-plugin*.jar /path/to/ranger-hive-plugin*.jar.disabled

Restrict SELECT Privileges

all

Tighten access controls to minimize users with SELECT privilege on sensitive databases.

# Use Ranger policies to restrict SELECT access
# Review and revoke unnecessary SELECT privileges

🧯 If You Can't Patch

  • Implement strict monitoring of Hive ownership changes and ALTER TABLE operations.
  • Enforce least privilege access and regularly audit user permissions in Ranger policies.

🔍 How to Verify

Check if Vulnerable:

Check the Ranger Hive Plugin version. If version is between 2.0.0 and 2.3.0 inclusive, the system is vulnerable.

Check Version:

Check the plugin JAR file version or Ranger admin console for plugin version information.

Verify Fix Applied:

Verify the plugin version is 2.4.0 or later and test that users with only SELECT privilege cannot alter table ownership.

📡 Detection & Monitoring

Log Indicators:

  • Hive audit logs showing ALTER TABLE OWNER commands from users with only SELECT privilege
  • Ranger plugin logs showing permission validation failures or bypasses

Network Indicators:

  • Unusual patterns of ALTER TABLE commands from users with limited privileges

SIEM Query:

source="hive_audit_logs" AND command="ALTER TABLE" AND (user_privileges="SELECT" OR user_privileges="select")

🔗 References

📤 Share & Export