Commit Graph

1055 Commits

Author SHA1 Message Date
Ilia Ross
04b47e5815 Add API-only access for Webmin accounts
This PR adds an `api_only` global permission that restricts a Webmin account to one supported API endpoint, such as virtual-server/remote.cgi.

External integrations need credentials that can call an API without also granting access to the Webmin interface or generic RPC. Existing module permissions do not provide this endpoint-level restriction. The new setting allows administrators to create dedicated integration accounts while Webmin continues performing authorized operations through its privileged backend.

The restriction is enforced in two places:
- MiniServ checks the authenticated account's policy before dispatching CGI, static-file, DAV, or WebSocket requests. Requests outside the configured endpoint receive HTTP 403.
- `init_config` requires the permitted CGI to explicitly opt in before initialization. This also protects Webmin-initializing CGIs hosted by another web server.

Generic RPC is denied for API-only accounts, even when an existing RPC permission would otherwise allow it. The endpoint's own module and operation permissions still apply. Selecting an endpoint does not grant permission to execute every API command.

Webmin Users gains an API-only setting for users and groups. Existing restrictions survive ordinary edits, resets, copies, cloning, renaming, group propagation, and cluster synchronization. Clearing a restriction requires an explicit permission edit. Group updates preserve restrictions already assigned to individual members.

MiniServ reads the policy on each request from the account's existing storage backend: local files, MySQL, PostgreSQL, or LDAP. Policy-read errors deny access instead of treating the account as unrestricted.

