Commit Graph

116 Commits

Author SHA1 Message Date
Markus Beth
5c900521f3 sec_decrypt() the correct amount of data
Save the correct amount of data to sec_decrypt() because after
inout_uint8p() the macro s_remaining(s) will find nothing left.
2019-06-13 14:12:25 +02:00
Pierre Ossman
25b8412333 Avoid poking around in STREAM internals
It's easy to make mistakes this way, and bypassed the normal bounds
checking. So make sure we always use macros or functions.
2019-05-06 14:33:38 +02:00
Pierre Ossman
c6d8b933c8 Avoid preallocated streams in tcp.c
We don't know when the caller might be done with a stream, so we
can end up with code overwriting things in a stream that is in use
elsewhere.

Solve the issue by returning a new stream each time and leave it
up to the callers to free it.
2019-05-06 14:33:05 +02:00
Pierre Ossman
75221eb3c5 Separate behaviour of out_uint8a and out_uint8p
Make them more match in_uint8a and in_uint8p in that one copies and
the other just gives you a pointer and it is up to the caller how
to fill it in. This can be useful when other APIs are used to
generate the data as it avoids a temporary buffer.
2019-05-06 14:33:05 +02:00
Pierre Ossman
6268b44f06 Add macro to check remaining length of STREAM
Avoids poking around in the internals, and also makes the code
easier to read.
2019-05-06 14:33:05 +02:00
Pierre Ossman
3e340f2f20 Add explicit STREAM allocation function
Avoids mistakes by making sure everyone allocates these the same
way.

The smart card code still has manual allocation because it has it's
own magical memory management.
2019-05-06 14:33:05 +02:00
Pierre Ossman
e099d79879 Remove dangerous s_check()
This macro checks if a pointer is valid _after_ we've already used
that pointer. So it will only trigger if we're already performed some
for of buffer overflow. As such, it provides little to no value and
can only server to encourage broken behaviour.

Let's remove it and replace it with proper bounds checking before
access instead.
2019-05-06 14:33:05 +02:00
Pierre Ossman
d8b0f3782a Give source code info in rdp_protocol_error()
Makes it easier to debug things by seeing exactly where the protocol
handling crashed.
2019-05-06 13:29:44 +02:00
Markus Beth
caae8af53c Fix memory leaks on certificate handling
Call rdssl_cert_free() for all certificates created with
rdssl_cert_read().
2019-02-05 22:48:32 +01:00
Alexander Zakharov
774a657975 Handle insufficient server side buffer for smartcard operations
We should pay attention to OutputBufferLength of DR_CONTROL_REQ
and send STATUS_BUFFER_TOO_SMALL if it's insufficient for returned
result.
2019-01-23 16:12:21 +03:00
Henrik Andersson
d12204b424 Bumb version of supported redirect PDU
Before this change we announce that we support redirection
packet version 3 (Microsoft RDP 5.1 and 5.2 clients), this
makes the server to only send back LB_TARGET_NET_ADDRESS which
includes an IP address for the redirection. Announcing version
4 (Microsoft RDP 6.0 and 6.1 clients) will make the server to
send a LB_TARGET_FQDN which solves a few problems, for example
using kerberos authentication.

Fixes issue #303
2019-01-22 13:20:13 +01:00
Henrik Andersson
4dca546d04 Malicious RDP server security fixes
This commit includes fixes for a set of 21 vulnerabilities in
rdesktop when a malicious RDP server is used.

