456 Commits

Author SHA1 Message Date
Ilia Ross
18296d3a55 Fix to simply skip stale PID file check
https://github.com/webmin/webmin/pull/2775#issuecomment-4792905755
2026-06-24 22:13:14 +02:00
Ilia Ross
18bf94af6a Fix possible startup loop with stale PID file after PID reuse
This PR fixes an issue where, after an unclean exit, Webmin can leave `miniserv.pid` behind.

If the kernel later reuses that PID for an unrelated process, the startup guard only checked that the PID was alive and refused to start with “Webmin is already running”.

With systemd restart handling, this can leave Webmin permanently down until the PID file is manually removed.

This change verifies that the live PID actually belongs to `miniserv.pl` running the same config before treating it as an active Webmin instance.

On Linux, it reads `/proc/<pid>/cmdline`, checks the miniserv script, and compares the config file by inode so symlinked paths still match and Usermin is correctly distinguished.

If the PID is confirmed unrelated, the stale PID file is removed and startup continues. If the process cannot be inspected, the previous conservative behavior is preserved.

Also hardens PID-file parsing with chomp and numeric validation, and adds tests for unrelated PID reuse, matching config, symlinked config, different miniserv config, and unreadable command-line fallback.
2026-06-24 17:37:02 +02:00
Ilia Ross
1a2046b1e3 Fix to harden WebSocket backend writes
This PR ensure proxied WebSocket backend writes complete the full buffer for both TLS and plain TCP connections.

Fail backend handshakes cleanly if writes cannot be completed, preventing truncated headers or frames from corrupting linked WebSocket tunnels.

Originally hinted by this code review: d1d1bad4ae (r189931785)
2026-06-24 01:14:32 +02:00
Ilia Ross
14c8d9b61e Fix to clean up consumed linked websocket routes
ⓘ Remove single-use ws-link routes when backend setup fails or after the backend handshake is consumed, with final loop cleanup kept as a fallback.

This prevents failed linked websocket retries from leaving temporary credential-bearing routes in `miniserv.conf`.
2026-06-23 01:30:29 +02:00
Ilia Ross
c72d232e2f Fix to restrict Basic auth for websocket routes
ⓘ Require websocket routes to opt in with allow_basic_ws before Basic auth is accepted in session mode. Mark linked ws-link routes and no-cookie backend-session routes as allowed, while leaving normal session-backed routes unmarked.
2026-06-23 01:09:43 +02:00
Ilia Ross
fac6b478b5 Fix to drain pending SSL data in websocket proxy
ⓘ Check OpenSSL's pending buffer before `select()` in the websocket forwarding loop so TLS-backed linked websocket streams do not stall during bursty backend output.
2026-06-22 21:47:16 +02:00
Ilia Ross
a0b67db65b Fix to simplify Miniserv config lock handling
ⓘ Remove the obsolete eval around `flock` in the `miniserv` config lock helper and report lock, write, and close failures explicitly.
2026-06-22 20:41:02 +02:00
Ilia Ross
26311baab9 Fix to use Webmin config locking for ws-link cleanup
ⓘ Make linked websocket teardown use the same `miniserv.conf.lock` convention as `link.cgi`, release the lock safely on cleanup errors
2026-06-22 20:34:00 +02:00
Ilia Ross
7ba1a39271 Fix parent route cleanup work 2026-06-22 20:02:56 +02:00
Ilia Ross
45ca170c20 Add support to proxy linked-server WebSockets
This PR adds general WebSocket proxying for linked Webmin servers, allowing modules such as `xterm` to work when opened through `servers/link.cgi`.

As requested in https://github.com/webmin/webmin/issues/1866.
2026-06-22 16:19:33 +02:00
Jamie Cameron
ea02aeb04a Merge pull request #2768 from webmin/dev/miniserv-ipv6-cidr-1570
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
Fix IPv6 CIDR access control matching
2026-06-19 10:04:04 -07:00
Ilia Ross
a9c6fe724a Fix IPv6 CIDR access control matching
This PR fixes Webmin IP access control handling for IPv6 CIDR prefixes that are not divisible by 8, such as `/29` as mentioned in this https://github.com/webmin/webmin/issues/1570 ticket.

