Commit Graph

45 Commits

Author SHA1 Message Date
matt335672
b1147f5faa CVE-2022-23479
Detect attempts to overflow input buffer

If application code hasn't properly sanitised the header_size
for a transport, it is possible for read requests to be issued
which overflow the input buffer. This change detects this
at a low level and bounces the read request.
2022-12-09 17:34:25 +00:00
a1346054
7fe18cc1c0
fix typos 2022-09-03 02:01:48 +00:00
matt335672
79bec8110c Unify connection fields for the connected client
The connected client is currently described in two places in
the xrdp_client_info structure:-

1) In the connection_description field. This was introduced as
   field client_ip by commit d797b2cf49
   for xrdp v0.6.0

2) In the client_addr and client_port fields introduced by commit
   25369460a1 for xrdp v0.8.0

This commit unifies these two sets of fields into a single
set of fields describing the connection IP and port (for
AF_INET/AF_INET6 connections only) and a connection description
for all connection types.

The code in os_calls to provide client logging has been simplified
somewhat which should make it easier to add new connection types (e.g.
AF_VSOCK).

The old connection_description field used to be passed to sesman to
inform sesman of the IP address of the client, and also to provide
a string for 'C' field session policy matching. 'C' field session policy
matching does not actually need this string (see #2239), and so now only
the IP field is passed to sesman.
2022-05-18 12:35:07 +01:00
matt335672
275eaf7683 Rework transport connect logic
There are a number of ways the existing transport connect logic in
trans_connect could be improved for POSIX compatibility, and also
slightly tidied up:-
1) The same socket is re-used for multiple connect attempts following
   failure which isn't behaviour defined by POSIX.1-2017 (although it
   works on Linux).
2) An asynchronous connect is started, and then after a short
   delay connect() is called again on the same socket. POSIX.1-2017
   is clear that in this situation EALREADY is returned before the
   connection is established, but is silent on the behaviour expected
   when the connection is established. Returning success is an option,
   but so is returning EISCONN. The current code assumes the connect()
   call will succeed.
3) The code contains two virtually identical, quite complex loops for
   TCP and UNIX sockets, differing only in the calls to create a socket
   and connect it.
4) trans_connect() contains looping and retry logic, but this isn't
   seen as sufficient by the chansrv connect code in xrdp/xrdp_mm.c and
   the Xorg connect code in xup/xup.c. Both of these implement their own
   looping and retry logic on top of the logic in trans_connect(),
   resulting in slightly unpredictable behaviour with regard to
   timeouts.
5) A socket number can technically be zero, but in a couple of places
   this isn't allowed for.

This PR attempts to correct the implementation of trans_connect(),
and also to simplify the areas it is called from.

