5
0
mirror of git://git.proxmox.com/git/pve-http-server.git synced 2025-08-03 20:21:56 +03:00

157 Commits

Author SHA1 Message Date
8d393dc81e bump version to 3.2-5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-07-02 09:24:03 +02:00
75ad1cacb7 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>
2022-07-02 09:22:07 +02:00
3967071623 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>
2022-07-02 09:22:00 +02:00
42bb4f3725 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>
2022-07-02 09:22:00 +02:00
f325788131 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>
2022-07-02 09:22:00 +02:00
be2215c4c2 response: improve no content comment
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-07-02 09:22:00 +02:00
eff0454e69 bump version to 3.2-4
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-05-17 16:43:10 +02:00
00661f1223 html formatter: encode href attributes
these contain untrusted data, so treat them accordingly.

Reported-by: Li, Jian Tao <li.jiantao@starlabs.sg>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
(cherry picked from commit 6781735008)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-05-17 16:42:07 +02:00
cdaec513e0 bump version to 3.2-3
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2021-05-18 10:19:37 +02:00
d7e0d2c6bf 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>
2021-05-18 10:18:32 +02:00
13a73eee2a 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>
2021-05-18 10:18:32 +02:00
015964a341 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>
2021-05-18 10:18:32 +02:00
f8f97c8d26 buildsys: split packaging and source build-systems
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-14 16:37:17 +02:00
ec08ad30f5 d/control: drop unzip from build depends
is actually not required since quite a bit, i.e., commit
88628fd141 from my last bootstrapping
effort in 2019.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-14 15:13:08 +02:00
e69542b4c9 d/control: improve package description
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-14 15:12:05 +02:00
a008f818b4 d/control: bump compat level to 12
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-14 15:11:46 +02:00
0527add069 d/copyright: update years
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-14 15:11:22 +02:00
dacfcf3a3c bump version to 3.2-2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-07 17:50:07 +02:00
9494318e18 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>
2021-05-07 17:47:46 +02:00
c6de5b3f2d 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>
2021-05-07 17:47:46 +02:00
6d42e63792 bump version to 3.2-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-04-23 13:54:14 +02:00
51841e98fa 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>
2021-04-22 18:18:50 +02:00
389ad881f9 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>
2021-04-22 18:18:50 +02:00
9afe1e89ea 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>
2021-04-21 17:44:03 +02:00
6d832dbced 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>
2021-04-21 17:42:01 +02:00
e22eccff31 bump version to 3.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-12-11 08:41:44 +01:00
1e1692429a add debug log for problems during accept
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2020-12-10 20:23:38 +01:00
ebcaaf4606 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>
2020-12-10 20:23:38 +01:00
c82d1707ed 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>
2020-12-10 20:23:38 +01:00
26e73e6b9e 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>
2020-12-10 20:23:38 +01:00
a420cb361a bump version to 3.0-6
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-07-02 09:44:16 +02:00
e7ee5e3f75 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>
2020-07-02 07:58:45 +02:00
abef317256 fix post if variable declaration
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-06-05 09:07:29 +02:00
3e05f16607 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>
2020-06-05 09:07:29 +02:00
779306a757 bump version to 3.0-5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-09 16:12:51 +01:00
f1b41d8405 websocket_proxy: fix indentation
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-03-07 20:19:03 +01:00
e6cb79b52c 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>
2020-03-07 20:17:41 +01:00
c3bd22ec46 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>
2020-03-07 20:11:12 +01:00
c55702c39b 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>
2020-03-07 20:11:12 +01:00
597f8fb9d1 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>
2020-03-06 19:02:00 +01:00
9789c451a5 followup: indentation and error message improvement
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-06 19:01:40 +01:00
542f4c3a03 increase allowed spiceport range
by using the new spice_port_range sub from PVE::Tools

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-03-06 18:58:45 +01:00
bd8e8612d8 bump version to 3.0-4
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-01-29 21:36:08 +01:00
3d358efe29 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>
2020-01-29 21:36:08 +01:00
362dd8eb9a api-server: extract, set and handle API token header
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-28 20:43:51 +01:00
e045d0700e 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>
2020-01-28 20:43:51 +01:00
fa5e6f6908 update standards version
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-12-11 10:14:01 +01:00
aa6e7a0d63 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 ea574439f7.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-28 10:26:26 +01:00
f5fe153b48 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>
2019-10-17 17:36:06 +02:00
c66bf47bff bump version to 3.0-3
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-11 11:25:23 +02:00