Bill said:
All:
Pardon the newbie question, but let's say I've got two pages in my website:
Welcome.aspx
NoNav.aspx
I want users to be able to navigate to the welcome.aspx page (e.g.
http://myserver.com/Welcome.aspx), but I don't want them to be able to
navigate directly to NoNav.aspx. The NoNav.aspx page will be loaded only by
a menu selection in Welcome.aspx.
How do I disable direct navigation to NoNav.aspx in this example?
Thanks,
Bill
For some of our sites, we got downright paranoid about navigation. What
we do is, during page load, we call a function called CanNavigate(),
passing it the name of the current page. The CanNavigate function has
an array of valid from/to pairs. If the page passed in, and the
previous page, are a matching pair, we let the navigation happen, and
store the page passed in into a session variable (so that we can use
that as the previous page the next time the funtion is called).
We use the session so that this data stays in server land and cannot be
tampered with by an attacker. Other notes:
Navigating to the same page as the previous page is always allowed
(this allows postbacks to occur).
The From/To pairs are checked in both directions. This allows the back
button to be used (provided it causes a page request to occur).
If the known previous page doesn't match the referer header (as passed
to us by the user agent), we traverse the from/to pairs backwards, to
see if the user has pressed the back button and it hasn't caused a
postback. We can do this because our navigation hierarchy is treelike
(no "to" page can be reached from multiple "from" pages, except where
one "from" page is in the path of the other).
If we cannot match the referer header either to the known previous
page, nor to any parent of that page, we conclude that the navigation
is illegal.
From all of the above, we're reasonably sure that the users are
following the navigation hierarchy we have determined. And if we cannot
match based on that data, we record the data with as much detail as
possible (for later analysis), and redirect to the root page.
I know for a fact that we do get some false negatives with this system
(where it decides the navigation is illegal even though it should have
been fine). If your projected user base can tolerate this, then it's
usable. Never really gotten to the bottom of this though (I think it
may be when the referer is unexpected)
Damien