Skip to content

Can open files using invalid paths #16622

Open
@cod3beat

Description

@cod3beat

Description

The path / /../ /../ /../ /../path/to/file is considered invalid by some file check functions:

<?php

is_file("/ /../ /../ /../ /../path/to/file"); // -> false
realpath("/ /../ /../ /../ /../path/to/file"); // -> false
filesize("/ /../ /../ /../ /../path/to/file"); // -> false

However, the path can actually be used to open /path/to/file :

<?php
echo file_get_contents("/ /../ /../ /../ /../path/to/file");

$res = fopen("/ /../ /../ /../ /../path/to/file", "r");
echo fread($res, 1024);

PHP Version

< 8.3

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions