Skip to content

Commit ca7b184

Browse files
committed
Allow longer username and password under Dynamic Challenge/Response Protocol.
Based on patches found at https://github.com/samm-git/aws-vpn-client, this updates OpenVPN for compatibility with AWS' (and other vendors) use of the dynamic challenge/response protocol to implement SAML-based authentication. Those vendors submit the password via the management interface, which can be up to 50kb long.
1 parent 7aa3520 commit ca7b184

File tree

6 files changed

+283
-8
lines changed

6 files changed

+283
-8
lines changed

flake.lock

Lines changed: 218 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
4+
devenv.url = "github:cachix/devenv";
5+
};
6+
7+
outputs = { self, nixpkgs, devenv, ... } @ inputs:
8+
let
9+
systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
10+
forAllSystems = f: builtins.listToAttrs (map (name: { inherit name; value = f name; }) systems);
11+
in
12+
{
13+
devShells = forAllSystems
14+
(system:
15+
let
16+
pkgs = import nixpkgs {
17+
inherit system;
18+
};
19+
in
20+
{
21+
default = devenv.lib.mkShell {
22+
inherit inputs pkgs;
23+
modules = [
24+
{
25+
# https://devenv.sh/reference/options/
26+
packages = [
27+
pkgs.autoconf
28+
pkgs.automake
29+
pkgs.libtool
30+
pkgs.openssl_1_1
31+
pkgs.lz4
32+
pkgs.lzo
33+
pkgs.pam
34+
pkgs.cmocka
35+
];
36+
37+
languages.c.enable = true;
38+
39+
enterShell = ''
40+
# Allows autreconf to find libtool.
41+
export ACLOCAL_PATH=${pkgs.libtool}/share/aclocal:$ACLOCAL_PATH
42+
'';
43+
}
44+
];
45+
};
46+
});
47+
};
48+
}

src/openvpn/common.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ typedef unsigned long ptr_type;
6464
/*
6565
* This parameter controls the TLS channel buffer size and the
6666
* maximum size of a single TLS message (cleartext).
67-
* This parameter must be >= PUSH_BUNDLE_SIZE
67+
* This parameter must be >= PUSH_BUNDLE_SIZE. It must also be greater than
68+
* the size of a long (>50Kb) password in the dyanmic challenge/response
69+
* protocol,
6870
*/
69-
#define TLS_CHANNEL_BUF_SIZE 2048
71+
#define TLS_CHANNEL_BUF_SIZE 65536
7072

7173
/* TLS control buffer minimum size
7274
*

src/openvpn/manage.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,7 +2244,7 @@ man_read(struct management *man)
22442244
/*
22452245
* read command line from socket
22462246
*/
2247-
unsigned char buf[256];
2247+
unsigned char buf[TLS_CHANNEL_BUF_SIZE];
22482248
int len = 0;
22492249

22502250
#ifdef TARGET_ANDROID
@@ -2580,7 +2580,7 @@ man_connection_init(struct management *man)
25802580
* Allocate helper objects for command line input and
25812581
* command output from/to the socket.
25822582
*/
2583-
man->connection.in = command_line_new(1024);
2583+
man->connection.in = command_line_new(TLS_CHANNEL_BUF_SIZE);
25842584
man->connection.out = buffer_list_new();
25852585

25862586
/*

src/openvpn/misc.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ struct user_pass
6565
#ifdef ENABLE_PKCS11
6666
#define USER_PASS_LEN 4096
6767
#else
68-
#define USER_PASS_LEN 128
68+
/*
69+
* Increase the username and password length size to 65KB, in order
70+
* to support long passwords under the dynamic challenge/response protocol.
71+
*/
72+
#define USER_PASS_LEN 65536
6973
#endif
7074
/* Note that username and password are expected to be null-terminated */
7175
char username[USER_PASS_LEN];

src/openvpn/options.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@
5252
#define MAX_PARMS 16
5353

5454
/*
55-
* Max size of options line and parameter.
55+
* Max size of options line and parameter. Note these
56+
* must be able to accomodate large (>50Kb) values in
57+
* order to support long passwords under the dynamic challenge-response
58+
* protocol.
5659
*/
57-
#define OPTION_PARM_SIZE 256
58-
#define OPTION_LINE_SIZE 256
60+
#define OPTION_PARM_SIZE USER_PASS_LEN
61+
#define OPTION_LINE_SIZE OPTION_PARM_SIZE
5962

6063
extern const char title_string[];
6164

0 commit comments

Comments
 (0)