CVE-2021-3779: Ruby-MySQL Gem Client File Read (FIXED)
The ruby-mysql gem before version 2.10.0 allowed a malicious MySQL server to request local file content from the client via the LOAD DATA LOCAL statement. An attacker controlling a rogue server could read arbitrary files from a connecting client without user authorisation.
Published on rapid7.com
The ruby-mysql Ruby gem prior to version 2.10.0 maintained by Tomita Masahiro is vulnerable to an instance of CWE-610: Externally Controlled Reference to a Resource in Another Sphere, wherein a malicious MySQL server can request local file content from a client without explicit authorization from the user. The initial…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The client library did not provide an option to disable LOAD DATA LOCAL queries, so a server could request local files without the user's consent.
Impact
An attacker could read arbitrary files from a client that connects to a malicious MySQL server, though routine security controls like SSL certificates would block network interception attempts.
What the attacker needed
Client uses vulnerable ruby-mysql; client connects to a malicious server
The fix
The issue was fixed in ruby-mysql 2.10.0; users unable to update should ensure CLIENT_LOCAL_FILES is disallowed by the client.
How it was found
- Run a rogue MySQL server instance.
- Use the vulnerable ruby-mysql gem to connect to that server and perform any database query.
- The server replies with a LOAD DATA LOCAL request, causing the client to send a local file.
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 write-up has not been written yet. The Original tab links to the source.
When a program connects to a database server, the server can ask the program to send back the contents of a file on the user's computer. In this case, the Ruby library used to talk to MySQL did not give the user a way to refuse that request. So if someone connected to a fake database server, that server could steal files from their machine.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.