Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

Fix open redirect CVE-2019-13038 #220

Closed
wants to merge 2 commits into from
Closed

Conversation

awakenine
Copy link

@awakenine awakenine commented Sep 6, 2019

Fix open redirect CVE-2019-13038
#35 (comment)

@awakenine awakenine changed the title Update auth_mellon_mode.c Update auth_mellon_mode.c: Fix open redirect CVE-2019-13038 Sep 6, 2019
@awakenine awakenine changed the title Update auth_mellon_mode.c: Fix open redirect CVE-2019-13038 Update auth_mellon_util.c: Fix open redirect CVE-2019-13038 Sep 17, 2019
@awakenine awakenine changed the title Update auth_mellon_util.c: Fix open redirect CVE-2019-13038 Fix open redirect CVE-2019-13038 Sep 17, 2019
Copy link
Contributor

@olavmrk olavmrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

first of all, sorry for taking so long before looking at this pull request.

I had a look at this pull request now. Overall, I am positive to the change, but I don't really trust the apr_uri_parse()-function anymore, since it has had so many problems.

I think we at least need to add more checks for what it returns.

My suggestion would be to allow two types of URLs: Absolute and relative to the root of the site.

For absolute URLs, we should require that scheme, hostname and path are set. We can allow port_str, query and fragment to be set. We should forbid forbid user and password.

For relative URLs, we should require path to be set, and allow query and fragment to be set. scheme, user, password, hostname and port_str should be forbidden.

In addition, for both absolute URLs and relative URLs, we should verify that path starts with a single /. I.e. "/" and "/example" are allowed, but // is forbidden.

/* http and https schemes without hostname are invalid. */
if (!uri.hostname) {
return HTTP_BAD_REQUEST;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you fix the indentation of the comment and closing curly bracket?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @olavmrk. Sure, it should be fixed now.

@awakenine
Copy link
Author

awakenine commented Sep 24, 2019

apr_uri_parse()

I used this code to check apr_uri_parse() behavior, and then text to Apache foundation to discuss that.
Their answer was that URI parser works simply according to RFC (please see https://tools.ietf.org/html/rfc7230#section-2.7.1).
If you need URL parser, it will be better to use safe URL parser, or create auxiliary function for parsing URL with all required security checks.

@awakenine awakenine requested a review from olavmrk September 24, 2019 12:58
@olavmrk
Copy link
Contributor

olavmrk commented Sep 27, 2019

If you need URL parser, it will be better to use safe URL parser, or create auxiliary function for parsing URL with all required security checks.

Yes, that is why the fix I imagined for the latest problem was to replace apr_uri_parse() with a really paranoid URL parser, though I realize I never wrote it out in my comment.

As I said in my comment, this is the third time that using apr_uri_parse() has given us a problem.

If we are not going to replace apr_uri_parse() here, I would rather be really paranoid in checking its output, which may reduce the probability of further open redirects being discovered.

@olavmrk
Copy link
Contributor

olavmrk commented Sep 30, 2019

Closing this pull request as part of archiving this project. See the announcement for details:

https://github.com/Uninett/mod_auth_mellon/blob/info/README.md

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants