php-src icon indicating copy to clipboard operation
php-src copied to clipboard

Surfacing security issues with OpenBSD as part of the CI with hardened memory allocator

Open loganaden opened this issue 1 month ago • 11 comments

Description

Hi folks,

We are analysing the PHP code and while it's clear that there are performance benefits from PHP current ZendMM allocator, we also see benefits from disabling it as a build option to surface memory corruption security bugs.

OpenBSD has a hardened memory allocator which can surface a lot of those security issues: OpenBSD malloc

Would the PHP team be willing to accept a PR for the CI which adds OpenBSD as a runner for CI builds with USE_ZEND_ALLOC=0 activated ?

loganaden avatar Oct 25 '26 05:10 loganaden

@iluuu1994 there is already a FreeBSD VM: https://github.com/php/php-src/blob/master/.github/actions/freebsd/action.yml. We can build the same for OpenBSD with USE_ZEND_ALLOC=0 ? we would be happy to help maintain this as part of the CI as we use OpenBSD a lot.

loganaden avatar Oct 25 '26 06:10 loganaden

This is a sensible proposal. OpenBSD hardened allocator can help identify security issues early.

Digi-Levy avatar Oct 25 '26 10:10 Digi-Levy

USE_ZEND_ALLOC=0 can leak memory on fatal errors such as timeouts. We're considering getting rid of longjmp() completely, which would make this possible.

iluuu1994 avatar Oct 28 '26 15:10 iluuu1994

@iluuu1994 how can we help with getting rid of longjmp() ?

loganaden avatar Oct 28 '26 16:10 loganaden

@iluuu1994 is the first step deprecating use of longjmp() in different parts of the code ? Can we start with extensions ?

loganaden avatar Oct 29 '26 04:10 loganaden

@loganaden We don't know yet. Some things like timeout can switch from bailout to a GracefulExit, like soft-OOM does. Other things like E_ERROR might have to switch to _exit(). There were some complications when we looked at this, like preloading depending on catchable longjmp(). _exit() can also be problematic for ZTS.

iluuu1994 avatar Oct 31 '26 02:10 iluuu1994

@iluuu1994 can we send a PR for OpenBSD in the CI ?

loganaden avatar Nov 14 '26 09:11 loganaden

@loganaden Not sure what specifically you're referring to. 🙂 But sure, unless there are security implications you can send any PR.

iluuu1994 avatar Nov 16 '26 21:11 iluuu1994

@iluuu1994 we would like to send a 1st PR to have OpenBSD 8.0 as part of the PHP CI, in addition to FreeBSD. Then, later once everybody is comfortable we can enable more mitigations on OpenBSD ?

loganaden avatar Nov 17 '26 03:11 loganaden

@loganaden We could consider OpenBSD for nightly, yes. (I.e. executed once per day per branch, rather than for ever push/PR)

iluuu1994 avatar Nov 18 '26 13:11 iluuu1994

OpenBSD CI would be good as it would give us LibreSSL. It should be on the same level as Solaris which means nightly and optional label trigger.

bukka avatar Nov 23 '26 12:11 bukka