]> git.proxmox.com Git - pve-http-server.git/log
pve-http-server.git
21 months agorequests: assert that theres no @ in the URLs authority
Thomas Lamprecht [Sat, 2 Jul 2022 06:27:02 +0000 (08:27 +0200)]
requests: assert that theres no @ in the URLs authority

We don't expect any userinfo in the authority and t o avoid that this
allows some leverage in doing weird things later its better to error
out early on such requests.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Originally-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
21 months agopass through streaming: only allow from privileged local pvedaemon
Thomas Lamprecht [Sat, 2 Jul 2022 05:59:50 +0000 (07:59 +0200)]
pass through streaming: only allow from privileged local pvedaemon

Ensures that no external request can control streaming on proxying
requests as safety net for when we'd have another issue in the
request handling part.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Originally-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
21 months agoproxy request: assert that API url starts with a slash
Thomas Lamprecht [Sat, 2 Jul 2022 05:56:12 +0000 (07:56 +0200)]
proxy request: assert that API url starts with a slash

We implicitly assume that to be the case when assembling the target
URL, so assert it explicitly as it's user controlled input.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Originally-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
21 months agoresponse: avoid linefeeds in response status
Thomas Lamprecht [Fri, 1 Jul 2022 09:32:54 +0000 (11:32 +0200)]
response: avoid linefeeds in response status

basically only possible to trigger with chromium based browsers
(chrome, edge, opera) but besides those having the biggest usage
currently its not that nice in any way.

Users could inject headers in their response, which isn't really that
bad itself, as they won't really do anything at least for sane
browsers that don't allow setting third party cookies by default
(unlike again, chrome), in which case one can create huge cookies
that then trigger the max header size check on requests, DOS'ing an
user's access to a PVE interface if they can get them to visit a
malicious site (a clear cooki actione would allow visiting it again)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reported-by: STAR Labs <info@starlabs.sg>
21 months agoresponse: improve no content comment
Thomas Lamprecht [Fri, 1 Jul 2022 08:14:31 +0000 (10:14 +0200)]
response: improve no content comment

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
23 months agobump version to 4.1-2
Thomas Lamprecht [Tue, 17 May 2022 14:40:33 +0000 (16:40 +0200)]
bump version to 4.1-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
23 months agohtml formatter: encode href attributes
Fabian Grünbichler [Tue, 17 May 2022 12:48:27 +0000 (14:48 +0200)]
html formatter: encode href attributes

these contain untrusted data, so treat them accordingly.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agotls: log failure to apply TLS 1.3 ciphers
Fabian Grünbichler [Tue, 18 Jan 2022 11:35:49 +0000 (12:35 +0100)]
tls: log failure to apply TLS 1.3 ciphers

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agobump version to 4.1-1
Thomas Lamprecht [Thu, 13 Jan 2022 12:32:47 +0000 (13:32 +0100)]
bump version to 4.1-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agofix #3789: allow disabling TLS v1.2/v1.3
Fabian Grünbichler [Fri, 17 Dec 2021 12:57:29 +0000 (13:57 +0100)]
fix #3789: allow disabling TLS v1.2/v1.3

SSL 2 and 3 are already disabled by default by us, and TLS 1.1 and below
are disabled by default on Debian systems.

requires corresponding patch in pve-manager to have an effect.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agofix #3745: allow overriding TLS key location
Fabian Grünbichler [Fri, 17 Dec 2021 12:57:28 +0000 (13:57 +0100)]
fix #3745: allow overriding TLS key location

when using a custom pveproxy certificate. actual handling is done in
pve-manager.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agofix #3790: allow setting TLS 1.3 cipher suites
Fabian Grünbichler [Fri, 17 Dec 2021 12:57:27 +0000 (13:57 +0100)]
fix #3790: allow setting TLS 1.3 cipher suites

like the TLS <= 1.2 cipher list, but needs a different option since the
format and values are incompatible. AnyEvent doesn't yet handle this
directly like the cipher list, so set it directly on the context.

requires corresponding patch in pve-manager (which reads the config, and
passes relevant parts back to the API server).

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agofix #3807: don't attempt response on closed handle
Fabian Grünbichler [Wed, 29 Dec 2021 11:15:34 +0000 (12:15 +0100)]
fix #3807: don't attempt response on closed handle