Before Webmin validation rejected non-byte-aligned IPv6 network sizes, and the runtime matcher compared IPv6 networks only by whole bytes. This meant valid IPv6 CIDR prefixes could not be used safely in access control rules.

Changes:
- Allow IPv6 access-control prefixes from `/0` through `/128`, without requiring divisibility by 8.
- Add bit-accurate IPv6 prefix matching for ACL checks.
- Apply the same matching behavior in both `miniserv.pl` and `webmin/webmin-lib.pl`.
- Fix IPv6 canonicalization for `::` and trailing `::` forms used by the matcher.
- Add regression tests for `/0`, `/29`, `/32`, `/63`, `/64`, `/127`, and `/128`.
2026-06-19 14:50:24 +02:00
bob7123
74bd78ae35 Fix indentation inside foreach loop per review 2026-06-18 08:23:45 +00:00
bob7123
8574c70d6b Register SNI callback on all SSL contexts, not just the default
setup_ssl_contexts() registers CTX_set_tlsext_servername_callback only
on the default (*) context. Per-IP contexts from ipcert entries do not
get the callback. When a client connects to a dedicated IP, the per-IP
context is used directly, the SNI callback never fires, and the wrong
certificate is served regardless of the requested hostname.

Fix: register the same SNI callback on every context in %ssl_contexts.
The callback function is unchanged. Clients without SNI still receive
the per-IP certificate. Clients with SNI get the correct certificate
matched by hostname.

Related: https://github.com/virtualmin/virtualmin-gpl/pull/1229

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-16 16:18:12 +00:00
Joe Cooper
fc6b66fcc0 Fix spaces to tabs 2026-05-20 16:15:40 -05:00
Joe Cooper
3e38e3268e Fix check_ip6address in miniserv 2026-05-20 14:04:53 -05:00
Joe Cooper
6458658bfb Fix encrypt_sha512 so it doesn't always fall back to crypt 2026-05-17 18:06:53 -05:00
Jamie Cameron
e36729f20b Merge branch 'master' of github.com:webmin/webmin
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
2026-05-13 20:56:25 -07:00
Jamie Cameron
96dd0ef65d Harden check for valid SSL SNI hostname 2026-05-13 20:56:18 -07:00
Ilia Ross
d367189711 Fix to reset remaining per-request keep-alive state too
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
https://github.com/webmin/webmin/pull/2699#issuecomment-4435490798
2026-05-14 00:38:34 +02:00
Jamie Cameron
7dd3902da8 Merge pull request #2699 from swelljoe/keep-alive-auth-state
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
Reset auth state in keep-alive proxied requests
2026-05-12 19:55:13 -07:00
Ilia Ross
c6647ce76c Fix to scope SSL cert auth user to one request
* Note: Declare the SSL certificate lookup user as lexical inside `handle_request`, so a previously matched client certificate user cannot survive into later keep-alive requests handled by the same miniserv child.

