2010-08-09 61 views
0

如果EnableViewStateMAC設置爲true,則ASP.NET將爲ViewState數據生成哈希碼並將其與發佈值中存儲的哈希碼進行比較。什麼阻止攻擊者根據更改後的表單值設置哈希值?ViewState EnableViewStateMAC

回答

3

基於表單值和服務器(請參閱Salt on wikipedia)已知的私鑰,生成的散列值爲。所以,當你沒有salt字符串時,你不能生成有效的散列。

您可以檢查從單執行 ASP.NET源和見System.Web.UI.ObjectStateFormatter類,方法反序列化()

if (EnableMac) { 
    data = MachineKeySectionUtils.VerifyDecrypt (Section, data); 
else { 
    data = MachineKeySectionUtils.Decrypt (Section, data); 
} 

,並在System.Web.Util.MachineKeySectionUtils類,方法VerifyDecrypt()

using (KeyedHashAlgorithm kha = GetValidationAlgorithm (section)) { 
    kha.Key = GetValidationKey (section); 
    // ... 
} 

其中GetValidationKey()返回鹽標誌並驗證哈希...