Pro EP 85 : How to avoid referencing to un-wanted sites in .NET Web ?

Muhammad Waseem
Become .NET Pro !
2 min readOct 28, 2023

The ability of attackers to manipulate or exploit the referrer header largely depends on the specific vulnerabilities or weaknesses present in the web application or browser.

Here are a few potential attack scenarios related to the referrer header:

1/ Referrer Leakage
2/ Privacy Concerns
3/ Spoofing Referrer
4/ Cross-Site Request Forgery Attacks

To mitigate these risks, it’s recommended to set a Referrer-Policy that minimizes the amount of information shared in the referrer header.

Common policies include ‘no-referrer’ (no referrer information is sent) or ‘same-origin’ (referrer is sent for requests from the same origin).

Keep in mind that while adjusting the Referrer-Policy is a good practice, it’s just one aspect of a comprehensive web security strategy.

Other security measures, such as input validation, secure coding practices, and regular security audits, are essential for robust protection against various web-based attacks.

We can add this following code to avoid refer policy attacks :

𝚌𝚘𝚗𝚝𝚎𝚡𝚝.𝚁𝚎𝚜𝚙𝚘𝚗𝚜𝚎.𝙷𝚎𝚊𝚍𝚎𝚛𝚜.𝙰𝚍𝚍(“𝚁𝚎𝚏𝚎𝚛𝚛𝚎𝚛-𝙿𝚘𝚕𝚒𝚌𝚢”, “𝚗𝚘-𝚛𝚎𝚏𝚎𝚛𝚛𝚎𝚛”);

It sets the “Referrer-Policy” to “no-referrer”, which means that no referrer information will be sent in the HTTP header when navigating from one page to another.

Whenever you’re ready, there are 4 ways I can help you

  1. Subscribe to my Weekly .NET Newsletter of C#/.NET with 6000+ Software Engineers.
  2. Promote yourself to 7500+ subscribers by Sponsoring my Newsletter
  3. Download my eBook at Gum Road which contains 30+ .NET Tips (With 2800+ Downloads)
  4. To get 100+ free and paid resources for learning C# and .NET visit this GitHub Repository

--

--