if a client closes the connection while the API server is
waiting/stalling here, the handle will disappear, and sending a response
is no longer possible.

(this issue is only cosmetic, but if such clients are a regular
occurrence it might get quite noisy in the logs)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agosmall indentation and code cleanup
Thomas Lamprecht [Thu, 13 Jan 2022 12:09:44 +0000 (13:09 +0100)]
small indentation and code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoavoid warning if request params do not exists
Thomas Lamprecht [Thu, 13 Jan 2022 12:09:11 +0000 (13:09 +0100)]
avoid warning if request params do not exists

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoWS: guard disconnect block check properly
Fabian Grünbichler [Fri, 17 Dec 2021 09:55:34 +0000 (10:55 +0100)]
WS: guard disconnect block check properly

if the WS gets disconnected without any data having been sent first,
wbuf (and thus `length $wbuf`) is undef. the actual length of the buffer
is not relevant here anyway, just the fact that it's non-empty - so
avoid the undef warning by dropping the unnecessary comparison.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agobump version to 4.0-4
Thomas Lamprecht [Wed, 24 Nov 2021 17:14:57 +0000 (18:14 +0100)]
bump version to 4.0-4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agohttp: split and sort use statements
Thomas Lamprecht [Wed, 24 Nov 2021 17:13:14 +0000 (18:13 +0100)]
http: split and sort use statements

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agodownload-stream: allow the api call to set the content-encoding
Dominik Csapak [Wed, 24 Nov 2021 14:47:47 +0000 (15:47 +0100)]
download-stream: allow the api call to set the content-encoding

this is useful if we want to pipe the output of a program e.g. through gzip

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoconstructor: split TLS flags to separate lines
Thomas Lamprecht [Tue, 16 Nov 2021 06:34:01 +0000 (07:34 +0100)]
constructor: split TLS flags to separate lines

easier to grasp what's actually being set..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agofix #3724: disable TLS renegotiation
Stoiko Ivanov [Mon, 15 Nov 2021 20:50:43 +0000 (21:50 +0100)]
fix #3724: disable TLS renegotiation

The issue is probably not critical and best addressed by not running
the perl API servers in an exposed environment or when this needs to
be done by installing a reverse proxy in front of them.

The DOS potential of the perl daemons is limited more by the limited
number of parallel workers (and the memory constraints of starting
more of them), than by the CPU cycles wasted on TLS renegotiation.

Still disabling TLS renegotiation should show very little downside:
* it was removed in TLS 1.3 for security reasons
* it was the way nginx addressed this issue [1].
* we do not use client certificate authentication

Tested by running `openssl s_client -no_tls1_3 -connect 192.0.2.1:8006`
and issuing a `HEAD / HTTP/1.1\nR\n`
with and without the patch.

[1] 70bd187c4c386d82d6e4d180e0db84f361d1be02 at
    https://github.com/nginx/nginx (although that code adapted to
    the various changes in openssl API over the years)
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agowebproxy: handle unflushed write buffer
Fabian Grünbichler [Thu, 11 Nov 2021 14:07:13 +0000 (15:07 +0100)]
webproxy: handle unflushed write buffer

for proxied requests, we usually tear down the proxy connection
immediately when closing the source connection. this is not the correct
course of action for bulk one-way data streams that are proxied, where
the source connection might be closed, but the proxy connection might
still have data in the write buffer that needs to be written out.

push_shutdown already handles this case (closing the socket/FH after it
has been fully drained).

one example for such a proxied data stream is the 'migrate' data for a
remote migration, which gets proxied over a websocket connection.
terminating the proxied connection early makes the target VM crash for
obvious reasons.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agobuildsys: change upload dist to bullseye
Thomas Lamprecht [Mon, 4 Oct 2021 08:21:12 +0000 (10:21 +0200)]
buildsys: change upload dist to bullseye

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agobump version to 4.0-3
Thomas Lamprecht [Mon, 4 Oct 2021 08:18:38 +0000 (10:18 +0200)]
bump version to 4.0-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: wrap-and-sort -tkn
Thomas Lamprecht [Mon, 4 Oct 2021 08:13:57 +0000 (10:13 +0200)]
d/control: wrap-and-sort -tkn

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: break libpve-storage-perl (<< 7.0-11)
Thomas Lamprecht [Mon, 4 Oct 2021 08:13:21 +0000 (10:13 +0200)]
d/control: break libpve-storage-perl (<< 7.0-11)

