Skip to content

Commit

Permalink
improve detection of suspicious redirect URLs; add test list
Browse files Browse the repository at this point in the history
bump to 2.4.11rc1

Signed-off-by: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
  • Loading branch information
zandbelt committed Jan 6, 2022
1 parent 319f225 commit 1a394a8
Show file tree
Hide file tree
Showing 7 changed files with 904 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
01/06/2022
- improve detection of suspicious redirect URLs; add test list
- bump to 2.4.11rc1

12/24/2021
- make interpretation of X-Forwarded-* headers configurable, defaulting to none
so mod_auth_openidc running behind a reverse proxy that sets X-Forwarded-* headers
Expand Down
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ EXTRA_DIST = \
LICENSE.txt \
auth_openidc.conf \
test/public.pem \
test/certificate.pem
test/certificate.pem \
test/open-redirect-payload-list.txt

noinst_DATA = mod_auth_openidc.la

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([mod_auth_openidc],[2.4.11rc0],[hans.zandbelt@zmartzone.eu])
AC_INIT([mod_auth_openidc],[2.4.11rc1],[hans.zandbelt@zmartzone.eu])

AC_SUBST(NAMEVER, AC_PACKAGE_TARNAME()-AC_PACKAGE_VERSION())

Expand Down
15 changes: 14 additions & 1 deletion src/mod_auth_openidc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,7 @@ static int oidc_target_link_uri_matches_configuration(request_rec *r,

#define OIDC_MAX_URL_LENGTH 8192 * 2

static apr_byte_t oidc_validate_redirect_url(request_rec *r, oidc_cfg *c,
apr_byte_t oidc_validate_redirect_url(request_rec *r, oidc_cfg *c,
const char *redirect_to_url, apr_byte_t restrict_to_host, char **err_str,
char **err_desc) {
apr_uri_t uri;
Expand Down Expand Up @@ -2515,6 +2515,19 @@ static apr_byte_t oidc_validate_redirect_url(request_rec *r, oidc_cfg *c,
return FALSE;
}

if ((strstr(url, "/%09") != NULL) || (strstr(url, "/%2f") != NULL)
|| (strstr(url, "/%68") != NULL) || (strstr(url, "/.") != NULL)
|| (strstr(url, "/http:") != NULL) || (strstr(url, "/https:") != NULL)
|| (strstr(url, "/javascript:") != NULL) || (strstr(url, "/〱") != NULL)
|| (strstr(url, "/〵") != NULL) || (strstr(url, "/ゝ") != NULL)
|| (strstr(url, "/ー") != NULL) || (strstr(url, "/〱") != NULL)
|| (strstr(url, "/ー") != NULL) || (strstr(url, "/<") != NULL)
|| (strstr(url, "%01javascript:") != NULL) || (strstr(url, "/%5c") != NULL)) {
*err_str = apr_pstrdup(r->pool, "Invalid URL");
*err_desc = apr_psprintf(r->pool, "URL value \"%s\" contains illegal character(s)", url);
oidc_error(r, "%s: %s", *err_str, *err_desc);
return FALSE;
}
return TRUE;
}

Expand Down
1 change: 1 addition & 0 deletions src/mod_auth_openidc.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ apr_byte_t oidc_proto_handle_authorization_response_idtoken(request_rec *r, oidc
apr_byte_t oidc_proto_validate_access_token(request_rec *r, oidc_provider_t *provider, oidc_jwt_t *jwt, const char *response_type, const char *access_token);
apr_byte_t oidc_proto_validate_code(request_rec *r, oidc_provider_t *provider, oidc_jwt_t *jwt, const char *response_type, const char *code);
apr_byte_t oidc_proto_validate_nonce(request_rec *r, oidc_cfg *cfg, oidc_provider_t *provider, const char *nonce, oidc_jwt_t *jwt);
apr_byte_t oidc_validate_redirect_url(request_rec *r, oidc_cfg *c, const char *redirect_to_url, apr_byte_t restrict_to_host, char **err_str, char **err_desc);
// oidc_authz.c
typedef apr_byte_t (*oidc_authz_match_claim_fn_type)(request_rec *, const char * const, const json_t * const);
Expand Down
Loading

0 comments on commit 1a394a8

Please sign in to comment.