php / php/php-src

OpenSSL config path does not respect open_basedir restriction

Open
#9,317 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Extension: openssl
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

Currently the config in options passed to some functions is not checked if it is inside open_basedir restriction. This should be probably fixed just in master as it is not usually a big issue considering that the config is basically read only and some user flows might have relied on it being in the system path so we don't want to break them in a patch release. However we should still confirm to the open_basedir rules and prohibit it in master branch. One thing to note that this should not be applied on the default path as it would be too big break for not a big gain.

The following code:

<?php
// cert path (existing cert)
$config= "$file_path/openssl.cnf";

ini_set('open_basedir', "$file_path/config");

$pkey= openssl_pkey_new([
    'config' => $config
]);

var_dump($pkey);

Resulted in this output:

object...

But I expected this output instead:

possibly warning
bool(false)
PHP Version

Any

Operating System

Any

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the openssl_pkey_new() entry point and trace how its explicit 'config' option is handled under open_basedir. Verify that a config path outside the restriction is rejected while the default path remains unaffected, then add regression coverage for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.