as only newer version cleanup temp files on their own.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoanyevent: move unlink from http-server to endpoint
Lorenz Stechauner [Tue, 31 Aug 2021 10:16:28 +0000 (12:16 +0200)]
anyevent: move unlink from http-server to endpoint

any uploaded file has to be deleted by the corrosponding
endpoint. the file upload was only used by the 'upload to
storage' feature in pve.

this change allows the endpoint to delete the file itself,
making the old and racey`sleep 1` (waiting until the worker
has opened the file) obsolete.

this change breaks all pve-manager versions, in which the
worker does not unlink the temp file itself.

Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
2 years agobump version to 4.0-2
Fabian Grünbichler [Tue, 18 May 2021 08:19:37 +0000 (10:19 +0200)]
bump version to 4.0-2

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agowebsocket: add note about compat removal
Fabian Grünbichler [Tue, 18 May 2021 07:25:15 +0000 (09:25 +0200)]
websocket: add note about compat removal

this major release still needs to have an incompatible client, the next
one can drop setting a protocol client-side, and the one after that can
remove the protocol handling on the server side.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoAnyEvent/websocket_proxy: drop handling of websocket subprotocols
Dominik Csapak [Mon, 17 May 2021 13:07:35 +0000 (15:07 +0200)]
AnyEvent/websocket_proxy: drop handling of websocket subprotocols

We do not support any, and we only ever send binary frames, so drop
trying to parse the header.

For compatibility with current clients (novnc, pve-xtermjs), we have
to reply with the protocols it sent.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agoAnyEvent/websocket_proxy: remove 'base64' handling
Dominik Csapak [Mon, 17 May 2021 13:07:34 +0000 (15:07 +0200)]
AnyEvent/websocket_proxy: remove 'base64' handling

novnc does not support this anymore since 2015, and neither does
our xtermjs client. it is also not listed in IANAs list of websocket
protocols [0].

so simply drop it and only send out binary frames and don't decode text frames

0: https://www.iana.org/assignments/websocket/websocket.xml#subprotocol-name

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agobump version to 4.0-1
Thomas Lamprecht [Fri, 14 May 2021 14:38:26 +0000 (16:38 +0200)]
bump version to 4.0-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agobuildsys: split packaging and source build-systems
Thomas Lamprecht [Fri, 14 May 2021 14:37:17 +0000 (16:37 +0200)]
buildsys: split packaging and source build-systems

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: drop unzip from build depends
Thomas Lamprecht [Fri, 14 May 2021 13:13:06 +0000 (15:13 +0200)]
d/control: drop unzip from build depends

is actually not required since quite a bit, i.e., commit
88628fd1414cc87c782083734a80b39aa4b806cc from my last bootstrapping
effort in 2019.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: improve package description
Thomas Lamprecht [Fri, 14 May 2021 13:12:05 +0000 (15:12 +0200)]
d/control: improve package description

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: bump compat level to 12
Thomas Lamprecht [Fri, 14 May 2021 13:11:46 +0000 (15:11 +0200)]
d/control: bump compat level to 12

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/copyright: update years
Thomas Lamprecht [Fri, 14 May 2021 13:11:22 +0000 (15:11 +0200)]
d/copyright: update years

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agobump version to 3.2-2
Thomas Lamprecht [Fri, 7 May 2021 15:50:07 +0000 (17:50 +0200)]
bump version to 3.2-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoaccess control: also include ipv6 in 'all'
Stoiko Ivanov [Wed, 5 May 2021 14:36:27 +0000 (16:36 +0200)]
access control: also include ipv6 in 'all'