Enlightened by: https://github.com/webmin/webmin/pull/2699
2026-05-13 00:46:39 +02:00
Joe Cooper
29952dce1e Also reset already_authuser 2026-05-11 21:57:34 -05:00
Joe Cooper
d202eca8f8 Probably resolve proxied keep-alive requests retain auth state 2026-05-11 21:46:10 -05:00
Jamie Cameron
236c5cf489 Merge pull request #2695 from swelljoe/minserv-as-module
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
Wrap miniserv.pl server loop in unless (caller) so we can require miniserv for unit testing
2026-05-11 19:38:06 -07:00
Jamie Cameron
2c8ff4ba15 Merge pull request #2692 from swelljoe/session-dbm
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
Prefer SHA over MD5 or crypt for session hash, other minor session tweaks
2026-05-10 22:03:47 -07:00
Joe Cooper
4472f210b9 Wrap app in unless (caller) so we can require miniserv for unit testing 2026-05-10 22:11:21 -05:00
Joe Cooper
7aeb5e4dd7 Only create session key file when session=1 2026-05-10 20:57:09 -05:00
Joe Cooper
77d817357d Remove login_redirect 2026-05-10 20:52:09 -05:00
Joe Cooper
4c3f7f5bd9 Omit needless words 2026-05-10 10:58:50 -05:00
Joe Cooper
1b5e48841a Don't fall back to weak session hash, use SHA instead 2026-05-10 03:36:07 -05:00
Joe Cooper
241abfe719 Add trusted_proxies config 2026-05-10 01:19:01 -05:00
Jamie Cameron
f03140314e Merge branch 'master' of github.com:webmin/webmin
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
2026-04-16 20:02:02 -07:00
Jamie Cameron
6c77b24da6 The crypt function can natively support SHA512
https://github.com/webmin/webmin/issues/2656
2026-04-16 20:01:55 -07:00
Ilia Ross
da18a16c84 Fix to require 2FA for RPC basic auth
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
+ improve remote auth errors
2026-04-15 22:36:40 +02:00
Jamie Cameron
ba336c297b Make check for 'X-SSL-Client-Verify' header stricter 2026-04-14 16:19:22 -07:00
Ilia Ross
87d8969efb Fix to gate forwarded proxy URL for consistency
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
https://github.com/webmin/webmin/pull/2666#issuecomment-4241962133
2026-04-14 14:44:57 +02:00
Ilia Ross
bd7e91c712 Fix comment shift ; add missing comments
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
2026-04-12 19:03:12 +02:00
Ilia Ross
67950afe3a Add configurable redaction for logged request parameters 2026-04-12 19:01:14 +02:00
Ilia Ross
a6156ff76b Add configurable websocket origin exceptions (for weird cases) 2026-04-12 18:35:21 +02:00
Ilia Ross
6de6529bba Fix to harden session cookie defaults 2026-04-12 18:17:32 +02:00
Ilia Ross
cf98ce3f55 Fix to normalize websocket path matching 2026-04-12 18:10:22 +02:00
Ilia Ross
c0fb00a6e4 Fix to improve proxied connection validation
X260412
2026-04-12 18:08:57 +02:00
Ilia Ross
49b8f1a2fa Fix to improve proxied connection handling
X260412
2026-04-12 14:56:51 +02:00
Joe Cooper
316529c8ca typo s/actphost/acpthost/ 2026-04-06 22:27:52 -05:00
Jamie Cameron
3dbeb4e4db Don't trust proxy-provided SSL cert if it's flagged as not verified
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
2026-04-01 18:17:02 -07:00
Ilia Ross
2397653d55 Fix IPv6 hostname matching for alwaysresolve access rules
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
* Note: Fix Miniserv IPv6 hostname resolution and matching used by access control when `alwaysresolve` is enabled:
  1. Correct `to_ip6address()` success handling (before getaddrinfo result was interpreted backwards)
  2. In `ip_match()`, resolve hostnames with `to_ip6address()` for IPv6 clients instead of IPv4-only `to_ipaddress()`
  3. Canonicalize IPv6 addresses before reverse and forward verification to avoid format-based mismatches.
  4. Mirror the IPv6 logic change in "webmin/webmin-lib.pl"

https://forum.virtualmin.com/t/webmin-access-control-for-domain-names-with-ipv6/136661?u=ilia
2026-02-21 13:30:08 +02:00
Jamie Cameron
0342f06fc8 Remove dependency on IO::Pty for calling sudo
https://github.com/webmin/webmin/issues/2587
2025-11-18 21:04:48 -08:00
Jamie Cameron
3d300b5fb6 Handle perl errors calling PEM_read_bio_X509 more gracefully 2025-11-10 21:24:36 -08:00
Ilia Ross
d694649872 Fix to safely get user hostname from URL 2025-10-03 03:19:54 +03:00