🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.vms
Article #244

Re: More PHP vulnerabilities

#244
From: Dan Cross
Date: Tue, 24 Nov 2026 00:37
93 lines
4812 bytes
In article <11e24vp$265v0$1@dont-email.me>,
Simon Clubley  <clubley@remove_me.eisner.decus.org-Earth.UFP> wrote:
>On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>> On 11/20/2026 3:10 PM, Simon Clubley wrote:
>>> On 2026-11-20, Arne Vajhøj <arne@vajhoej.dk> wrote:
>>>> On 11/19/2026 4:25 PM, Arne Vajhøj wrote:
>>>>> echo file_get_contents("http://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>>> //echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>>> echo file_get_contents("https://arnepc5.vajhoej.dk/reveal.aspx", false,
>>>>> stream_context_create($sslctxopts)) . "\n";
>>>>> echo file_get_contents("HTTPS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>>> echo file_get_contents("httpS://arnepc5.vajhoej.dk/reveal.aspx") . "\n";
>>>>
>>>>> $ php another.php
>>>>> Port = 80
>>>>> Port = 443
>>>>> Port = 80
>>>>> Port = 80
>>>> And for the curious - before fix:
>>>>
>>>> use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) &&
>>>> ZSTR_VAL(resource->scheme)[4] == 's';
>>>
>>> I really hope that line was always compiled by a short-circuiting
>>> compiler and that line always successfully triggered short-circuiting...
>>>
>>> Don't be surprised if everyone is now looking for similar constructs
>>> that rely on short-circuiting to be safe.
>> Doesn't C require/mandate short circuiting in cases like this??
>>
>
>As Dan has pointed out, yes. However, I absolutely hate that style of
>coding (and the use of short circuiting in general) - it is way too fragile.
>
>It depends on the compiler behaving as expected and it depends on someone
>not making some edit change that happens to have the unexpected side-effect
>of disabling any working short circuiting.

I'm going to have to push back on this.  Short-circuiting of
boolean operators, in C, is a defined part _of the language_ and
is specified by an international standard.  If a compiler is
miscompiling them, then that's a compiler bug or a language that
is not C.

>Seriously. Please consider not using short circuiting and instead writing
>your code so it works regardless of whether your compiler short-circuits
>or not. (Or it suddenly decides to stop short-circuiting one day).

This begs the question: what other parts of the language should
we not use?

>Oh, and before you all start mocking me, please read this:
>
>https://www.redhat.com/en/blog/security-flaws-caused-compiler-optimizations

Apples and oranges, I'm afraid; that post concerns optimizations
in the face of _undefined behavior_, which is a concept that is
specified in the C standard.  But short-circuiting is
well-defined.

>Even Linux has been caught out in the past by compilers not behaving
>as expected.

Linux is full of bugs, and that's exactly what this is.  The
compiler is right; Linux was wrong.

Here's the TAP/TUN example from that post:

1?   static unsigned int tun_chr_poll(struct file *file, poll_table * wait)
2?   {
3?       struct tun_file *tfile = file->private_data;
4?       struct tun_struct *tun = __tun_get(tfile);
5?       struct sock *sk = tun->sk;
6?       unsigned int mask = 0;
7?       if (!tun)
8?           return POLLERR;

The issue here is that dereferncing a NULL pointer is undefined
behavior, which is behavior for which the C standard imposes
abolutely _no_ requirements.  Thus, a compiler is free to assume
that it does not exist/does not occur; in this case, on line 5,
we dereference `tun` (to get its `sk` member).  But since
deref'ing a NULL pointer is UB, the compiler is free to assume
that it doesn't happen; then, on line 7, the compiler elides the
conditional (and return) since it "knows" that `tun` cannot be
nil, since it was dereferenced on line 5.

But this is _qualitatively different_ than relying on
short-circuiting for `&&` and `||`, which (again) is explicitly
defined by the language.

	- Dan C.
Technical Details
Message-ID: <11e2m8f$i1e$1@reader2.panix.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
References: <11dnpep$2kvk6$2@dont-email.me> <11dq9gg$3ghpm$1@dont-email.me> <11dqa7g$3guqc$1@dont-email.me> <11e24vp$265v0$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cross@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.os.vms
Subject: Re: More PHP vulnerabilities
Date: Tue, 24 Nov 2026 00:37:35 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <11e2m8f$i1e$1@reader2.panix.com>
References: <11dnpep$2kvk6$2@dont-email.me> <11dq9gg$3ghpm$1@dont-email.me> <11dqa7g$3guqc$1@dont-email.me> <11e24vp$265v0$1@dont-email.me>
Injection-Date: Tue, 24 Nov 2026 00:37:35 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
	logging-data="18478"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)