Link to home
Start Free TrialLog in
Avatar of curiouswebster
curiouswebsterFlag for United States of America

asked on

Does this C# block return URL hacking?

Does this C# block return URL hacking?

            if (Url.IsLocalUrl(redirectToAfterLoggingIn) && redirectToAfterLoggingIn.Length > 1 &&
                (redirectToAfterLoggingIn.StartsWith("/") && !redirectToAfterLoggingIn.StartsWith("//")) &&
                !redirectToAfterLoggingIn.StartsWith("/\\"))
                return Redirect(redirectToAfterLoggingIn);

Open in new window


I find it confusing, at best.

How can it be a local URL if it starts with a "/"?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of curiouswebster

ASKER

So, could redirectToAfterLoggingIn still have a value like:

/?returnurl=http://reallybadsite.com

I am trying to assess the danger of calling the Redirect function, as written.

Should I create a different version of my whitelist check which could attempt to extract a URL to verify, from that partial domain?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks
You are welcome.