As part of the PR, the signature of the server_is_term member of the
xrdp module interface is changed to match the signature expected by the
is_term member of a struct trans. This allows for trans_connect()
in xrdp modules to directly access g_is_term() within the main xrdp
executable. At the moment this functionality is only used by the xup
module.
2022-03-31 20:48:07 +01:00
matt335672
8f4860cb55 Add subclassing capability to struct trans 2022-03-15 10:23:27 +00:00
matt335672
c9afd804a4 Minor const and comment fixes 2021-07-27 13:36:34 +01:00
Alexandre Quesnel
bb9d3079c0 Fixing formatting with astyle in common/* 2021-03-14 23:33:31 +00:00
Matt Burt
1f8bb57fd6 Improve source_info commenting and fix neutrino slow link 2020-10-20 09:55:17 +01:00
Jay Sorg
0bc7803eaa add TCP V4 and V6 only socket functions 2019-06-29 23:59:18 -07:00
Ben Cohen
3b5b7a5935 UDS file deleted after first connection
If you run xrdp with a Unix Domain Socket (UDS) for the port specified in
/etc/xrdp/xrdp.ini then the first connection succeeds but subsequent
connections fail.  In fact the UDS is deleted from the filesystem as soon
as the first connection is established.

Test case:

1. Edit /etc/xrdp/xrdp.ini to set "port=/var/run/xrdp-local.socket".

2. Restart xrdp.

3. Run the following.  When rdesktop starts up and the logon dialog is
   displayed, press "Cancel".

   sudo socat TCP-LISTEN:12345 UNIX-CONNECT:/var/run/xrdp-local.socket &
   rdesktop localhost:12345

4. Run the following:

    sudo socat TCP-LISTEN:12346 UNIX-CONNECT:/var/run/xrdp-local.socket &
    rdesktop localhost:12346

Expected behaviour: rdesktop starts up and displays the logon dialog.
Observed behaviour: rdesktop exits with "ERROR: Connection closed" and
                    socat exits with "No such file or directory.

This is because in the child process after forking, xrdp_listen_fork()
calls trans_delete() which deletes the UDS.  Simply commenting out the
g_file_delete() and g_free() fixes this, but that isn't a proper solution
because trans_delete() is called from elsewhere where the UDS might no
longer be wanted.

Fix by adding a function trans_delete_from_child() that frees and clears
listen_filename before calling trans_delete(), and call the new function
from xrdp_listen_fork().

(Workaround: set "fork=false" in /etc/xrdp/xrdp.ini, because
trans_delete() is then not called.)
2018-03-27 09:22:49 +03:00
Jay Sorg
26507644e3 vsock, move some defines 2017-11-07 18:20:45 -08:00
Justin Terry (VM)
50bd624cc4 Implements XRDP over vsock
1. Implements the ability to use AV_VSOCK for the transport rather than TCP.
2. Updates the ini file to be able to conditionally turn this feature on.
2017-11-07 18:20:45 -08:00
Pavel Roskin
6ed4c969f4 Eliminate APP_CC and DEFAULT_CC 2017-03-14 00:21:48 -07:00
Koichiro IWAO
e94ab10e14 TLS: new method to specify SSL/TLS version
SSL/TLS protocols only listed in ssl_protocols should be used.
The name "ssl_protocols" comes from nginx.

Resolves #428.
2017-02-27 14:17:25 +09:00
Idan Freiberg
19375dda7a Merge pull request #426 from metalefty/log-tls-version-and-cipher
TLS: log TLS version and cipher
2017-01-16 07:26:51 +02:00
Pavel Roskin
f1a521204a Remove redundant function declarations 2017-01-11 23:25:42 -08:00
Koichiro IWAO
40e8194122 TLS: log TLS version and cipher 2016-11-22 10:50:30 +09:00
Alex Illsley
47124df4ed new options for xrdp.ini disableSSlv3=yes and tls_ciphers=HIGH and code to implement 2016-08-25 11:20:47 -07:00
Pavel Roskin
0c72ee2371 Use char* for TLS send and receive
This is consistent with ssl_tls_read() and ssl_tls_write(). C++ warnings
are fixed without adding any casts.
2016-07-08 04:29:56 +00:00
Jay Sorg
6c23b85593 add timeout to trans_get_wait_objs_rw 2015-07-13 01:10:48 -07:00
Jay Sorg
b56aa9832e work on main loop changes 2015-07-05 23:14:46 -07:00
Jay Sorg
cc0406dddf common: move tls calls to ssl_calls 2014-11-25 18:55:37 -08:00
Jay Sorg
5a8bf87c7f common: tls, fix for pending reads 2014-11-21 20:49:01 -08:00
speidy
4015f526db work on tls mode 2014-08-22 09:13:33 +03:00
Jay Sorg
386512c0ed common: fix some warning for TLS 2014-07-31 16:46:58 -07:00
Jay Sorg
abf5549524 common: indent, not logic change 2014-07-25 21:21:48 -07:00
Idan Freiberg
afdf638c7b libxrdp, common: work on TLS mode 2014-07-23 15:31:45 +03:00
Idan Freiberg
f0b6c6b1d1 libxrdp: started adding TLS support 2014-07-15 18:29:40 +03:00
Jay Sorg
148c1f858c common: indent, no logic change to trans.h 2014-04-20 20:24:05 -07:00
Jay Sorg
374633e63f common: no logic change, update comments 2014-03-01 23:26:40 -08:00
Jay Sorg
f6fb5a32ed common: added some trans options used in fast path 2014-02-25 20:33:19 -08:00
Jay Sorg
1deac46fdc common: add trans_get_wait_objs_rw to header 2013-12-04 15:26:23 -08:00
Jay Sorg
25369460a1 log client ip with pid, etc 2013-10-02 16:27:12 -07:00
Jay Sorg
3b743f64eb chansrv: deadlock, add trans copy func 2013-09-23 18:08:22 -07:00
Jay Sorg
dfd78c722b chansrv: fix for deadlock 2013-09-23 12:16:52 -07:00
Jay Sorg
e602a28d5c common: transport aware when app is terminating 2013-08-17 13:32:53 -07:00
Jay Sorg
c6fa03102f copyright year update 2013-06-08 10:51:53 -07:00
ArvidNorr
a2bbbd8cc3 Display PAM error in gateway setup, use domain name as IP/DNS, changed how the socket is closed 2013-01-16 01:28:35 -08:00
Laxmikant Rashinkar
1123323fda o moved from GNU General Public License to Apache License, Version 2.0
o applied new coding standards to all .c files
o moved some files around
2012-09-19 20:51:34 -07:00
norrarvid
a45f993bfe added comments, added define, removed unused inparameter 2012-05-29 12:46:56 +02:00
Jay Sorg
1e8b5ea2cd bind to specific address 2010-10-19 21:23:13 -07:00
jsorg71
27e097663f improve trans 2010-05-04 07:37:22 +00:00
jsorg71
2a7c40dad8 add unix socket to trans 2009-09-05 03:29:43 +00:00
jsorg71
6c5f82fd04 update copyright year 2009-02-02 08:01:44 +00:00
jsorg71
643e22a6e5 added trans files 2008-08-22 06:08:11 +00:00