0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00
Commit Graph

3997 Commits

Author SHA1 Message Date
RenovateBot
2ff8029eba chore(deps): update dependency chriskohlhoff/asio to asio-1-30-1 2024-04-10 12:00:45 +00:00
illia.polishchuk
458826d784 Make the inactive behavior similar to openvpn2
By resetting the timer on each incoming packet, we can capture more gaps.
Consider the following examples:

Old logic:
0 seconds: openvpn3 starts with an inactive timeout of 60 seconds.
30 seconds: An ICMP packet was received with 48 bytes.
60 seconds: 48 bytes received for the last 60 seconds, continue...
90 seconds: An ICMP packet was received with 48 bytes.
120 seconds: 48 bytes received...

New logic:
0 seconds: openvpn3 starts with an inactive timeout of 60 seconds.
30 seconds: An ICMP packet was received with 48 bytes.
Inactive timeout reset!.
90 seconds: Inactive timeout triggered. Terminating session..."

Signed-off-by: illia.polishchuk illia.polishchuk@openvpn.com
2024-04-08 12:11:28 +00:00
Charlie Vigue
dd115d2e83 Fix RouteBase string formatting bug
When correcting conversion issues in RouteBase a to_string bug was
introduced which caused some characters to be escaped when inserted
to the string, for example a prefix_len of 0 would render as "\0"
rather than inserting '0'. The std::ios::binary flag does not seem
to prevent this for std::ostringstream so I have cast the data member
up to uint16_t which should be safe, and solves the issue.

Added a unit test to demonstrate the issue. Old code output was
"0.0.0.0/\0", now outputs "0.0.0.0/0" as expected.

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-03-29 03:13:00 +00:00
RenovateBot
e150bb3985 chore(deps): update dependency google/googletest to v1.14.0 2024-03-28 11:27:25 +00:00
RenovateBot
70c0d9a534 chore(deps): update dependency chriskohlhoff/asio to asio-1-29-0 2024-03-28 11:27:24 +00:00
Mark Deric
8558312d92 Fix client logging problems
A refactoring of the logging code in commit 9ffa263b removed
conventional #ifndef header guards and replaced them with #pragma
once.  Some consumers of the code used the header #defines to guide
their behavior.  The missing guards caused the consumers to log
incorrectly.  The fix was to still rely on the #pragma once for
guarding, but to reinstate the #defines from the original headers.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2024-03-28 11:27:23 +00:00
Mark Deric
5955f05eab Improve C2os unit tests with better templates
Signed-off-by: Mark Deric <jmark@openvpn.net>
2024-03-28 11:27:23 +00:00
Frank Lichtenheld
91a62654fe renovate: add global Core configuration
So that we override values from the global Ops
configuration we do not like.

While here change rebaseWhen. Since we do rebase
everything before merge anyway, let's renovate
do it for us.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-03-28 11:27:22 +00:00
Mark Deric
18e92a823f Extend C2os to handle containers of pointers
Create a new cast to tell the ostreamer to dereference before
inserting.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2024-03-22 15:15:10 +00:00
Illia Polishchuk
00bdf8ba8b Make profile errors clearer for users by reporting specific error codes.
ERR_INVALID_OPTION_DNS -- invalid value for some of DNS\Domain options
ERR_INVALID_OPTION_CRYPTO -- invalid value for some of SSL\Crypto option
ERR_INVALID_CONFIG -- missing option or not supported option
ERR_INVALID_OPTION_PUSHED -- pushed to server option error
ERR_INVALID_OPTION_VAL -- invalid value for some general option

Signed-off-by: Illia Polishchuk <illia.polishchuk@openvpn.com>
2024-03-22 15:15:09 +00:00
Illia Polishchuk
447c942395 Add codes support to option_error for clearer messages.
Signed-off-by: Illia Polishchuk <illia.polishchuk@openvpn.com>
2024-03-22 15:15:09 +00:00
Illia Polishchuk
c2b7a39a1b Simplify creation of exceptions with codes by a new macro
The OPENVPN_EXCEPTION_WITH_CODE(C, DEFAULT_CODE, ...)
macro creates enum C_code with __VA_ARGS__ codes
and constructor with the C_code as first argument which
adds label at the beginning of error message, other
constructors add DEFAULT_CODE label

Signed-off-by: Illia Polishchuk <illia.polishchuk@openvpn.com>
2024-03-22 15:15:09 +00:00
Frank Lichtenheld
9b63b1e3be Do not check for C++ <= 17
Code should now silently assume C++-17 semantics.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-03-19 12:23:44 +01:00
Antonio Quartulli
1216f566e4 sitnl: allow user to configure custom metric for routes
Until now sitnl was just default to metric 0 when installing routes,
while ignoring any value that may have been passed by the user.

Extend logic to properly accept a user value.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2024-03-15 13:27:14 +00:00
Antonio Quartulli
1e23850291 tunnetlink.hpp: remove unused include
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2024-03-15 13:27:14 +00:00
Antonio Quartulli
56dbd2ceec TunBuilderCapture: use default route metric if none was specified
When the user specifies no metric (i.e. value is -1), the TunBuilder
should pass the default value down the stack.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2024-03-15 13:27:14 +00:00
Frank Lichtenheld
f8c7d0629f
Manage more parts of GHA with renovate
- Add custom rule for vcpkg
- Add custom rule for repository checkouts

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-03-13 16:43:53 +01:00
Frank Lichtenheld
4a51628afe
Tweaking renovate config
- Group GHA updates and set them to monthly schedule to
  drastically reduce the numbers of PRs
- Notify about GoogleTest updates

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-03-13 16:43:52 +01:00
RenovateBot
ad0e0f5e7a
Add renovate.json 2024-03-13 16:43:27 +01:00
Antonio Quartulli
9eeeb38c45
unit-test: fix sitnl systematic failure
It was noted that the SITNL unit test is always failing for no clear
reason.

It turned out that commit 22ba196429
("SITNL: revert change of sitnl_send return type, return int"),
that was supposed to be a simple revert of
ae663c573a ("Using new numeric
conversion tools") is actually converting two "return ret" into
return -1 and return -EINVAL accordingly.

This accidental change results in two functions always returning
an error despite terminating succesfully.

This behaviour was obviously fooling the unitest which failed in result.

Fix both functions by properly returning "ret" as it was originally.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2024-03-12 09:47:54 +01:00
Frank Lichtenheld
8c007de79d client: Explicitely use int as socket type in SWIG
For some reason SWIG doesn't seem to pick this
up automatically from the typedefs.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-03-06 13:00:04 +01:00
Arne Schwabe
282075fee9 Allow test_sslctx to work with mbed TLS
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-02-23 15:32:58 +01:00
Arne Schwabe
c1bcf78d2e Add support for mbed TLS 3.0
This currently still depends on the mbed TLS compat API functionality.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-02-23 15:32:58 +01:00
Mark Deric
ade5f80f8a Add doxygen comments to simplified logging files
Signed-off-by: Mark Deric <jmark@openvpn.net>
2024-02-21 10:04:12 -08:00
Mark Deric
9ffa263bc8 Remove old and/or unneeded code from logging
Also, update copyright dates

Signed-off-by: Mark Deric <jmark@openvpn.net>
2024-02-21 08:58:43 -08:00
Mark Deric
e5c850cc82 Untangle log header macro/class globs
The purpose of this change is to allow headers that require the
logbase.hpp classes to compile in executables using logsimple.hpp.

By munging classes and macros into both headers, an avoidable conflict
of macro re-definition is created.  This commit separates the classes
from the macros into new headers. Then propagates the mistake into the
current headers so none of the existing code is broken. ;-)

Signed-off-by: Mark Deric <jmark@openvpn.net>
2024-02-21 07:27:38 -08:00
David Sommerseth
bae10062b3
Merging in changes from OpenVPN 3 Core version 3.8.4
Signed-off-by: David Sommerseth <davids@openvpn.net>
2024-02-19 22:46:53 +01:00
David Sommerseth
8f4cd953b2
Release: OpenVPN 3 Core Library, version 3.8.4
Signed-off-by: David Sommerseth <davids@openvpn.net>
2024-02-13 18:07:01 +01:00
Lev Stipakov
b4a400f6fe Improve handling of unknown options
Currently we error out on the first unsupported
option which belongs to the "fatal" category, such as
"removed deprecated option" or "Option allowed only to
be pushed by the server".

To improve user experice and allow application code
to display all problematic options and their categories,
collect options into a category->options map and then
serialize it into multiline string:

  cat1: opt1,opt2
  cat2: opt3

Introduce a new error code UNUSED_OPTIONS, which is
placed into ClientAPI::Status::status. The serialized
options map is placed into ClientAPI::Status::message.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-02-07 17:03:45 +02:00
Charlie Vigue
cb9ce3d71c
Add notes to sslctx and add unit tests
- Add notes regarding some unexpected behaviors in sslctx
- Add unit tests specifically for sslctx, including simple in-memory
handshaking with both success and failure examples.

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-02-01 13:29:21 +01:00
Frank Lichtenheld
fe40d7288f
Change some arguments to const refs
Triggered by move suggestions from Coverity.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-01-31 17:02:47 +01:00
Frank Lichtenheld
fdf55e8776
ovpncli: simplify Client::open_url()
Remove unused argument "flags".

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-01-31 17:02:46 +01:00
Frank Lichtenheld
eaf9147fcd
Add various moves as suggested by Coverity
Out of all the suggestions by Coverity I picked
the ones that move non-Ptr objects into variables
or attributes.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-01-31 17:02:45 +01:00
Frank Lichtenheld
853169a566
Fix various "auto causes copy" Coverity warnings
No reason not to fix those.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-01-31 17:02:28 +01:00
Arne Schwabe
afdfe1bb3f
Fix accessing a null pointer when PKCS7 is invalid
If we get a valid but almost empty PKCS7 structure we otherwise try
to access invalid fields.