Validation passed with the four separately submitted supporting fixes (#2897, #2898, #2899, #2900) ,applied: 169 focused tests, syntax checks, and live Debian tests using file-backed and PostgreSQL accounts. Live checks covered account creation, lifecycle operations, both CGI modes, sessions, RPC, static files, DAV, and WebSockets.

The supporting fixes remain separate PRs. This API-only branch currently has seven lifecycle test failures that depend on the file-cache and group ACL cleanup fixes landing.
2026-10-23 22:06:12 +02:00
Jamie Cameron
d59f5326a1 Merge pull request #2886 from webmin/dev/fix-rpc-deserialization
Fix RPC deserialization
2026-10-21 20:35:07 -07:00
Ilia Ross
dbb360b127 Add Data::Dumper parser module 2026-10-22 01:45:44 +02:00
Ilia Ross
91d3dd843b Fix unsafe fast RPC deserialization without dropping Data::Dumper support
https://github.com/webmin/webmin/pull/2886#issuecomment-6207458026
2026-10-19 01:49:05 +02:00
Ilia Ross
fb70225187 Fix RPM package install completion
This PR fixes package installation pages stopping after "Re-fetching available packages .." on RPM systems, before the System Status refresh, reboot check, and return link appeared.

The regression was introduced by https://github.com/webmin/webmin/commit/658f930, which wrapped RPM queries in `clean_environment` while the Package Updates installer had already cleaned the environment.

The inner clean overwrote the only saved environment, leaving `WEBMIN_CONFIG` unset and causing the System Status library to fail after the page headers had been sent.

Nested `clean_environment` calls now save separate snapshots, allowing each `reset_environment` call to restore the matching environment exactly while preserving Virtualmin's API script runner behavior.
2026-10-17 01:27:12 +02:00
Ilia Ross
7f4a2cf5cd Fix SSL certificate checks for regular RPC
This PR fixes SSL certificate verification for regular `/rpc.cgi` connections.

It reuses the existing certificate requirements already passed to Fast RPC, so both transports honor `checkssl`.

<!-- ANT-2026-1G97HEC6: Reported by Adam via email on October 11, 2026 at 12:08. -->
2026-10-16 05:25:50 +02:00
Ilia Ross
5231d6de0f Drop certificate checks from RPC deserialization fix 2026-10-16 05:16:40 +02:00
Ilia Ross
0678fbfa6b Fix Fast RPC transfer authentication
This PR fixes unauthenticated Fast RPC transfer sockets by requiring the transfer connection to present the active RPC session ID before file data moves.

Patched peers use authentication, while mixed-version transfers retain existing behavior for compatibility.

ANT-2026-1G97HEC6: Reported by Adam email on October 11 2026 at 12:08.
2026-10-15 16:36:32 +02:00
Ilia Ross
ffa551a24b Fix RPC deserialization and certificate checks
This PR fixes unsafe RPC deserialization by dropping `Data::Dumper` from fast RPC, rejecting `$VAR1` input, and keeping remote objects as plain data.

Original report by Adam emailed October 11, 2026 at 05:34.
2026-10-15 15:02:39 +02:00
Jamie Cameron
692cb6ea70 Merge pull request #2876 from webmin/dev/fix-symlink-loops
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
Fix symlink resolution loops
2026-10-13 20:51:55 -07:00
Ilia Ross
222a2fd31b Fix convert to JSON to support canonical flag for independent key sorting 2026-10-13 05:26:42 +02:00
Jamie Cameron
8bc89757a7 Only log hashed session ID, so it cannot be used to login 2026-10-11 18:03:22 -07:00
Ilia Ross
e99841ebc6 Fix directory symlink handling in temporary file helpers 2026-10-10 21:33:46 +02:00
Ilia Ross
22c31d206f Fix symlink loops when opening temporary files
This change fixes infinite loops in `open_tempfile()` and `open_lock_tempfile()` when opening cyclic symlinks.
2026-10-10 17:45:52 +02:00
Ilia Ross
f7f2fcbdb8 Fix growing symlink loops
This change fixes memory exhaustion from symlinks such as link -> link/child.
2026-10-10 17:42:51 +02:00
Ilia Ross
34040bd0df Fix false symlink loop detection
This patch fixes valid symlink paths being mistaken for loops by [c51f0ed4](https://github.com/webmin/webmin/commit/c51f0ed4).

It simplifies only the checked path prefix, preserving the unresolved remainder.

Original loop cases still stop quickly, while long valid chains remain supported.

I reproduced incorrect PHP selection in Virtualmin and WP Workbench, and GoAccess choosing its root log-creation branch instead of the domain-user helper.
2026-10-10 16:51:51 +02:00
Jamie Cameron
c51f0ed465 Ensure uniqueness by simplifying the path being checked for repitition 2026-10-09 20:58:39 -07:00
Jamie Cameron
dea3af005f Merge branch 'master' of github.com:webmin/webmin
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-10-08 21:26:25 -07:00
Jamie Cameron
b4c79b1348 Exit from resolve_links if a link goes back to itself 2026-10-08 21:25:31 -07:00
Ilia Ross
5e90e1438a Fix module name validation (once again)
This patch fixes `get_module_info()` accepting module names with a trailing newline after the regex anchors were changed.

It preserves the strict validation introduced in my `2f4f017ac` to prevent loading files outside installed modules.

The check directly rejects undefined or empty names and any character outside ASCII letters, digits, underscores, and hyphens, including newlines anywhere in the name.

Regression tests pass and verify that invalid names are rejected before module lookup while valid names remain accepted.
2026-10-08 22:40:36 +02:00
Jamie Cameron
223b0f331f Merge branch 'master' of github.com:webmin/webmin 2026-10-07 21:57:01 -07:00
Jamie Cameron
851883c41d Use standard start and end markers, since this isn't a multi-line regexp 2026-10-07 21:56:56 -07:00
Ilia Ross
18d5344043 Fix empty action log details
This patch fixes blank sections in action details when multiple actions are logged in one process.
2026-10-08 04:53:32 +02:00
Ilia Ross
61d3618cc5 Fix external IP checks to use requested address family #1300 2026-10-04 22:06:49 +02:00
Ilia Ross
6b7832acd0 Fix stale miniserv configuration reads
This PR fixes WebSocket routes being lost when miniserv configuration changes multiple times within one second.

Read `miniserv.conf` directly so locked updates use the current configuration.

The previous cache could reuse stale data because it compared modification times in whole seconds.

Add a regression test covering route additions and removals with an unchanged modification time.
2026-09-30 01:36:26 +02:00
Ilia Ross
267b6bc07f Fix IPv4 delays caused by IPv6 lookups
This PR fixes delays when IPv6 DNS lookups stall otherwise working IPv4 connections.

The earlier changes ([04c74877](04c74877c3) and [8a6f7784](8a6f778410)) added fallback across available IPv4 and IPv6 addresses, which this PR preserves.

Resolving both families upfront appears to have been an implementation choice, yet now IPv6 is resolved only when no IPv4 connection succeeds.

Unit tests and real socket compatibility tests passed on Alma 10 and Debian 13.
2026-09-13 23:49:36 +02:00
Ilia Ross
2f4f017acf Fix module name validation in configuration pages 2026-09-11 17:34:17 +02:00
Ilia Ross
f197e6e886 Fix admin detection when RPC is disabled
This PR stops treating `rpc=0` as a safe-user restriction, restoring File Manager ops and admin features for fully privileged accounts created with RPC disabled.

Preserve explicit `_safe` restrictions and product roles.

Regression tests and Perl syntax checks pass.

Fixes https://github.com/webmin/webmin/issues/2837
2026-09-10 04:30:47 +02:00
Ilia Ross
6183a4006a Add an option to rotate Miniserv logs using logrotate
This PR adds the ability for the logging pages to hand the Miniserv access and error logs, and the Webmin actions log, to logrotate instead of having Miniserv periodically delete them. The generated section uses copy-truncate rotation, since Miniserv only reopens its error log when the file disappears.

The option only appears when the Log File Rotation module is available and configured correctly.
2026-08-22 01:03:48 +02:00
Ilia Ross
3c26b2be3b Fix FQDN detection on systemd systems
ⓘ Do not return a short name from /etc/hostname when the full name is requested; resolve it with hostname -f first, honoring the no_hostname_f option, and otherwise fall back to the existing file-based logic.

Also check for /run/systemd/system instead of reading /proc/1/comm as it's much cheaper.

Fixes #2054
2026-08-21 19:37:47 +02:00
Ilia Ross
3eccc770dd Fix log email being sent to bogus address when no destination is set 2026-08-20 03:23:49 +02:00
Jamie Cameron
2f9a12c008 Use destination email with name if configured 2026-08-19 18:08:10 -07:00
Ilia Ross
199dae2562 Remove bundled Miniserv certificate and safely fall back to HTTP 2026-08-09 15:27:13 +02:00
Ilia Ross
76030a251c Fix indent
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-24 12:43:21 +02:00
Ilia Ross
0eaf0ef80d Fix redirect ports and linked-server WebSocket routing
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
ⓘ Follow up on #2794 by making `redirect_port` work even when `redirect_host` is not set. Keep existing host precedence and correctly handle proxy headers, IPv6 addresses, default ports, and invalid port values.

ⓘ Fix linked-server by keeping the child URL recognizable to the parent, then generating the final WebSocket URL on the same host and port the browser is using. This keeps the connection working with the current Webmin session.
2026-07-15 20:38:41 +02:00
LemoeChun
2ea3723811 Fix to honor redirect settings for WebSocket URLs 2026-07-15 17:27:16 +08:00
Ilia Ross
934073532f Fix to use the existing HTTP and FTP mode 7 callback 2026-07-14 02:27:10 +02:00
Ilia Ross
a618c2b58e Fix to manually incorporated Jamie's ed3cd51 change 2026-07-14 01:57:26 +02:00
Ilia Ross
9dcdca7f1f Merge branch 'master' into dev/download-target-check 2026-07-14 00:58:07 +02:00
Ilia Ross
bf3cd03977 Fix to manually incorporated Jamie's 70011c1 change 2026-07-14 00:46:12 +02:00
Jamie Cameron
70011c11c0 Keep track of the remote IP for HTTP connections, and make it available to the callback function 2026-07-13 14:41:52 -07:00
Jamie Cameron
9e7cdc801c Use formal params 2026-07-13 14:20:14 -07:00
Ilia Ross
1555224592 Fix to refactor download address checks to use callback bundles
ⓘ Extend HTTP and FTP download callbacks with destination validation while preserving legacy tracking callbacks and enforcing SSRF policy across redirects, proxies, caches, and direct/passive sockets.

https://github.com/webmin/webmin/pull/2789#discussion_r3567985773
2026-07-13 13:36:34 +02:00
Ilia Ross
955daa53c6 Fix to use physical ACL restore when supported
ⓘ Detect support for combining `-P` with `setfacl --restore` to prevent acl 2.4.0 security warnings while retaining compatibility with older releases.
2026-07-12 23:50:34 +02:00
Ilia Ross
1ca52c9a97 Add ACL controls for URL download destinations
Block non-public HTTP, HTTPS and FTP destinations by default in File Manager, Mailboxes and Upload and Download, with per-user IP/CIDR exceptions, redirect and proxy protection, cache isolation, and current-ACL enforcement for scheduled jobs.
2026-07-12 14:57:08 +02:00
Ilia Ross
203a87ff0e Fix to reuse copy helper for ACL-controlled file copies 2026-07-12 01:07:30 +02:00
Ilia Ross
2fb4eb1721 Fix linked-server uploads over partial TLS writes
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
ⓘ Stream linked-server request bodies in bounded chunks, retry partial SSL writes with byte-safe offsets, detect incomplete forwarding, and add regression coverage.

https://github.com/webmin/webmin/issues/2784
2026-07-10 14:48:47 +02:00
Ilia Ross
a13461f9c1 Fix to respect global file ACLs for server-local imports
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
ⓘ Centralize global file ACL checks for server-local reads and applies them to batch, LDAP batch, MySQL, and PostgreSQL local import and restore flows. Files are read under the configured `fileunix` identity and staged with the correct command-user ownership, preventing constrained Webmin users from bypassing `root`, `otherdirs`, or `fileunix`.

9ceffce70f (r191495975)
2026-07-07 12:39:35 +02:00
Ilia Ross
aa2282778e Fix to recognize hex numeric HTML entities
https://forum.virtualmin.com/t/char-redered-as-x25e6/137494/6?u=ilia
2026-06-29 23:28:28 +02:00
Ilia Ross
7878ef466f Fix to expire abandoned linked websocket routes
ⓘ Use the existing scheduled websocket cleanup path for linked-server ws-link routes and expire unopened temporary routes after five minutes.

This limits how long credential-bearing proxy routes can remain in `miniserv.conf` while leaving active and normal websocket cleanup behavior unchanged.
2026-06-23 02:24:17 +02:00