Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Canonicalization
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Filenames === Files in [[file system]]s may in most cases be accessed through multiple [[filename]]s. For instance in [[Unix]]-like systems, the string "<code>/./</code>" can be replaced by "<code>/</code>". In the [[C standard library]], the function <code>realpath()</code> performs this task. Other operations performed by this function to canonicalize filenames are the handling of <code>/..</code> components referring to parent directories, simplification of sequences of multiple slashes, removal of trailing slashes, and the resolution of [[symbolic link]]s. Canonicalization of filenames is important for computer security. For example, a web server may have a restriction that only files under the cgi directory <code>C:\inetpub\wwwroot\cgi-bin</code> may be executed. This rule is enforced by checking that the path starts with <code>C:\inetpub\wwwroot\cgi-bin\</code> and only then executing it. While the file <code>C:\inetpub\wwwroot\cgi-bin\..\..\..\Windows\System32\cmd.exe</code> initially appears to be in the cgi directory, it exploits the <code>..</code> path specifier to traverse back up the directory hierarchy in an attempt to execute a file outside of <code>cgi-bin</code>. Permitting <code>cmd.exe</code> to execute would be an error caused by a failure to canonicalize the filename to the simplest representation, <code>C:\Windows\System32\cmd.exe</code>, and is called a [[directory traversal]] vulnerability. With the path canonicalized, it is clear the file should not be executed.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)