CVE: CVE-2023-6247
Reported-by: Bahaa Naamneh <bahaa.cpl@gmail.com>
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-01-25 12:02:12 +01:00
Charlie Vigue
f4f8caa400
Refactor RC - readability and doxygen
- Split big classes into declaration and definition
- Added doxygen

The goal here is to add make the classes easier to reason about by
splitting them into declaration and definition and then adding
doxygen.

The notify parts are left intentionally undocumented for now.

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-01-24 19:17:12 +01:00
Charlie Vigue
9f3d32b2f4
Add virtual default DTOR to ClientEvent::Base
ClientEvent::Base is the base class for many other classes including
a few that add data members. If at some point one of these enhanced
derived classes is referenced and then deleted via a base class
pointer, some memory could leak.

I don't think we do that yet, but it seems worth preventing.

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-01-24 16:24:14 +01:00
Charlie Vigue
b06252bb5d Cleanup API for JSON, map() --> asObject() etc
- .map() --> .asObject()
- .array() --> .asArray()

Required by changes in JSON API

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-01-23 13:21:53 +00:00
Arne Schwabe
1824aaed1d
Use OpenSSL 3.0 API for generating TLS 1.0 PRF
When compiling against OpenSSL 3.0, use the newer API for generating the
TLS 1.0 PRF.  Older OpenSSL versions will use the OpenSSL 1.x API.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-01-10 21:01:46 +01:00
Charlie Vigue
6bc9c0bd59
Check length of response before accessing it
The NTLM protocol implementation does not validate the length of
the proxy server’s response. If the response is shorter than
expected, the code will access the response buffer out of bounds,
which will raise an exception. This change checks and explicitly
raises an exception with an informative message if the response
is too short.

This was never a security issue as such but might result in a client
terminating early and without a nice diagnostic.

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-01-08 21:32:17 +01:00
Arne Schwabe
8ad83b5ae8 Add missing length check in parsing ACC messages, add more related tests
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-01-04 17:51:23 +01:00
Arne Schwabe
8bfdc2809b Implement various fixes to avoid copying argument related to appcontrol 2024-01-04 17:51:23 +01:00
Frank Lichtenheld
44aa9acab2
ClientProto::Session: fix coverity issue "declaration hides parameter"
CID 11873: (#12 of 12): Parse warning (PW.PARAMETER_HIDDEN)
parameter_hidden: declaration hides parameter "e"

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-12-20 23:18:33 +01:00
Frank Lichtenheld
185426c5e8
ServerProto::Session: fix coverity issue "declaration hides parameter"
CID 11809: (#2 of 3): Parse warning (PW.PARAMETER_HIDDEN)
parameter_hidden: declaration hides parameter "e"

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-12-20 23:18:33 +01:00
Frank Lichtenheld
b4082c93cb
WS::Client::HTTPCore: fix coverity issue "declaration hides parameter"
CID 11948: (#2 of 2): Parse warning (PW.PARAMETER_HIDDEN)
parameter_hidden: declaration hides parameter "error"

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-12-20 23:18:33 +01:00
Frank Lichtenheld
9524e33727
ClientOptions: fix coverity error "Structurally dead code"
CID 11851: (#1 of 1): Structurally dead code (UNREACHABLE)
unreachable: This code cannot be reached

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-12-20 23:18:32 +01:00
Mark Deric
5b3294202c Prefer special purpose accessor to public
Instead of exposing protected data to the global environment, provide
a special purpose accessor to satisfy AppControl needs.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2023-12-20 08:29:55 -08:00
Arne Schwabe
c151efc908 Allow specifying different client and server reasons for disconnect
Currently PG only allows to either send or withhold the reason to the
client but there are certain circumstances where you want to have more
detailed internal reason but still want to send some reason to the
client.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-12-13 16:51:22 +01:00
Arne Schwabe
2910164ebf Add helper method for reliable uniform int for unit tests
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-12-13 16:51:22 +01:00
Arne Schwabe
95b821a2fd Allow to string methods of IP::Addr to display mapped IPv4 as plain IPv4
Some systems like to see the mapped IPv4 addresses as real IP addresses.
This commit adds the ability to show IP addresses as such.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-12-13 16:51:22 +01:00