All vulnerabilities was identified and reported by Eyal Itkin.

 * Add rdp_protocol_error function that is used in several fixes
 * Refactor of process_bitmap_updates
 * Fix possible integer overflow in s_check_rem() on 32bit arch
 * Fix memory corruption in process_bitmap_data - CVE-2018-8794
 * Fix remote code execution in process_bitmap_data - CVE-2018-8795
 * Fix remote code execution in process_plane - CVE-2018-8797
 * Fix Denial of Service in mcs_recv_connect_response - CVE-2018-20175
 * Fix Denial of Service in mcs_parse_domain_params - CVE-2018-20175
 * Fix Denial of Service in sec_parse_crypt_info - CVE-2018-20176
 * Fix Denial of Service in sec_recv - CVE-2018-20176
 * Fix minor information leak in rdpdr_process - CVE-2018-8791
 * Fix Denial of Service in cssp_read_tsrequest - CVE-2018-8792
 * Fix remote code execution in cssp_read_tsrequest - CVE-2018-8793
 * Fix Denial of Service in process_bitmap_data - CVE-2018-8796
 * Fix minor information leak in rdpsnd_process_ping - CVE-2018-8798
 * Fix Denial of Service in process_secondary_order - CVE-2018-8799
 * Fix remote code execution in in ui_clip_handle_data - CVE-2018-8800
 * Fix major information leak in ui_clip_handle_data - CVE-2018-20174
 * Fix memory corruption in rdp_in_unistr - CVE-2018-20177
 * Fix Denial of Service in process_demand_active - CVE-2018-20178
 * Fix remote code execution in lspci_process - CVE-2018-20179
 * Fix remote code execution in rdpsnddbg_process - CVE-2018-20180
 * Fix remote code execution in seamless_process - CVE-2018-20181
 * Fix remote code execution in seamless_process_line - CVE-2018-20182
2019-01-16 12:28:44 +01:00
Henrik Andersson
c16b74a974 Run indent-all.sh script on source 2018-10-29 15:53:57 +01:00
Karl Mikaelsson
08c293b405 Fix Fast-Path PDU decryption regression
This solves a problem where rdesktop would get really confused about
the data read from the server and crash in random places just after
connecting.
2018-02-02 17:13:36 +01:00
Henrik Andersson
b5708cf775 Refactoring of slow and fastpath handling
This changes clarifies a chunk of code related to receiving
data and handle slow and fast path pdus.
2018-02-01 12:47:22 +01:00
Cendio
58d8f78eea Add lots of protocol debug logging
Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Karl Mikaelsson <derfian@cendio.se>
2018-01-31 11:03:32 +01:00
Cendio
e112b69c61 Use proper user-initiated disconnect sequence
A correct user initated disconnect sequence should send
a MCS Disconnect Provider Ultimatum PDU defined in T.128
upon a disconnect. This commit adds the implementation
the mentioned PDU and the actual write of the packet.

Signed-off-by: Henrik Andersson <hean01@cendio.com>
2018-01-31 11:03:32 +01:00
Cendio
7f76e2218a Rename of global variable for clarity
Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Thomas Nilefalk <thoni56@cendio.se>
2018-01-11 15:10:05 +01:00
Cendio
ab50ea31cf Implement dynamic session resize
This adds support for resizing the RDP session dynamically based on
the window size. Some complicated logic has been added to avoid
sending excessive amounts of resize requests to the RDP server.

When supported, this resize mechanism should use the RDPEDISP way of
signalling the server to initiate a Deactivate/Activate sequence, but
rdesktop will fall back on Disconnect/Reconnect if RDPEDISP is not
supported by the server.

ui_select has been refactored and most functionality has been broken
out into three new functions, simplifying ui_select into a loop.

Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Karl Mikaelsson <derfian@cendio.se>
Signed-off-by: Thomas Nilefalk <thoni56@cendio.se>
2017-12-07 11:15:03 +01:00
Cendio
2f03f65efe Add Dynamic Virtual Channels and basic RDPEDISP support
Fix issue #192

