NTFS has a great feature called junction points that let you create directory aliases starting in Windows 2000. This lets you avoid security issues that result from parent-path canonicalization attacks. For example, in IIS 6.0, parent paths are disabled (e.g. you cannot use relative URLs that do innocuous-looking stuff like
). This is common in web applications that need to share common files such as images. They usually have directory structures that look like:
VDir
+--Images
+--App1
+--App2
To avoid file path canonicalization attacks, you need to do is create junction points in NTFS. This results in directory structures that look like:
VDir
+--Images
+--App1
+--Images*
+--App2
+--Images*
Note that the directories marked by (*) are actually junction points and NOT real subdirectories. This lets you rewrite your HTML to look like:
.
Now creating junction points is a whole other matter entirely. For reasons that I don’t understand, Windows doesn’t ship with any tools that let you create junction points. You must either purchase a copy of the Windows 2000 Resource Kit so that you can use its linkd utility, or you can download Mark Russinovich’s most excellent junction utility.
5 archived reader comments
Atif Aziz (2004-02-26)
Also checkout FSUTIL that ships with Windows XP and Windows 2003.
John Lam (2004-02-26)
If I’m not mistaken, I can only create hard links with fsutil and not junction points.
Duncan Smart (2004-02-26)
a) All this is a waste of time as all browsers normalise url requests to a server anyway. i.e. even if you have [img src=”../images/logo.gif”] in a file in the /test/ folder — a GET request will be made for “/images/logo.gif” - the server doesn’t see the parent path.
b) Why fiddle with junction points? Just add a virtual *sub*directory! Virtual directories can be added anywhere in a directory hierarchy in IIS. (In fact you can add a vDir with the same same as an existing one, and if effectively ‘overrides’ the real one)
Paul Bartlett (2004-02-27)
Talking of hardlinks, SysInternals also have a tool that does that, even on NT (an “interesting” usage of the Backup/Restore API if memory serves…)
Ernst (2004-02-27)
Thanks for the link to Mark’s junction util! It’s most useful.