Net::IP objects are bound to a version - 0/0 is treated as ipv4 only.
If 'all' is present in the allow_from/deny_from list we should also
add ::/0 for matching all ipv6 addresses.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agoaccess control: correctly match v4-mapped-v6 addresses
Stoiko Ivanov [Wed, 5 May 2021 14:36:26 +0000 (16:36 +0200)]
access control: correctly match v4-mapped-v6 addresses

With recent changes to the listening socket code in pve-manager
the proxy daemons now usually bind to '::' and ipv4 clients are
read as v4-mapped-v6 addresses [0] from ::ffff:0:0/96.

This caused the allow_from/deny_from matching to break.

This patch addresses the issue by normalizing addresses from
::ffff:0:0/96 using Net::IP::ip_get_embedded_ipv4
(which roughly splits on ':' and checks if the last part looks like an
ipv4 address).

Issue was originally reported in our community forum [1]

[0] https://en.wikipedia.org/wiki/IPv6_address
[1] https://forum.proxmox.com/threads/my-pveproxy-file-doesnt-work.83228/

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agobump version to 3.2-1
Thomas Lamprecht [Fri, 23 Apr 2021 11:54:14 +0000 (13:54 +0200)]
bump version to 3.2-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoallow stream download from path and over pvedaemon-proxy
Stefan Reiter [Thu, 22 Apr 2021 15:34:53 +0000 (17:34 +0200)]
allow stream download from path and over pvedaemon-proxy

Allow specifying a filepath for stream=1 instead of either a path or fh
with stream=1.

With this in place, we can also just return the path to the proxy in
case we want to stream a response back, and let it read from the file
itself. This way, the pvedaemon is cut out of the transfer pipe.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2 years agosupport streaming data form fh to client
Stefan Reiter [Thu, 22 Apr 2021 15:34:52 +0000 (17:34 +0200)]
support streaming data form fh to client

Use an explicit AnyEvent::Handle similar to websocket proxying.

Needs some special care to make sure we apply backpressure correctly to
avoid caching too much data. Note that because of AnyEvent restrictions,
specifying a "fh" to point to a file or a packet-based socket may result
in unwanted behaviour[0].

[0]: https://metacpan.org/pod/AnyEvent::Handle#DESCRIPTION

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2 years agoutils: add LISTEN_IP option in /etc/default/pveproxy
Oguz Bektas [Mon, 22 Mar 2021 14:00:45 +0000 (15:00 +0100)]
utils: add LISTEN_IP option in /etc/default/pveproxy

to allow setting arbitrary IP address to listen on

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Tested-by: Dylan Whyte <d.whyte@proxmox.com>
Reviewed-by: Dylan Whyte <d.whyte@proxmox.com>
2 years agoallow 'download' to be passed from API handler
Stefan Reiter [Wed, 21 Apr 2021 11:15:35 +0000 (13:15 +0200)]
allow 'download' to be passed from API handler

PVE::HTTPServer in pve-manager wraps the API return value in a 'data'
element, look for a 'download' element there too to allow an API call to
instruct the HTTP server to return a file via path or filehandle.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
3 years agobump version to 3.1-1
Thomas Lamprecht [Fri, 11 Dec 2020 07:41:44 +0000 (08:41 +0100)]
bump version to 3.1-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoadd debug log for problems during accept
Stoiko Ivanov [Thu, 10 Dec 2020 14:02:51 +0000 (15:02 +0100)]
add debug log for problems during accept

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoaccept-phase: shutdown socket on early error
Stoiko Ivanov [Thu, 10 Dec 2020 14:02:50 +0000 (15:02 +0100)]
accept-phase: shutdown socket on early error

if an error happens before AnyEvent::Handle registers the cleanup
callback, we should shutdown/close the socket, when handling it.

Using close, instead of shutdown($sock, SHUT_WR) here, since we are in
an error-state, and would not read from the socket anyways.
(Additionally close sends just on packet (RST,ACK), vs shutdown
(FIN,ACK+RST,ACK) in its use here).

Co-Authored-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoaccept-phase: fix conn_count "leak"
Stoiko Ivanov [Thu, 10 Dec 2020 14:02:49 +0000 (15:02 +0100)]
accept-phase: fix conn_count "leak"

When handling new connections in 'accept_connections' the number of
active connections (conn_count) got increased before the callback, which
would eventually decrease it got registered in AnyEvent::Handle->new.

Any error/die before registering the callback would skip the
decrement, and leave the process in an endless loop upon exiting in
wait_end_loop.

This can happen e.g. when the call to getpeername fails, or if the
connection is denied by the ALLOW_FROM/DENY_FROM settings in
'/etc/default/pveproxy' (which is also a simple reproducer for that).

Additionally it can cause a denial of service, by attempting to
connect from a denied ip until the connection count exeeds the maximum
connections of all child-processes.

This patch addresses the issue by incrementing the connection count
before attempting to create the handle, and decrementing it again, if
handle creation fails.

A warning is logged if 'conn_count' turns negative when decrementing
during cleanup on error/eof. In case creating a new handle during
initial accept_connection fails, a warning is logged as well, but
'conn_count' is not decremented.

Reported via our community-forum:
https://forum.proxmox.com/threads/pveproxy-eats-available-ram.79617/

Co-Authored-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoadd debug print helper
Stoiko Ivanov [Thu, 10 Dec 2020 14:02:48 +0000 (15:02 +0100)]
add debug print helper

and uniformly use it

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agobump version to 3.0-6
Thomas Lamprecht [Thu, 2 Jul 2020 07:44:16 +0000 (09:44 +0200)]
bump version to 3.0-6

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoincrease max headers to 64 to cope with modern browsers + proxy combinations
Thomas Lamprecht [Thu, 2 Jul 2020 05:54:52 +0000 (07:54 +0200)]
increase max headers to 64 to cope with modern browsers + proxy combinations

This is mostly a "do not allow infinity headers" limit in the sense
of "it's good to have limits". With modern browsers and users behind
proxies we may actually get over 30 headers, so increase it for now
to 64 - hopefully enough for another decade ;)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reported-by: Victor Hooi <victorhooi@yahoo.com>
3 years agofix post if variable declaration
Dominik Csapak [Fri, 29 May 2020 13:29:01 +0000 (15:29 +0200)]
fix post if variable declaration

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agofix #2766: allow application/json as content-type for post/put requests
Dominik Csapak [Fri, 29 May 2020 13:29:00 +0000 (15:29 +0200)]
fix #2766: allow application/json as content-type for post/put requests

this makes creating an api client much nicer

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agobump version to 3.0-5
Thomas Lamprecht [Mon, 9 Mar 2020 15:12:51 +0000 (16:12 +0100)]
bump version to 3.0-5

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agowebsocket_proxy: fix indentation
Fabian Grünbichler [Fri, 6 Mar 2020 10:20:30 +0000 (11:20 +0100)]
websocket_proxy: fix indentation

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agowebsocket_proxy: implement ping/pong support
Fabian Grünbichler [Fri, 6 Mar 2020 10:20:29 +0000 (11:20 +0100)]
websocket_proxy: implement ping/pong support

needed to keep tunnel connections alive.

> The Ping frame contains an opcode of 0x9.
> [...]
> The Pong frame contains an opcode of 0xA.
-- Section 5.5.2 cf. https://tools.ietf.org/html/rfc6455#section-5.5.2

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agowebsocket_proxy: pull out encoding into helper sub
Fabian Grünbichler [Fri, 6 Mar 2020 10:20:28 +0000 (11:20 +0100)]
websocket_proxy: pull out encoding into helper sub

to allow adding other types of frames.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agowebsocket: improve masking performance
Fabian Grünbichler [Fri, 6 Mar 2020 10:20:27 +0000 (11:20 +0100)]
websocket: improve masking performance

in order to make websocket proxying feasible as general tunnel, we need
to be able to transfer more than a few MB/s

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agod/control: bump versioned dependency to pve-common
Thomas Lamprecht [Fri, 6 Mar 2020 18:01:56 +0000 (19:01 +0100)]
d/control: bump versioned dependency to pve-common

to ensure that we've PVE::Tools::spice_port_range available

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofollowup: indentation and error message improvement
Thomas Lamprecht [Fri, 6 Mar 2020 18:01:40 +0000 (19:01 +0100)]
followup: indentation and error message improvement

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoincrease allowed spiceport range
Dominik Csapak [Tue, 3 Mar 2020 09:47:31 +0000 (10:47 +0100)]
increase allowed spiceport range

by using the new spice_port_range sub from PVE::Tools

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agobump version to 3.0-4
Thomas Lamprecht [Wed, 29 Jan 2020 08:32:08 +0000 (09:32 +0100)]
bump version to 3.0-4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agod/control: versioned break pve-manager and pmg-api
Thomas Lamprecht [Tue, 28 Jan 2020 20:18:06 +0000 (21:18 +0100)]
d/control: versioned break pve-manager and pmg-api

due to incompatible new cookie/header extraction method

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi-server: extract, set and handle API token header
Fabian Grünbichler [Tue, 21 Jan 2020 12:54:20 +0000 (13:54 +0100)]
api-server: extract, set and handle API token header

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agoallow ticket in auth header as fallback
Tim Marx [Tue, 21 Jan 2020 12:54:19 +0000 (13:54 +0100)]
allow ticket in auth header as fallback

based on idea & RFC by Tim Marx, incorporating feedback by Thomas
Lamprecht. this will be extended to support API tokens in the
Authorization header as well, so make it generic.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agoupdate standards version
Thomas Lamprecht [Wed, 11 Dec 2019 09:14:01 +0000 (10:14 +0100)]
update standards version

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoRevert "tls: make dh to openssl 1.1 compatible"
Thomas Lamprecht [Fri, 25 Oct 2019 15:34:27 +0000 (17:34 +0200)]
Revert "tls: make dh to openssl 1.1 compatible"

The libanyevent-perl version 7.140-3 included a fix for this.
It migrated to the then still testing (buster was not yet released)
on 07.04.2019, and so we can safely revert this workaround again
here.

Albeit this was fixed since Buster was officially released, still
bump the version dependency to libanyevent-perl in debian/control.

A future libanyevent-perl will use "ffdhe3072" for DH; another good
reason to revert this, to not keep hardcoded parameters with possible
(future) security implications here.

[0]: https://tracker.debian.org/news/1037514/libanyevent-perl-7140-3-migrated-to-testing/

This reverts commit ea574439f76bb3914b8b8c0be8e40ee826c95afc.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoproxy_request: drop duplicate, unused parameter
Fabian Grünbichler [Thu, 17 Oct 2019 13:14:10 +0000 (15:14 +0200)]
proxy_request: drop duplicate, unused parameter

which was mistakenly added back when this was still in pve-manager.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agobump version to 3.0-3
Thomas Lamprecht [Fri, 11 Oct 2019 09:25:23 +0000 (11:25 +0200)]
bump version to 3.0-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoAnyEvent: extend send_file with content-type
Dominik Csapak [Thu, 10 Oct 2019 09:21:51 +0000 (11:21 +0200)]
AnyEvent: extend send_file with content-type

for pmg, we need to send temporary files (for the attachment quarantine),
but we cannot know beforehand what content-type it is, so we
optionally give it to send_file_start

we give a hash with the open filehandle and the content-type in that case

this also removes the unnecessary open on the filename, since we open
it in send_file_start anyway...

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agobump version to 3.0-2
Thomas Lamprecht [Thu, 11 Jul 2019 17:30:36 +0000 (19:30 +0200)]
bump version to 3.0-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agodecode_urlencoded: cope with undefined values
Thomas Lamprecht [Tue, 9 Jul 2019 12:04:42 +0000 (14:04 +0200)]
decode_urlencoded: cope with undefined values

