Java編程安全漏洞之:數據或系統信息安全

Cleartext_Submission_of_Sensitive_Information

明文提交敏感數據,使用明文通訊方式傳輸、提交敏感數據java

修復建議

加密後再提交或使用加密的通訊方式傳輸、提交敏感數據。web

Use_of_Insufficiently_Random_Values

使用了不夠隨機的隨機值算法

修復建議

使用足夠隨機的隨機值,如使用java自帶Random生成隨機數,則可添加必定算法。安全

修復示例

如:cookie

       public void Use_of_Insufficiently_Random_Values(){session

              String rans = new Random().nextInt() + "";dom

       }函數

修復爲:加密

       public void Use_of_Insufficiently_Random_Values_Fix(){spa

              String rans = new Random().nextDouble() + "";

       }

Use_of_a_One_Way_Hash_without_a_Salt

使用了沒有添加鹽值的單向散列函數

修復建議

添加鹽值。

修復示例

如:

       public void Use_of_a_One_Way_Hash_without_a_Salt(){

              String text = "";

              String dtext = "";

              MessageDigest md = MessageDigest.getInstance("SHA");

              byte[] dbts = md.digest(text.getBytes());

              dtext = new String(dbts);

       }

修復爲:

       public void Use_of_a_One_Way_Hash_without_a_Salt_Fix(){

              String text = "";

              String dtext = "";

              MessageDigest md = MessageDigest.getInstance("SHA");

              md.update(("" + new Random().nextDouble()).getBytes());

              byte[] dbts = md.digest(text.getBytes());

              dtext = new String(dbts);

       }

HttpOnlyCookies_In_Config

啓用了Cookie功能。

修復建議

關閉Cookie功能,只有http協議使用。

修復示例

在web.xml中添加或設置以下屬性:

       <session-config>

              <cookie-config>

                     <http-only>true</http-only>

              </cookie-config>

       </session-config>

External_Control_of_Critical_State_Data

程序在一個未經受權的用戶能夠訪問的位置存儲了與用戶或軟件自己相關的安全狀態信息。

相關文章
相關標籤/搜索