dongliao6491 2014-09-29 08:18
浏览 44
已采纳

会话固定在Joomla 2.5

Impact that this can cause: 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.

And recommended solution to prevent session fixation attacks is to renew the session ID when a user logs in. This fix can be done at the code level or framework level, depending on where the session management functionality is implemented.

I'm trying to find a fix for this and still i'm not successful. Anyone can help how to fix this in Joomla 2.5?

I want to implement this fix at framework level. Any help will be appreciated.

  • 写回答

2条回答 默认 最新

  • douxie2029 2014-10-06 09:53
    关注

    Thanks a lot @ryadavalli ! It is very helpful. Using your suggested solution, I solved it for Joomla 2.5.

    Only few changes; for Joomla 2.5 the code needs to be placed in

    1. libraries/joomla/application/application.php
    2. libraries/joomla/session/session.php

    In application.php w.r.t your solution

    public function login($credentials, $options = array())
        {
            // Get the global JAuthentication object.
            jimport('joomla.user.authentication');
    
            $authenticate = JAuthentication::getInstance();
            $response = $authenticate->authenticate($credentials, $options);
    
            // Import the user plugin group.
            JPluginHelper::importPlugin('user');
    
            if ($response->status === JAuthentication::STATUS_SUCCESS)
            {
                 $session = &JFactory::getSession();
                        // we fork the session to prevent session fixation issues
                 $session->fork();
                // validate that the user should be able to login (different to being authenticated)
                // this permits authentication plugins blocking the user
                $authorisations = $authenticate->authorise($response, $options);
    

    In session.php, updated the code as following

    public function fork()
        {
            if ($this->_state !== 'active')
            {
                // @TODO :: generated error here
                return false;
            }
    
            // Save values
            $values = $_SESSION;
    
            // Keep session config
            /*$trans = ini_get('session.use_trans_sid');
            if ($trans)
            {
                ini_set('session.use_trans_sid', 0);
            } */
            $cookie = session_get_cookie_params();
    
            // Create new session id
            //$id = $this->_createId();
    
                session_regenerate_id(true);
                $id = session_id();
    
                // first we grab the session data
                $data = $this->_store->read();
    
            // Kill session
            session_destroy();
    
            // Re-register the session store after a session has been destroyed, to avoid PHP bug
            $this->_store->register();
    
            // Restore config
            ini_set('session.use_trans_sid', $trans);
            session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure']);
    
            // Restart session with new id
            session_id($id);
            session_start();
    
            $_SESSION = $values;
    
                //now we put the session data back
                $this->_store->write($id, $data);
    
            return true;
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 对于知识的学以致用的解释
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败