|
|
bef612 |
From a1b8e7aa92e5e624a5f90bb736c307dae22230a1 Mon Sep 17 00:00:00 2001
|
|
|
bef612 |
From: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
|
|
|
bef612 |
Date: Mon, 27 Jul 2020 19:35:29 +0200
|
|
|
bef612 |
Subject: [PATCH 2/4] prevent XSS and open redirect on OIDC session
|
|
|
bef612 |
managemement OP iframe
|
|
|
bef612 |
|
|
|
bef612 |
- apply OIDCRedirectURLsAllowed on the login_uri parameter
|
|
|
bef612 |
- thanks Andrew Brady
|
|
|
bef612 |
- bump to 2.4.4rc3
|
|
|
bef612 |
|
|
|
bef612 |
Signed-off-by: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
|
|
|
bef612 |
(cherry picked from commit 51d997899afea6ea454abda49bd4cd41aa7c0cdc)
|
|
|
bef612 |
---
|
|
|
bef612 |
ChangeLog | 12 ++++++------
|
|
|
bef612 |
auth_openidc.conf | 3 ++-
|
|
|
bef612 |
configure.ac | 2 +-
|
|
|
bef612 |
src/mod_auth_openidc.c | 21 +++++++++++++++++----
|
|
|
bef612 |
4 files changed, 26 insertions(+), 12 deletions(-)
|
|
|
bef612 |
|
|
|
bef612 |
diff --git a/ChangeLog b/ChangeLog
|
|
|
bef612 |
index eba2ebc..075f98d 100644
|
|
|
bef612 |
--- a/ChangeLog
|
|
|
bef612 |
+++ b/ChangeLog
|
|
|
bef612 |
@@ -86,7 +86,7 @@
|
|
|
bef612 |
- bump to 2.3.5rc0
|
|
|
bef612 |
|
|
|
bef612 |
04/27/2018
|
|
|
bef612 |
-- avoid crash when a relative logout URL parameter is passed in; thanks Vivien Delenne
|
|
|
bef612 |
+- avoid crash when a relative logout URL parameter is passed in; thanks Vivien Delenne
|
|
|
bef612 |
- release 2.3.4
|
|
|
bef612 |
|
|
|
bef612 |
03/22/2018
|
|
|
bef612 |
@@ -258,7 +258,7 @@
|
|
|
bef612 |
- bump to 2.2.1rc6
|
|
|
bef612 |
|
|
|
bef612 |
05/18/2017
|
|
|
bef612 |
-- fix parse function of OIDCRequestObject configuration option; thanks @suttod
|
|
|
bef612 |
+- fix parse function of OIDCRequestObject configuration option; thanks @suttod
|
|
|
bef612 |
|
|
|
bef612 |
05/17/2017
|
|
|
bef612 |
- avoid crash when the X-Forwarded-Proto header is not correctly set by a reverse proxy in front of mod_auth_openidc
|
|
|
bef612 |
@@ -325,7 +325,7 @@
|
|
|
bef612 |
|
|
|
bef612 |
02/20/2017
|
|
|
bef612 |
- security fix: scrub headers for "AuthType oauth20"
|
|
|
bef612 |
-- release 2.1.6
|
|
|
bef612 |
+- release 2.1.6
|
|
|
bef612 |
|
|
|
bef612 |
02/15/2017
|
|
|
bef612 |
- improve logging of session max duration and session inactivity timeout
|
|
|
bef612 |
@@ -534,7 +534,7 @@
|
|
|
bef612 |
- bump to 1.9.0rc3
|
|
|
bef612 |
|
|
|
bef612 |
7/19/2016
|
|
|
bef612 |
-- add support for chunked session cookies; closes #153; thanks @glatzert
|
|
|
bef612 |
+- add support for chunked session cookies; closes #153; thanks @glatzert
|
|
|
bef612 |
- bump to 1.9.0rc2
|
|
|
bef612 |
|
|
|
bef612 |
7/9/2016
|
|
|
bef612 |
@@ -911,7 +911,7 @@
|
|
|
bef612 |
|
|
|
bef612 |
1/1/2015
|
|
|
bef612 |
- update copyright to 2015
|
|
|
bef612 |
-- use json_int_t (seconds) for "exp" and "iat" fields, instead of apr_time_t (microseconds)
|
|
|
bef612 |
+- use json_int_t (seconds) for "exp" and "iat" fields, instead of apr_time_t (microseconds)
|
|
|
bef612 |
- correct expiry debug printout
|
|
|
bef612 |
- bump to 1.7.2rc1
|
|
|
bef612 |
|
|
|
bef612 |
@@ -1191,7 +1191,7 @@
|
|
|
bef612 |
- support using a Bearer token on client registration calls
|
|
|
bef612 |
|
|
|
bef612 |
4/22/2014
|
|
|
bef612 |
-- match request and response type
|
|
|
bef612 |
+- match request and response type
|
|
|
bef612 |
- check at_hash value on "token id_token" implicit flow
|
|
|
bef612 |
- use shared memory caching by default
|
|
|
bef612 |
- release 1.2
|
|
|
bef612 |
diff --git a/auth_openidc.conf b/auth_openidc.conf
|
|
|
bef612 |
index 87685f6..75cdb8e 100644
|
|
|
bef612 |
--- a/auth_openidc.conf
|
|
|
bef612 |
+++ b/auth_openidc.conf
|
|
|
bef612 |
@@ -786,7 +786,8 @@
|
|
|
bef612 |
#OIDCStateInputHeaders [none|user-agent|x-forwarded-for|both]
|
|
|
bef612 |
|
|
|
bef612 |
# Define one or more regular expressions that specify URLs (or domains) allowed for post logout and
|
|
|
bef612 |
-# other redirects such as the "return_to" value on refresh token requests, e.g.:
|
|
|
bef612 |
+# other redirects such as the "return_to" value on refresh token requests, and the "login_uri" value
|
|
|
bef612 |
+# on session management based logins through the OP iframe, e.g.:
|
|
|
bef612 |
# OIDCRedirectURLsAllowed ^https://www.example.com ^https://(\w+).example.org ^https://example.net/app
|
|
|
bef612 |
# or:
|
|
|
bef612 |
# OIDCRedirectURLsAllowed ^https://www.example.com/logout$ ^https://www.example.com/app/return_to$
|
|
|
bef612 |
diff --git a/configure.ac b/configure.ac
|
|
|
bef612 |
index ad5ba0e..c61d117 100644
|
|
|
bef612 |
--- a/configure.ac
|
|
|
bef612 |
+++ b/configure.ac
|
|
|
bef612 |
@@ -91,7 +91,7 @@ HAVE_LIBJQ=0
|
|
|
bef612 |
|
|
|
bef612 |
AC_ARG_WITH(jq,
|
|
|
bef612 |
[ --with-jq=PATH location of your libjq installation])
|
|
|
bef612 |
-
|
|
|
bef612 |
+
|
|
|
bef612 |
if test -n "$with_jq"
|
|
|
bef612 |
then
|
|
|
bef612 |
JQ_CFLAGS="-I$with_jq/include"
|
|
|
bef612 |
diff --git a/src/mod_auth_openidc.c b/src/mod_auth_openidc.c
|
|
|
bef612 |
index 215ed5e..68fbca5 100644
|
|
|
bef612 |
--- a/src/mod_auth_openidc.c
|
|
|
bef612 |
+++ b/src/mod_auth_openidc.c
|
|
|
bef612 |
@@ -2688,7 +2688,8 @@ static int oidc_handle_logout_request(request_rec *r, oidc_cfg *c,
|
|
|
bef612 |
}
|
|
|
bef612 |
|
|
|
bef612 |
static apr_byte_t oidc_validate_redirect_url(request_rec *r, oidc_cfg *c,
|
|
|
bef612 |
- const char *url, char **err_str, char **err_desc) {
|
|
|
bef612 |
+ const char *url, apr_byte_t restrict_to_host, char **err_str,
|
|
|
bef612 |
+ char **err_desc) {
|
|
|
bef612 |
apr_uri_t uri;
|
|
|
bef612 |
const char *c_host = NULL;
|
|
|
bef612 |
apr_hash_index_t *hi = NULL;
|
|
|
bef612 |
@@ -2717,7 +2718,7 @@ static apr_byte_t oidc_validate_redirect_url(request_rec *r, oidc_cfg *c,
|
|
|
bef612 |
oidc_error(r, "%s: %s", *err_str, *err_desc);
|
|
|
bef612 |
return FALSE;
|
|
|
bef612 |
}
|
|
|
bef612 |
- } else if (uri.hostname != NULL) {
|
|
|
bef612 |
+ } else if ((uri.hostname != NULL) && (restrict_to_host == TRUE)) {
|
|
|
bef612 |
c_host = oidc_get_current_url_host(r);
|
|
|
bef612 |
if ((strstr(c_host, uri.hostname) == NULL)
|
|
|
bef612 |
|| (strstr(uri.hostname, c_host) == NULL)) {
|
|
|
bef612 |
@@ -2792,7 +2793,7 @@ static int oidc_handle_logout(request_rec *r, oidc_cfg *c,
|
|
|
bef612 |
} else {
|
|
|
bef612 |
|
|
|
bef612 |
/* do input validation on the logout parameter value */
|
|
|
bef612 |
- if (oidc_validate_redirect_url(r, c, url, &error_str,
|
|
|
bef612 |
+ if (oidc_validate_redirect_url(r, c, url, TRUE, &error_str,
|
|
|
bef612 |
&error_description) == FALSE) {
|
|
|
bef612 |
return oidc_util_html_send_error(r, c->error_template, error_str,
|
|
|
bef612 |
error_description,
|
|
|
bef612 |
@@ -2948,6 +2949,18 @@ static int oidc_handle_session_management_iframe_rp(request_rec *r, oidc_cfg *c,
|
|
|
bef612 |
if (s_poll_interval == NULL)
|
|
|
bef612 |
s_poll_interval = "3000";
|
|
|
bef612 |
|
|
|
bef612 |
+ int poll_interval = s_poll_interval ? strtol(s_poll_interval, NULL, 10) : 0;
|
|
|
bef612 |
+ if ((poll_interval <= 0) || (poll_interval > 3600 * 24))
|
|
|
bef612 |
+ poll_interval = 3000;
|
|
|
bef612 |
+
|
|
|
bef612 |
+ char *login_uri = NULL, *error_str = NULL, *error_description = NULL;
|
|
|
bef612 |
+ oidc_util_get_request_parameter(r, "login_uri", &login_uri);
|
|
|
bef612 |
+ if ((login_uri != NULL)
|
|
|
bef612 |
+ && (oidc_validate_redirect_url(r, c, login_uri, FALSE, &error_str,
|
|
|
bef612 |
+ &error_description) == FALSE)) {
|
|
|
bef612 |
+ return HTTP_BAD_REQUEST;
|
|
|
bef612 |
+ }
|
|
|
bef612 |
+
|
|
|
bef612 |
const char *redirect_uri = oidc_get_redirect_uri(r, c);
|
|
|
bef612 |
java_script = apr_psprintf(r->pool, java_script, origin, client_id,
|
|
|
bef612 |
session_state, op_iframe_id, s_poll_interval, redirect_uri,
|
|
|
bef612 |
@@ -3061,7 +3074,7 @@ static int oidc_handle_refresh_token_request(request_rec *r, oidc_cfg *c,
|
|
|
bef612 |
}
|
|
|
bef612 |
|
|
|
bef612 |
/* do input validation on the return to parameter value */
|
|
|
bef612 |
- if (oidc_validate_redirect_url(r, c, return_to, &error_str,
|
|
|
bef612 |
+ if (oidc_validate_redirect_url(r, c, return_to, TRUE, &error_str,
|
|
|
bef612 |
&error_description) == FALSE) {
|
|
|
bef612 |
oidc_error(r, "return_to URL validation failed: %s: %s", error_str,
|
|
|
bef612 |
error_description);
|
|
|
bef612 |
--
|
|
|
bef612 |
2.31.1
|
|
|
bef612 |
|