Avoids syslog/journal warning like:
>  Use of uninitialized value $v in substitution (s///) at
>  /usr/share/perl5/PVE/APIServer/AnyEvent.pm line 648.

If one passes a "value-less" GET argument to a request, e.g.,
GET /?debug

Besides the fact that this allows us to even use such arguments it
also is a general improvement against a slight "syslog DOS attack",
because anybody can pass such parameters to the '/' page, and all
proxmox daemons providing a API/UI using libpve-http-server-perl
allow to do such requests unauthenticated (which itself is OK, as
else one could not show the login window at all). As each of such
request produces two log lines in the syslog/journal it's far from
ideal.

A simple reproducer of the possible outcome can be seen with the
following shell script using curl:

> PVEURL='127.0.0.1'
> ARGS='?a'; # send multiple args at once to amplify the per-connection cost
> for c in {a..z}; do for i in {0..9}; do ARGS="$ARGS&$c$i"; done; done
> while true; do curl --insecure --silent --output /dev/null "https://$PVEURL:8006$ARGS"; done

Not really bad, but not nice either, as logging is not too cheap this
has some resource usage cost and noise in the syslog is never nice.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agore-use Debians jQuery and Bootstrap packages
Thomas Lamprecht [Wed, 22 May 2019 06:10:58 +0000 (08:10 +0200)]
re-use Debians jQuery and Bootstrap packages

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoanyevent: rpcenv is optional and from our child instance
Thomas Lamprecht [Wed, 22 May 2019 06:07:17 +0000 (08:07 +0200)]
anyevent: rpcenv is optional and from our child instance

This fixes the simple-demo, which was regressed with commit
8782148642e4a09c5852781ec057017cc1145f17 were we falsely assumed that
we always have an rpcenv instance here, but actually that's just
optional as it comes from our child class instance

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobuildsys: switch upload dist over to buster
Thomas Lamprecht [Wed, 22 May 2019 05:39:03 +0000 (07:39 +0200)]
buildsys: switch upload dist over to buster

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobuildsys: also cleanup build directory on clean
Thomas Lamprecht [Wed, 22 May 2019 05:23:11 +0000 (07:23 +0200)]
buildsys: also cleanup build directory on clean

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobuildsys: no need to include arch detection for arch-independent package
Thomas Lamprecht [Tue, 21 May 2019 20:25:36 +0000 (22:25 +0200)]
buildsys: no need to include arch detection for arch-independent package

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobuildsys: clean and distclean are phony targets
Thomas Lamprecht [Tue, 21 May 2019 19:43:05 +0000 (21:43 +0200)]
buildsys: clean and distclean are phony targets

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobump version to 3.0-1
Thomas Lamprecht [Tue, 21 May 2019 19:39:36 +0000 (21:39 +0200)]
bump version to 3.0-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobuildsys: fix dependencies for bootstrap files
Thomas Lamprecht [Tue, 21 May 2019 19:37:12 +0000 (21:37 +0200)]
buildsys: fix dependencies for bootstrap files

avoid removing and unzipping the bootstrap source archive as many
times as ${BTDATA} has file entries, add an intermediate target for
the directory, which is the producer for all those BTDATA files, and
that directory then depends on the zip archive.

I mean, it would be even better to just use the libjs-bootstrap
package (and jQuery for that matter) but that a little bigger change
for now

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoupdate Bootstrap to 3.4.1
Thomas Lamprecht [Tue, 21 May 2019 19:26:10 +0000 (21:26 +0200)]
update Bootstrap to 3.4.1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoupdate jQuery to 3.4.1
Thomas Lamprecht [Tue, 21 May 2019 19:12:37 +0000 (21:12 +0200)]
update jQuery to 3.4.1

by bumping and actually using ${JQVER} when downloading ;)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobuildsys: use dpkg-dev makefile helpers for pkg info
Thomas Lamprecht [Tue, 21 May 2019 19:25:11 +0000 (21:25 +0200)]
buildsys: use dpkg-dev makefile helpers for pkg info

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agobump version to 2.0-13
Thomas Lamprecht [Wed, 3 Apr 2019 11:56:04 +0000 (13:56 +0200)]
bump version to 2.0-13

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agoforward Host header in proxy_request
Wolfgang Bumiller [Tue, 2 Apr 2019 10:22:03 +0000 (12:22 +0200)]
forward Host header in proxy_request

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agostore Host header in rpc environment
Wolfgang Bumiller [Tue, 2 Apr 2019 10:22:02 +0000 (12:22 +0200)]
store Host header in rpc environment

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agotls: make dh to openssl 1.1 compatible
Thomas Lamprecht [Fri, 22 Mar 2019 09:32:46 +0000 (10:32 +0100)]
tls: make dh to openssl 1.1 compatible