Signed-off-by: Henrik Andersson <hean01@cendio.com>
Signed-off-by: Karl Mikaelsson <derfian@cendio.se>
2017-11-09 15:39:39 +01:00
René Genz
9e99dd52d6 Fix minor spelling mistakes 2017-11-02 01:01:44 +01:00
joshudson
fe692058a2 Add Windows 10 support: add option to send DPI to server as Windows 1… (#66)
Add support  for choosing DPI of remote session
2017-11-01 06:37:18 +01:00
Karl Mikaelsson
8c162a5563 Enable 32-bit color depths
To enable 32-bit color depths a earlyCapabilityFlag in the CS_CORE
packet is required. When 32-bit color depth is requested, this
RNS_UD_CS_WANT_32BPP_SESSION flag will now be set. We also advertise
support for 32-bit color depths through the RNS_UD_32BPP_SUPPORT flag.
2017-10-18 12:18:50 +02:00
Karl Mikaelsson
27e447555e Rename SEC_TAG_CLI_ constants to match specification 2017-10-17 12:29:41 +02:00
Karl Mikaelsson
3bb69ac4b8 Document sec_out_mcs_connect_initial_pdu
Cross-referenced the PDU with the spec. I found and fixed a few
inconsistencies while also adding comments identifying each data
field.
2017-10-17 12:17:13 +02:00
Karl Mikaelsson
fd0846ccee Rename sec_out_mcs_data to sec_out_mcs_connect_initial_pdu 2017-10-17 12:16:51 +02:00
Henrik Andersson
fd1673392e Fix unused-but-set-variable compiler warnings 2017-10-17 10:50:14 +02:00
Henrik Andersson
995e830665 Use new out_utf16s_padded() string function for fixed string 2017-09-29 16:30:17 +02:00
Karl Mikaelsson
a27c0ac4c8 Silence "sec_process_crypt_info(), failed to parse crypt info" msgs
If sec_parse_crypt_info returns false, it's not always a problem with
parsing the crypt info. It could very well be that Enhanced RDP
Security is used, which would trigger a false return value from the
function.

This commit adds new log messages to sec_parse_crypt_info for cases it
would return false and removes the incorrect catch-all message from
the caller.
2017-09-20 16:18:13 +02:00
Henrik Andersson
c93960b266 Cleanup of TS_SECURITY_HEADER code
Add correct naming of header TS_SECURITY_HEADER and its flags
as per MSRDPBCGR specification.
2017-03-07 15:32:14 +01:00
Henrik Andersson
87d8d123b8 Rework the logging system
This commit will add a logging system to solve the problem that
one actually need to recompile rdesktop from source to enable
different debug logging.

- Same logging api  for all kind of logging and messages to
   end user.

- Adding -v for verbose output when running rdesktop.

- All messages are logged into a subject and with a type, eg:

     logger(Keyboard, Notice, "Autos-electing %s based on locale.", locale);

- Debug logging is enabled trough a environment variable RDEKSTOP_DEBUG,
  which specifies subjects of interest, comma separated. There is a special
  subject named All which includes all subject for debug loggin. There is also
  a simple logic opeartor '!' = NOT which can be used in combination like:

    RDESKTOP_DEBUG=All,!Graphics,!Sound

  Which would give debug log output for All subject except Graphics and Sound.
2017-01-26 14:19:40 +01:00
Henrik Andersson
dbb87244dd Reset license issued state to make redirections work with issued device licenses.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1785 423420c4-83ab-492f-b58f-81f9feb106b5
2014-02-07 08:44:55 +00:00
Henrik Andersson
2503dbb9d9 Cleanup and clarify the implementation of TS_UD_CS_CLUSTER.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1762 423420c4-83ab-492f-b58f-81f9feb106b5
2013-11-28 11:10:35 +00:00
Henrik Andersson
51014c91df Initial implementation of kerberos server autentication with CredSSP,
disabled by default and is enabled using argument --enable-credssp
to configure script.

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1676 423420c4-83ab-492f-b58f-81f9feb106b5
2012-11-15 11:21:01 +00:00
Henrik Andersson
2664c4f92a Reset licens error status when restting state, fixes issue with
pending resize which would hang for ever.

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1673 423420c4-83ab-492f-b58f-81f9feb106b5
2012-11-08 12:15:24 +00:00
Peter Åstrand
5cb7910413 Indented with indent-all.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1670 423420c4-83ab-492f-b58f-81f9feb106b5
2012-10-23 11:38:27 +00:00
Henrik Andersson
0f5824d414 Rename of internal ssl_ wrapper functions/defines to
rdssl_ to prevent nameclashing with openssl library now
when we link against ssl library.

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1665 423420c4-83ab-492f-b58f-81f9feb106b5
2012-07-02 11:36:39 +00:00
Henrik Andersson
c44025aa18 Added support for protocol negotiation, this is a part of
adding Enhanced RDP Security support to rdesktop and brings
support for TLSv1 tunnel functionality.

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1659 423420c4-83ab-492f-b58f-81f9feb106b5
2012-06-15 05:16:20 +00:00
Henrik Andersson
cdce9aae75 Run indentation script.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1658 423420c4-83ab-492f-b58f-81f9feb106b5
2012-01-16 06:35:13 +00:00
Henrik Andersson
8a52bf3a9b - Change licensestore to XDG directory ~/.local/share/rdesktop/licenses
- Added helper functions for SHA1 hash to hash the hostname used for
  licenses filename to hide information of what host user X connects 
  from in a infrastructure with NFS mounted home directories.



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1644 423420c4-83ab-492f-b58f-81f9feb106b5
2011-11-21 10:51:08 +00:00
Peter Åstrand
b638882347 Include emails in copyright statements.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1615 423420c4-83ab-492f-b58f-81f9feb106b5
2011-04-13 11:13:04 +00:00
Peter Åstrand
27068f53f8 Updated the copyright notices for the things we have been working on.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1612 423420c4-83ab-492f-b58f-81f9feb106b5
2011-04-13 08:55:42 +00:00
Michael Gernoth
360b4a3faa fix two problems found by clang static analyzer
secure.c:  Dereference of null pointer
xkeymap.c: Pass-by-value argument in function call is undefined

both seem to be noncritical, as sec_recv is never called with a null
pointer and ensure_remote_modifiers only accesses initialized fields


git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1589 423420c4-83ab-492f-b58f-81f9feb106b5
2010-04-07 11:39:29 +00:00
Peter Åstrand
1b4c36a45f Implemented support for "Client Auto-Reconnect". This means that the
client can re-connect using a cookie, instead of going through the
normal authentication. This patch saves those cookies, and uses them
during logon. 

Note that this feature is currently unused. It remains to add support
for, say, detecting when the TCP connection has gone done and restart
a new one. 



git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1539 423420c4-83ab-492f-b58f-81f9feb106b5
2010-01-12 10:34:38 +00:00
Peter Åstrand
281d7c9f06 Changed license to GPLv3
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1534 423420c4-83ab-492f-b58f-81f9feb106b5
2010-01-12 08:31:06 +00:00
Peter Åstrand
440542c535 Elminate code duplication in rdp_reconnect and sec_connect.
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1528 423420c4-83ab-492f-b58f-81f9feb106b5
2010-01-07 20:01:58 +00:00
Jay Sorg
88855ddcbf update the copyright year
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@1474 423420c4-83ab-492f-b58f-81f9feb106b5
2008-07-11 03:51:23 +00:00
Jay Sorg
6e2ac16e15 indent
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@1389 423420c4-83ab-492f-b58f-81f9feb106b5
2007-02-10 05:28:54 +00:00
Jay Sorg
d3349e6087 g_ prefix for global vars
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@1388 423420c4-83ab-492f-b58f-81f9feb106b5
2007-02-10 05:15:58 +00:00
Jay Sorg
6c626e9e53 call ssl.c set key function, not openssl
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@1384 423420c4-83ab-492f-b58f-81f9feb106b5
2007-01-27 20:38:30 +00:00