Disable multiple deferred authentication plug-ins
v5 cover Disable multiple deferred authentication plug-ins
From: David Sommerseth <[email protected]...>
This is the same patch set as the v4 [1] patch set, just without the embarrassing syntax error in the second patch.
[1] <https://www.mail-archive.com/[email protected]/msg23935.html>
Message-Id: [email protected]...
David Sommerseth (3):
sample-plugin: New plugin for testing multiple auth plugins
plug-ins: Disallow multiple deferred authentication plug-ins
plug-ins: Remove defer/simple.c sample plugin
doc/openvpn.8 | 13 + doc/tests/authentication-plugins.md | 153 +++++++ sample/sample-plugins/defer/README | 9 +- sample/sample-plugins/defer/multi-auth.c | 413 +++++++++++++++++ sample/sample-plugins/defer/simple.c | 541 ----------------------- sample/sample-plugins/defer/simple.def | 6 - src/openvpn/plugin.c | 33 +- 7 files changed, 616 insertions(+), 552 deletions(-) create mode 100644 doc/tests/authentication-plugins.md create mode 100644 sample/sample-plugins/defer/multi-auth.c delete mode 100644 sample/sample-plugins/defer/simple.c delete mode 100755 sample/sample-plugins/defer/simple.def
Signature · 1 line
2.27.0
PATCH v5 1/3 sample-plugin: New plugin for testing multiple auth plugins
From: David Sommerseth <[email protected]...>
This plugin allows setting username/passwords as well as configure deferred authentication behaviour as part of the runtime initialization.
With this plug-in it is easier to test various scenarios where multiple authentication plug-ins are active on the server side.
A test documentation was also added to describe various test cases and the expected results.
---
v3 - Flipped NULL==var/NULL!=var to (var)/(!var) in if() block
--- doc/tests/authentication-plugins.md | 153 +++++++++ sample/sample-plugins/defer/README | 8 + sample/sample-plugins/defer/multi-auth.c | 413 +++++++++++++++++++++++ 3 files changed, 574 insertions(+) create mode 100644 doc/tests/authentication-plugins.md create mode 100644 sample/sample-plugins/defer/multi-auth.c
doc/tests/authentication-plugins.md new file +153 -0
@@ -0,0 +1,153 @@ +# TESTING OF MULTIPLE AUTHENTICATION PLUG-INS + + +OpenVPN 2.x can support loading and authenticating users through multiple +plug-ins at the same time. But it can only support a single plug-in doing +deferred authentication. However, a plug-in supporting deferred +authentication may be accompanied by other authentication plug-ins **not** +doing deferred authentication. + +This is a test script useful to test the various combinations and order of +plug-in execution. + +The configuration files are expected to be used from the root of the build +directory. + +To build the needed authentication plug-in, run: + + make -C sample/sample-plugins + + +## Test configs + +* Client config + + verb 4 + dev tun + client + remote x.x.x.x + ca sample/sample-keys/ca.crt + cert sample/sample-keys/client.crt + key sample/sample-keys/client.key + auth-user-pass + +* Base server config (`base-server.conf`) + + verb 4 + dev tun + server 10.8.0.0 255.255.255.0 + dh sample/sample-keys/dh2048.pem + ca sample/sample-keys/ca.crt + cert sample/sample-keys/server.crt + key sample/sample-keys/server.key + + +## Test cases + +### Test: *sanity-1* + +This tests the basic authentication with an instant answer. + + config base-server.conf + plugin multi-auth.so S1.1 0 foo bar + +#### Expected results + - Username/password `foo`/`bar`: **PASS** + - Anything else: **FAIL** + + +### Test: *sanity-2* + +This is similar to `sanity-1`, but does the authentication +through two plug-ins providing an instant reply. + + config base-server.conf + plugin multi-auth.so S2.1 0 foo bar + plugin multi-auth.so S2.2 0 foo bar + +#### Expected results + - Username/password `foo`/`bar`: **PASS** + - Anything else: **FAIL** + + +### Test: *sanity-3* + +This is also similar to `sanity-1`, but uses deferred authentication +with a 1 second delay on the response. + + plugin multi-auth.so S3.1 1000 foo bar + +#### Expected results + - Username/password `foo`/`bar`: **PASS** + - Anything else: **FAIL** + + +### Test: *case-a* + +Runs two authentications, the first one deferred by 1 second and the +second one providing an instant response. + + plugin multi-auth.so A.1 1000 foo bar + plugin multi-auth.so A.2 0 foo bar + +#### Expected results + - Username/password `foo`/`bar`: **PASS** + - Anything else: **FAIL** + + +### Test: *case-b* + +This is similar to `case-a`, but the instant authentication response +is provided first before the deferred authentication. + + plugin multi-auth.so B.1 0 foo bar + plugin multi-auth.so B.2 1000 test pass + +#### Expected results + - **Always FAIL** + - This test should never pass, as each plug-in expects different + usernames and passwords. + + +### Test: *case-c* + +This is similar to the two prior tests, but the authentication result +is returned instantly in both steps. + + plugin multi-auth.so C.1 0 foo bar + plugin multi-auth.so C.2 0 foo2 bar2 + +#### Expected results + - **Always FAIL** + - This test should never pass, as each plug-in expects different + usernames and passwords. + + +### Test: *case-d* + +This is similar to the `case-b` test, but the order of deferred +and instant response is reversed. + + plugin ./multi-auth.so D.1 2000 test pass + plugin ./multi-auth.so D.2 0 foo bar + +#### Expected results + - **Always FAIL** + - This test should never pass, as each plug-in expects different + usernames and passwords. + + +### Test: *case-e* + +This test case will run two deferred authentication plug-ins. This is +**not** supported by OpenVPN, and should therefore fail instantly. + + plugin ./multi-auth.so E1 1000 test1 pass1 + plugin ./multi-auth.so E2 2000 test2 pass2 + +#### Expected results + - The OpenVPN server process should stop running + - An error about multiple deferred plug-ins being configured + should be seen in the server log. + +
sample/sample-plugins/defer/README +8 -0
@@ -5,12 +5,20 @@ Examples provided: simple.c -- using the --auth-user-pass-verify callback, test deferred authentication. +multi-auth.c -- Test plug-in for testing multiple authentication + plug-ins in the same OpenVPN server configuration. + Only tested on Linux. + To build: ./build simple (Linux/BSD/etc.) + ./build multi-auth (Linux/BSD/etc.) ./winbuild simple (MinGW on Windows) To use in OpenVPN, add to config file: plugin simple.so (Linux/BSD/etc.) plugin simple.dll (MinGW on Windows) + +For the multi-auth.so, see the documentation in +doc/tests/authentication-plugins.md
sample/sample-plugins/defer/multi-auth.c new file +413 -0
413 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [Openvpn-devel] [PATCH v2.4 v5 1/3] sample-plugin: New plugin for testing multiple auth plugins
Hi,
Quoted 5 lines · David Sommerseth
From: David Sommerseth <[email protected]...>
This plugin allows setting username/passwords as well as configure deferred authentication behaviour as part of the runtime initialization.
Quoted 7 lines
With this plug-in it is easier to test various scenarios where multiple authentication plug-ins are active on the server side.
A test documentation was also added to describe various test cases and the expected results.
Signed-off-by David Sommerseth <[email protected]...>
We've discussed this on IRC, and decided to not invest further work into 2.4 for this - the 2.5 plugin will work, but "fiddling with the build stuff" is left as an excercise for the reader, as we consider 2.4 to be effectively "out of maintenance, only critical bugfixes".
Thus, formal NAK on this.
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...PATCH v5 2/3 plug-ins: Disallow multiple deferred authentication plug-ins
In reply to David SommersethFrom: David Sommerseth <[email protected]...>
The plug-in API in OpenVPN 2.x is not designed for running multiple deferred authentication processes in parallel. The authentication results of such configurations are not to be trusted. For now we bail out when this discovered with an error in the log.
CVE: 2022-0547
---
Note: The man page snippet is copied from the generated nroff formatting from the git master generated man page.
v3 - flip CONSTANT==var to var==CONSTANT in if() clause v4 - Use M_FATAL instead of M_ERR
v5 - Fix missing ) in if() clause
--- doc/openvpn.8 | 13 +++++++++++++ src/openvpn/plugin.c | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-)
doc/openvpn.8 +13 -0
@@ -2805,6 +2805,19 @@ function (such as tls\-verify, auth\-user\-pass\-verify, or client\-connect), then every module and script must return success (0) in order for the connection to be authenticated. + +.INDENT 7.0 +.TP +.B \fBWARNING\fP: +Plug\-ins may do deferred execution, meaning the plug\-in will +return the control back to the main OpenVPN process and provide +the plug\-in result later on via a different thread or process. +OpenVPN does \fBNOT\fP support multiple authentication plug\-ins +\fBwhere more than one of them\fP do deferred authentication. +If this behaviour is detected, OpenVPN will shut down upon first +authentication. +.UNINDENT +.UNINDENT .\"********************************************************* .TP .B \-\-keying\-material\-exporter label len
src/openvpn/plugin.c +30 -3
@@ -809,7 +809,7 @@ plugin_call_ssl(const struct plugin_list *pl,const int n =plugin_n (pl);bool success = false;bool error = false; -bool deferred = false; +bool deferred_auth_done = false;setenv_del (es,"script_type" ); envp =make_env_array (es, false, &gc);
@@ -834,7 +834,34 @@ plugin_call_ssl(const struct plugin_list *pl,break ;case OPENVPN_PLUGIN_FUNC_DEFERRED : - deferred = true; +if ((type ==OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY ) + && deferred_auth_done) + { +/* +* Do not allow deferred auth if a deferred auth has +* already been started. This should allow a single +* deferred auth call to happen, with one or more +* auth calls with an instant authentication result. +* +* The plug-in API is not designed for multiple +* deferred authentications to happen, as the +* auth_control_file file will be shared across all +* the plug-ins. +* +* Since this is considered a critical configuration +* error, we bail out and exit the OpenVPN process. +*/ + error = true; +msg (M_FATAL , +"Exiting due to multiple authentication plug-ins " +"performing deferred authentication. Only one " +"authentication plug-in doing deferred auth is " +"allowed. Ignoring the result and stopping now, " +"the current authentication result is not to be " +"trusted." ); +break ; + } + deferred_auth_done = true;break ;default :
@@ -858,7 +885,7 @@ plugin_call_ssl(const struct plugin_list *pl, {return OPENVPN_PLUGIN_FUNC_ERROR ; } - else if (deferred) + else if (deferred_auth_done) {return OPENVPN_PLUGIN_FUNC_DEFERRED ; }
Signature · 1 line
2.27.0
[Openvpn-devel] [PATCH applied] Re: plug-ins: Disallow multiple deferred authentication plug-ins
I have not done formal testing, just verified that the code change is the same and that it compiles. The "plugin.c" module did change quite a bit since 2.4 (PF removal, argv overhaul, ENABLE_CRYPTO, etc.) but the code patched here - plugin_call_ssl() - is identical.
Your patch has been applied to the release/2.4 branch.
commit 58ec3bb4aac77131118dbbc39a65181e7847adee
Author: David Sommerseth Date: Tue Mar 15 16:53:43 2022 +0100
plug-ins: Disallow multiple deferred authentication plug-ins
Signed-off-by: David Sommerseth <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/search?l=mid&[email protected]...
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH v5 3/3 plug-ins: Remove defer/simple.c sample plugin
In reply to David SommersethFrom: David Sommerseth <[email protected]...>
The use case for this plug-in is dubious now with the new multi-auth.c plugin available. This new plugin is based on simple.c, but allows far more flexibility for testing.
--- sample/sample-plugins/defer/README | 3 - sample/sample-plugins/defer/simple.c | 541 ------------------------- sample/sample-plugins/defer/simple.def | 6 - 3 files changed, 550 deletions(-) delete mode 100644 sample/sample-plugins/defer/simple.c delete mode 100755 sample/sample-plugins/defer/simple.def
sample/sample-plugins/defer/README +0 -3
@@ -2,9 +2,6 @@ OpenVPN plugin examples. Examples provided: -simple.c -- using the --auth-user-pass-verify callback, - test deferred authentication. - multi-auth.c -- Test plug-in for testing multiple authentication plug-ins in the same OpenVPN server configuration. Only tested on Linux.
sample/sample-plugins/defer/simple.c deleted +0 -541
541 lines not on this page · raw message
sample/sample-plugins/defer/simple.def deleted +0 -6
@@ -1,6 +0,0 @@ -LIBRARY OpenVPN_PLUGIN_SAMPLE -DESCRIPTION "Sample OpenVPN plug-in module." -EXPORTS - openvpn_plugin_open_v1 @1 - openvpn_plugin_func_v1 @2 - openvpn_plugin_close_v1 @3
Signature · 1 line
2.27.0
Re: [Openvpn-devel] [PATCH v2.4 v5 3/3] plug-ins: Remove defer/simple.c sample plugin
Hi,
Quoted 5 lines · David Sommerseth
From: David Sommerseth <[email protected]...>
The use case for this plug-in is dubious now with the new
multi-auth.cplugin available. This new plugin is based onsimple.c, but allows far more flexibility for testing.
As for 1/3 v5, we decided to not invest time into plugin maintenance for 2.4 -> so, formal NAK for this one. Just for the sake of the archives.
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...