Effective the same approach used in libanyevent-perl 7.140-3[0]
Stretch is also compatible with this, and we can remove it for
buster/PVE 6 once the libanyevent-perl package transitioned to
from unstable to buster, until then do it ourself to have a
functioning api/proxy...

[0]: https://salsa.debian.org/perl-team/modules/packages/libanyevent-perl/commit/7f3d5721bb915c0c24088c3ff361238938172108

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agobump version to 2.0-12
Thomas Lamprecht [Tue, 26 Feb 2019 06:08:11 +0000 (07:08 +0100)]
bump version to 2.0-12

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agoAdd short comment about users of read_proxy_config
Stoiko Ivanov [Fri, 22 Feb 2019 18:52:00 +0000 (19:52 +0100)]
Add short comment about users of read_proxy_config

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
5 years agomove read_proxy_conf from PVE::API2Tools to new Utils module
Stoiko Ivanov [Fri, 22 Feb 2019 18:51:59 +0000 (19:51 +0100)]
move read_proxy_conf from PVE::API2Tools to new Utils module

move the read_proxy_conf method into a new perl module
'PVE::APIServer::Utils'.
It now takes the proxy_name (e.g. pveproxy, pmgproxy) as variable to be used
for the configfile location (/etc/default/$proxy_name)

This serves as preparation to make pmgproxy configurable in the same way as
pveproxy.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agoadd ssl fallback values to AnyEvent->new
Stoiko Ivanov [Fri, 22 Feb 2019 18:51:58 +0000 (19:51 +0100)]
add ssl fallback values to AnyEvent->new

This allows for sharing the values between pveproxy and pmgproxy

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
5 years agofollowup: adapt coding style to surrounding
Thomas Lamprecht [Thu, 21 Feb 2019 09:44:26 +0000 (10:44 +0100)]
followup: adapt coding style to surrounding

compression is set to true by default, and we only want to be able to
switch it off, not force it on.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agoDon't override explicit $nocomp with default
Stoiko Ivanov [Thu, 21 Feb 2019 09:35:11 +0000 (10:35 +0100)]
Don't override explicit $nocomp with default

By making compression configurable the $nocomp flag in response got set to
the configured (or default) setting, irrespective of the explicitly passed
value to response.

This broke (e.g.) noVNC connections

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
5 years agoAdd configurable 'compression'
Stoiko Ivanov [Fri, 15 Feb 2019 11:36:00 +0000 (12:36 +0100)]
Add configurable 'compression'

Rationale for disabling compression is the potential for being affected by
the BREACH (CVE-2013-3587) attack and it's considered good practice for https
configuration (see e.g. [0]).

The default remains: to have compression enabled for compressible file-types.

[0] https://cipherli.st/

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
5 years agoAdd configurable 'honor_cipher_order'
Stoiko Ivanov [Fri, 15 Feb 2019 11:35:59 +0000 (12:35 +0100)]
Add configurable 'honor_cipher_order'

Needed to fix #2069.

Prefering the ciphers set in the server, instead of relying on the offer of the
client is considered good practice in TLS1.[012] (see e.g. [0]).

[0] https://cipherli.st/

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
5 years agobump version to 2.0-11
Thomas Lamprecht [Fri, 28 Sep 2018 08:42:07 +0000 (10:42 +0200)]
bump version to 2.0-11

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agofix #1935: read empty line after 200 OK
Dominik Csapak [Fri, 28 Sep 2018 07:36:39 +0000 (09:36 +0200)]
fix #1935: read empty line after 200 OK

commit a4d8bbafbe400be78bebeab169963025dc46e29b
introduced an additional empty line after '200 OK'
for remote-viewer 7 to work, but we also have to read this line
in our own proxy reader else the connection to a remote node does
not work

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
5 years agoUse https for Homepage URL
Rhonda D'Vine [Thu, 6 Sep 2018 09:43:43 +0000 (11:43 +0200)]
Use https for Homepage URL

Signed-off-by: Rhonda D'Vine <rhonda@proxmox.com>
5 years agoAdd unzip to Build-Depends
Rhonda D'Vine [Thu, 6 Sep 2018 09:43:42 +0000 (11:43 +0200)]
Add unzip to Build-Depends

Signed-off-by: Rhonda D'Vine <rhonda@proxmox.com>