Skip to content

Reject non-numeric Sysadmin ports before comparing them to 80 - #38

Open
BradKollmyer wants to merge 1 commit into
FreePBX:release/17.0from
BradKollmyer:fix/php8-disabled-port
Open

BradKollmyer wants to merge 1 commit into
FreePBX:release/17.0from
BradKollmyer:fix/php8-disabled-port

Conversation

@BradKollmyer

Copy link
Copy Markdown

Fixes the PHP 8 port comparison reported in FreePBX/issue-tracker#1335.

Services.class.php on release/17.0 (17.0.2.1) still accepts Sysadmin's "disabled" as a port in three places:

  • acp (HTTP)
  • sslacp (HTTPS)
  • leport (Let's Encrypt)

On PHP 8 a non-numeric string compared with >= 80 is compared as a string, so "disabled" >= 80 is true. PHP 7 cast that string to 0 and the check failed closed. The other Sysadmin port lookups in this file already skip "disabled". restapi / sslrestapi cast with (int) first, which is also safe.

When leport is disabled, responsive Let's Encrypt rules call enableLeRules() with port "disabled". iptables rejects it (invalid port/service 'disabled'), and the temporary port-80 opening never happens. HTTP-01 renewal then cannot be reached from the internet. The same bad port is what fills firewall.err in issue 1335.

is_numeric() rejects "disabled" and any other non-port string. A !== 'disabled' guard, as the issue suggests and as UCP already uses, fixes this sentinel. is_numeric() also covers other non-numeric Sysadmin values.

Checked on a FreePBX 17 / PHP 8.2 host with leport disabled: after this guard, enableLeRules() adds real port 80 (from the HTTP service's leport flag) instead of the string disabled.

On PHP 8, "disabled" >= 80 is true, so HTTP, HTTPS, and LetsEncrypt
service discovery handed iptables the port string "disabled". Responsive
LetsEncrypt rules then never opened TCP 80.

Refs FreePBX/issue-tracker#1335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant