安全性:会话标识符未在tcl中更新

时间:2014-07-01 10:53:53

标签: session tcl session-cookies owasp project-open

我正在开发应用程序"Project-Open",在扫描过程中我遇到了以下漏洞:

[Medium] Session Identifier Not Updated
Issue: 13800882
Severity: Medium
URL: https://<server_name>/register/
Risk(s): It is possible to steal or manipulate customer session and cookies, which might be used to impersonate a legitimate user,allowing the hacker to view or alter user records, and to perform transactions as that user
Fix: Do not accept externally created session identifiers

虽然提到了修复但是我不能完全理解它。请指导我如何删除它。如果有任何进一步的细节需要了解这个问题,请告诉我。 项目源代码在tcl

我发现以下代码也是如此,但它在java中。

  public HttpSession changeSessionIdentifier(HttpServletRequest request) throws AuthenticationException {

     // get the current session
        HttpSession oldSession = request.getSession();

     // make a copy of the session content
        Map<String,Object> temp = new ConcurrentHashMap<String,Object>();
        Enumeration e = oldSession.getAttributeNames();
        while (e != null && e.hasMoreElements()) {
               String name = (String) e.nextElement();
               Object value = oldSession.getAttribute(name);
               temp.put(name, value);
        }

     // kill the old session and create a new one
        oldSession.invalidate();
        HttpSession newSession = request.getSession();
        User user = ESAPI.authenticator().getCurrentUser();
        user.addSession( newSession );
        user.removeSession( oldSession );

     // copy back the session content
        for (Map.Entry<String, Object> stringObjectEntry : temp.entrySet()){
             newSession.setAttribute(stringObjectEntry.getKey(),       stringObjectEntry.getValue());
         }
  return newSession;

}

P.S。我是TCL的新手。 如果您需要任何进一步的解释,请告诉我。

2 个答案:

答案 0 :(得分:2)

OpenACS 5.9中有一个解决方案可以解决您的扫描报告问题。请参阅OpenACS.org上的以下讨论以供参考。

http://www.openacs.org/forums/message-view?message_id=5332821

答案 1 :(得分:0)

OWASP报告所讨论的问题是无法迁移会话以使用新ID,从而使攻击者更容易发现ID并重用它。对此的保护是不时地更改会话ID(不,我不知道多久!)并且Java代码正在参与这样做。

会话表示为存储在浏览器中的令牌,通常在cookie中(这就是Cookie的设计目的)。然后,该令牌用于查找与会话相对应的数据库记录,该会话保存会话中键/值映射的序列化。这是一个简单的机制,但非常强大。由于序列化等原因,用于完成所有这些操作的Java代码在幕后将相当复杂,但Tcl值(通常,并且始终用于内置类型)可自然地序列化,因此应该证明这不是一个问题。 ;将会话复制到新密钥可以在不必首先进行反序列化的情况下完成。

执行此操作的确切代码取决于使用的框架。我不知道]project-open[使用了什么,所以我们现在就可以钻。你需要和其他真正在PO工作的人交谈......


尽管如此,最好的方法是让给客户端的密钥不是主键,这样你就可以更改会话密钥而不必删除东西。只需要一个会话密钥列(带索引!),你就能使事情正常。这是一种更复杂的方法;在您的环境中实施可能不切实际。