Skip to content

PHP Bug when using shell_exec on Centos Stream and also 8. #13257

@batata004

Description

@batata004

Description

In my server selinux is already set to disabled. Also <?php echo exec('whoami'); ?> returns apache. In my visudo I already added the line apache ALL=(ALL) NOPASSWD:ALL. So all look fine.

Then I create this test.php file:

<?php echo shell_exec('sudo echo "aa" > /a.txt'); ?>

If I run this using the command line php test.php it all works fine. However if I try to access domain.com/test.php in the browser (I am using all default configurations from Apache/PHP, nothing changed) the file never gets created and no error message it shown anywhere.

I already reported this on SO and after people looking into this, they told me to come here and report this.

PHP Version

latest but I think affects all 8 version

Operating System

Centos stream and 8

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions