A month or so ago I was in the middle of one of my "Distributed Applications" classes and the professor was explaining us how to """properly""" authenticate users in a server.
To demonstrate how to prevent users from accessing all files under a given directory (i.e. with name "private"), the professor showed us some JSP code that was something like the following pseudocode:
String URI = uri.getRequest();
if (URI.contains("/private/") {
if (userIsAuthenticated()) grantAccess();
else redirectToLogInPage();
}
Of course, I realized what was wrong there, and what could be a security flaw. If an user requests for an URL such as mysite.com/private%2Fmypage
then URI wouldn't contain the literal string "/private/" so the user would be granted access.
Yesterday I remembered that class, so as I was curious about it, I indeed found out that not only all my previous web projects in Uni actually had this vulnerability, but even some websites of serious companies also have this issue. You can access to a lot of pages where you should not be able to (basically user profile pages when you haven't logged in), just by percent encoding some character in the URL.
So, as I've realized that there are a lot of people not caring too much about this issue I'm a bit confused. Isn't it a big flaw? What could be some attacks that could be done taking advantage of this issue? I'd just like to know, from a theoretical point of view if possible, how bad could get this issue for a site that does not manage url-encoding properly.
P.S: I know that a plausible solution could be to also check if requested URL is percent-encoded and denying access to it. Or even if we'd like to go further and implement a more secure solution we could use a Key Distributed Center such as Kerberos. However I don't understand why you can find serious websites with this flaw and it doesn't seem soo much of a big deal to them.