PHP session.save_path Security Restriction Bypass

Published on 02 Jul 2018
1 min read
Vulnerability

The session save path function returns the path of the current directory that is being used to save session data. There are many servers with this vulnerability. This vulnerability exists due to an error while handling the session.save_path function. The session.save_path function changes the path used to save cookie data. This vulnerability can be exploited by an attacker through local access to bypass open_basedir restrictions. PHP with versions before 4.4.4 and with versions before 5.2.0 allowed an attacker to bypass security restrictions locally. This exploit existed due to a bug in session.save_path function that allowed an attacker to send an empty value to session.save_path function. This step by the attacker allowed him to bypass open_basedir restrictions.

The steps involved in this attack are:-

  1. Gain local access to the victim server.
  2. The attacker will modify tmpdir and place it in a directory where the attacker has full access.
  3. An empty value is sent to session.save_path. There is no official patch for this vulnerability by PHP. But, there are 3rd party updates as a fix for this vulnerability.

Example

The below code is an example of session_save_path().

        string session_save_path ([ string $path ] )

    

The above function returns the path.

Impact

Using this vulnerability, an attacker can:-

  • perform Cross-Site Request Forgery (CSRF)
  • manipulate sensitive information
  • leak sensitive information
  • gain administrator access to the web application

Mitigation / Precaution

Beagle recommends the following fixes:-

  • Try to patch the bug using reliable 3rd party suppliers because PHP has not fixed this bug yet. Make sure to restrict the access to the systems to trusted users.
Sooraj V Nair
Written by
Cyber Security Engineer

Sooraj was probably the kid who opened up a remote control just to see what was inside, then had to figure out how to put it back together before anyone noticed. That curiosity eventually found its way into cybersecurity, where breaking things is actually part of the job description. Today, he explores vulnerabilities, analysis threats, and helps build safer digital spaces. His favourite question remains the same: “What happens if I try this?”

Experience the Beagle Security platform
Unlock one full penetration test and all Advanced plan features free for 14 days
4.8 on G2 • ISO 27001 certified
See How Beagle Security Works
No credit card • No setup required
Launch interactive demo