Commit Graph

13 Commits

Author SHA1 Message Date
Ilia Ross
9ceffce70f Fix local batch file imports to enforce file access ACLs
ⓘ This tightens local server-side batch file execution in the Users and Groups module.

Both user and group batch endpoints now read local batch files through a shared helper that enforces the module `batchdir` ACL, the user’s global file chooser ACL (`root` / `otherdirs`), and the configured `fileunix` read identity. Existing ACLs remain compatible by treating a missing `batchdir` as `/`, while an explicitly blank value denies local server batch files.

Regression coverage was added for allowed paths, denied paths, `otherdirs`, missing/blank `batchdir`, symlink escape rejection, and successful local batch reads.

----

Reproduction / verification steps:

1. Create a constrained Webmin user with access to the `Users and Groups` module.

2. Set the user's Global ACL:

   - Root directory for file browser: `/home/user1`
   - Other directories to allow: empty
   - Browse as Unix user: `nobody`

3. Set the user's `Users and Groups` module ACL:

   - Can view batch file form?: `Yes`
   - Batch files must be under directory: `/`

4. Create test files on the Webmin host:

   ```sh
   sudo mkdir -p /home/user1

   echo ROOT_SECRET_MARKER | sudo tee /root/batch-secret.txt >/dev/null
   sudo chown root:root /root/batch-secret.txt
   sudo chmod 600 /root/batch-secret.txt

   echo ALLOWED_BATCH_MARKER | sudo tee /home/user1/allowed.batch >/dev/null
   sudo chmod 644 /home/user1/allowed.batch

   sudo ln -sf /root/batch-secret.txt /home/user1/link-secret.batch

   echo ROOT_ONLY_ALLOWED_MARKER | sudo tee /home/user1/root-only.batch >/dev/null
   sudo chown root:root /home/user1/root-only.batch
   sudo chmod 600 /home/user1/root-only.batch
   ```

5. Log in to Webmin as the constrained user and request:

   ```text
   /useradmin/batch_exec.cgi?source=1&local=/root/batch-secret.txt
   /useradmin/gbatch_exec.cgi?source=1&local=/root/batch-secret.txt
   ```

   Expected fixed result:

   ```text
   Local file location is not allowed
   ```

6. Request an allowed readable file:

   ```text
   /useradmin/batch_exec.cgi?source=1&local=/home/user1/allowed.batch
   /useradmin/gbatch_exec.cgi?source=1&local=/home/user1/allowed.batch
   ```

   Expected fixed result:

   ```text
   Invalid action at line 1 : ALLOWED_BATCH_MARKER
   ```

7. Request a symlink inside the allowed directory that points outside it:

   ```text
   /useradmin/batch_exec.cgi?source=1&local=/home/user1/link-secret.batch
   /useradmin/gbatch_exec.cgi?source=1&local=/home/user1/link-secret.batch
   ```

   Expected fixed result:

   ```text
   Local file location is not allowed
   ```

8. Request a root-only file inside the allowed directory:

   ```text
   /useradmin/batch_exec.cgi?source=1&local=/home/user1/root-only.batch
   /useradmin/gbatch_exec.cgi?source=1&local=/home/user1/root-only.batch
   ```

   Expected fixed result:

   ```text
   Local file not found
   ```

The fixed behavior confirms that local batch file imports now enforce the configured global file ACL, reject symlink escapes, and read files using the configured Unix identity instead of the privileged Webmin process.
2026-07-07 00:29:14 +02:00
Jamie Cameron
e84e4c3fe6 Add new ACL option for batch directory
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
Close inactive / close-inactive (push) Has been cancelled
2026-07-02 19:10:23 -07:00
Jamie Cameron
1445cd7641 Check permission to delete home dirs in batch operations 2026-06-14 13:29:54 -07:00
Ilia Ross
07a11f7de6 Fix to use quotemeta to prevent shell injection in Useradmin module
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
2026-02-11 13:03:27 +02:00
Jamie Cameron
a2dc3f7124 Switch all calls to open() to explicitly open for read 2020-03-14 17:20:54 -07:00
Jamie Cameron
0f6c404cab Double-check home dir 2008-11-12 21:29:42 +00:00
Jamie Cameron
bacc98141b UI-lification 2008-08-14 18:52:36 +00:00
Jamie Cameron
5663179028 Allow non-existent shell 2008-07-18 18:03:09 +00:00
Jamie Cameron
d0ed6bbc88 Set PASS in batch creation 2008-04-08 00:19:34 +00:00
Jamie Cameron
636005b90d Better batch validation and UI 2007-11-30 23:07:35 +00:00
Jamie Cameron
f75c063e6a Use real base when batch creating 2007-11-16 01:24:42 +00:00
Jamie Cameron
2e6c860b7a Fixed batch rename bug 2007-06-03 22:56:01 +00:00
Jamie Cameron
fc1c1b243f Initial checkin of Webmin 2007-04-12 20:24:50 +00:00