Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8748571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:32:53+00:00 2026-06-13T12:32:53+00:00

In .NET 4.5 it’s possible to optionaly use randomized string hash code generation. That

  • 0

In .NET 4.5 it’s possible to optionaly use randomized string hash code generation.
That means, that hash codes for the same string calculated in different application domains will be different. (See http://msdn.microsoft.com/en-us/library/jj152924.aspx)

The question is: what is the practical use of this option?
In other words, in what scenario (scenarios) do I need to switch it on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:32:53+00:00Added an answer on June 13, 2026 at 12:32 pm

    I believe that the general application of this is to prevent possible DoS attacks against the hashing mechanism.

    Since GetHashCode() is used internally by things like Dictionary<,>, and for “normal” data, the hash values should be reasonably well distributed so that hash collisions don’t occur “too often”. When a hash collision does occur, the Dictionary<,> falls back to a linear search of all items with the same hash code.

    In a publicly accessible application, it may be possible for an adversary with knowledge of the hashing mechanism, to submit requests with large numbers of strings with identical hash codes, resulting in a normally O(1) lookup becoming an O(N) lookup for any dictionary that has these values added to it.

    For web applications specifically, I believe that things like headers, and query string parameters are added to dictionaries for quick access by the application, as such the adversary could submit a request with thousands of parameters with colliding hashes, resulting in the request being significantly more resource-hungry than a “normal” request. This has an amplifying effect on any DoS attempt, allowing an attack to take place even when the attacker has only relatively modest bandwidth available.

    By randomizing the hash value per AppDomain, it is less likely that an attacker can craft strings with colliding hashes, so preventing such an attack.

    Edit addressing comments:

    Whilst the MSDN article doesn’t mention it, the intention of the setting isn’t about providing a means to have different AppDomains create different string hashes, it’s a security feature to prevent a third party from creating many strings with identical hashes.

    Prior to .NET 4.5 (or with this setting disabled), providing that I was running the same .NET version as you, "some string".GetHashCode() on my machine would give the same value as on yours. Since the hashing mechanism used is simple, (and certainly not a cryptographically secure hash), it’s relatively easy to reverse engineer and create lots of strings with identical hashes, then use these as described above to amplify a DoS attack.

    With this setting enabled, an element of randomness is added to the hash code generation for strings, making it much more difficult for an attacker to craft colliding strings reliably.

    The fact that it’s per-AppDomain is a by-product of the fact that hash codes have certain required properties, e.g. two identical strings have identical hash codes. The AppDomain therefore provides a sensible boundary for the effects of the setting in that most applications will run perfectly fine with this setting enabled.

    This new setting likely further addresses issues raised in this vulnerability disclosure: CVE-2011-3414 related to exploiting hashing collisions in ASP.NET applications (the issue was “fixed” in other .NET versions, I believe, by limiting the number of keys that could be supplied in the request, preventing an attacker from creating so many collisions that performance was significantly degraded). The referenced paper specifically mentions the lack of randomized string hashing as a factor contributing to the widespread nature of the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

net c#. I have a page A with this code //ON PAGE A: string
NET web application and a WCF Application that share the same ASP.NET membership database.
net CF I need to use substring to capture the mid of a string.
.Net's Server.HTMLEncode() is the very helpful function that takes an HTML string and replaces
.Net core libraries source code (that can be accessed using Resharper) sometimes contain weird
.NET framework 3.5 introduces Action and Func<> predefined delegate types that are very handy.
.NET provides EventLog class that be able to write application event information to a
.Net framework contains a great class named Convert that allows conversion between simple types,
net ajax app. I have one modelpopup that shows a IFrame and inside Iframe
.NET 3.5 was different and co-existed along with .NET 2.0. Is that still the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.