
Webmin 2.670 - High 8.8 - Remote - Path write - MySQL csv.cgi writes CSV outside bpath
A coworker with a Webmin MySQL login is supposed to dump files into one folder. The Backup Database button honors that jail. The CSV export form does not. They can overwrite a path the backup ACL already refused. When the backup Unix user is root, that write is as the Webmin process, usually root. They still need that login. They still cannot run mysqldump outside the jail.
Class: Path write
Reach: Remote (MySQL module user, buser set, bpath jail)
Webmin 2.670 (3a2b2b86) - Webmin
| ID | no CVE yet |
| Class | Path write |
| Reach | Remote (signed-in MySQL-module user with buser set and a bpath that does not contain the target) |
| CWE | CWE-22 |
| CVSS | High: 8.8 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H |
| Product | Webmin |
| Affected | 2.670 (3a2b2b8671c0669c129f5275b3dd1853106ae02b) |
| Auth | Webmin session. MySQL module. buser must be set. edonly must be off. |
| License | GNU Affero GPL v3.0 |
| Lab | 127.0.0.1:18420 only |
Needs a signed-in Webmin user who was given the MySQL module, a backup Unix user (buser), and a backup directory (bpath) that is not /. Default ACL is bpath=/ and buser=root. That is the full grant, not this leftover. The leftover is the jailed user. CSV export is supposed to reuse the same directory the backup form already checks.
| Privilege | Method / sink | Recon / integrity / availability | Lab-proven or inferred |
|---|---|---|---|
Write a CSV to an absolute path outside bpath as root | POST /mysql/csv.cgi dest=1 file=/tmp/h32-csv-write.csv when buser=root | Integrity (host file write) | Lab-proven. File contains WEBMIN-H32-CSV-WRITE |
| Overwrite an existing path the miniserv user can write | same sink, open_tempfile(OUT, ">$in{'file'}") then rename | Integrity | Inferred from open_tempfile / close_tempfile. Lab wrote a new /tmp file |
Write as a non-root buser | same CGI, command_as_user cat > plus quote_path | Integrity (as that Unix user) | Source. Lab used buser=root |
| Knock the host over by replacing a config the process later reads | same write | Availability | Inferred. Not the lab oracle |
| Negative control: Backup Database to the same path | POST /mysql/backup_db.cgi dest=0 file=/tmp/h32-csv-write.csv | n/a | Lab-proven. Invalid backup path / Backups can only be created under. File not created |
Stays closed on this leftover
| Axis | Method / sink | Why it is closed |
|---|---|---|
| Integrity | Backup Database local dump | backup_db.cgi calls is_under_directory($access{'bpath'}, $in{'file'}) |
| Integrity | CSV to the browser | dest=0 prints text/plain to STDOUT. No host write |
| Integrity | CSV with buser unset | Form hides the file field. CGI errors cvs_ebuser |
| Integrity | CSV when edonly=1 | csv.cgi errors dbase_ecannot |
| Integrity | Custom-command parameter injection | Fixed in 2.670. Different module |
| Integrity | Unauthenticated write | Session required |
| Integrity | Shell metacharacters on the non-root branch | quote_path on cat >. This leftover is the file op |
| Recon | Reading a file the user cannot already SELECT | CSV is a write of query output, not a file read |
This is a write. It is not a file read. It is not a command string. I did not treat crontab or authorized_keys overwrite as proven RCE.
I pinned webmin/webmin tag 2.670. The policy at webmin.com/security says fine-grained ACLs are the control. bpath is that control for MySQL dumps. backup_db.cgi checks it. csv.cgi asks for buser and an absolute path, then opens the file.
Wrong turns: treating the CSV where box as SQL injection (the same user already has Execute SQL); treating two-arg open as a pipe on Perl 5.34; treating the already-public custom-command bug as this path.
Docker, git, python3. The launcher clones webmin/webmin at 3a2b2b8671c0669c129f5275b3dd1853106ae02b when the shared image is missing. MariaDB is the sibling container.
python3 webmin-mysql-csv-write-Abraxas-Labs.py
or:
cd lab
./run.sh
Target only http://127.0.0.1:18420. Image webmin-lab:2.670. Compose webminh32. The limited user is csvuser / csvpass. Module ACL is dbs=labdb, bpath=/var/webmin/mysql-jail, buser=root, edonly=0. Loopback only.
IOC image=webmin-lab:2.670 label-version=2.670
IOC webmin-version=2.670 expect=2.670
IOC acl=dbs=labdb;create=0;delete=0;stop=0;perms=0;bpath=/var/webmin/mysql-jail;buser=root;edonly=0;indexes=0;views=0;noconfig=1;
IOC login-page status=200
IOC login status=302 sid=1
IOC backup-neg http=200 denied=1 wrote=0
IOC csv-file='"WEBMIN-H32-CSV-WRITE"'
SUCCESS WEBMIN-H32-MYSQL-CSV WEBMIN-H32-CSV-WRITE
Apply bpath the way backup_db.cgi already does:
if (!$in{'dest'} && !&is_under_directory($access{'bpath'}, $in{'file'})) {
On CSV, dest=1 is the file. Refuse unless is_under_directory($access{'bpath'}, $in{'file'}). Do it before open_tempfile and before the cat > branch.
3a2b2b8671c0669c129f5275b3dd1853106ae02b)mysql/csv.cgi (csv.cgi:11-14, :34-44)mysql/backup_db.cgi (backup_db.cgi:43-46)mysql/csv_form.cgi (csv_form.cgi:25-31)is_under_directory (web-lib-funcs.pl:10878)GNU Affero GPL v3.0. See LICENSE. Loopback lab only. No warranty.
Abraxas Labs [email protected]