1

This article says that having opcache_get_status() enabled is a security risk. To turn it off, one has to configure opcache.restrict_api, but I couldn't find an example of how.

This person had the restriction in effect when configured as opcache.restrict_api=/restricted, which gives me a clue that it needs to be a path.

I started by creating a test script with an opcache_get_status() call, and I got an output of lots of PHP scripts on that system, confirming there was no restriction. Then I edited my /etc/php/7.3/fpm/php.ini to have opcache.restrict_api=/dev/null, and that same call now returns bool(false) - I take that the restriction is enabled.

My goal is to forbid opcache_get_status() and the like completely, and by 'allowing' scripts under /dev/null, I'm essentially making it impossible to use, since you can't a file there.

  • Is this logic correct?
  • Should I maybe use some other path?
  • Is there a way to enable the restriction directly, without messing around with fake paths?

Thank you

1 Answer 1

2

Looking at the source code of ext/opcache/zend_accelerator_module.c

Also here's someone else using opcache.restrict_api=1 too.

Please correct me if I'm wrong somewhere! Until then, I feel like this pretty much answers my question.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .