URI Fragment

The final (optional) part of the URL after the pound sign (#) is the URI fragment.

URI fragments are available only to the browser. The browser reads the full URL but strips the fragment before passing the request to the server.

JavaScript can read the fragment through location.hash, which makes it a common source of DOM-based cross-site scripting. If a page writes the fragment into the document without escaping it, an attacker can send a victim a link with a script hidden after the #. The script runs in the victim's browser, and since the fragment never reaches the server, server-side input filters and logs never see it.

Further Reading

Learn it hands-on

If you make use of URI fragments in your site, you need to ensure they cannot be abused to inject malicious JavaScript.