Skip to content

security: restrict AJAX during upgrade and escape installer config writes#706

Open
anonymoususer72041 wants to merge 2 commits intoopencats:masterfrom
anonymoususer72041:security/restrict-ajax-during-upgrade
Open

security: restrict AJAX during upgrade and escape installer config writes#706
anonymoususer72041 wants to merge 2 commits intoopencats:masterfrom
anonymoususer72041:security/restrict-ajax-during-upgrade

Conversation

@anonymoususer72041
Copy link
Copy Markdown
Contributor

@anonymoususer72041 anonymoususer72041 commented Jan 30, 2026

Summary

When upgrade mode is active and INSTALL_BLOCK is missing, ajax.php now only allows installer AJAX actions (install:*). All other AJAX requests are rejected early with the standard XML error response.

This PR also hardens installer config writes in modules/install/ajax/ui.php by escaping string values before passing them to CATSUtility::changeConfigSetting(). The affected installer settings now use safe PHP string literals via var_export($value, true) before being written to config.php.

Motivation

During upgrades, index.php is already blocked when INSTALL_BLOCK is missing, but ajax.php remained accessible. That could allow existing sessions or stale UI tabs to continue sending AJAX requests while schema migrations are running, increasing the risk of unintended changes or inconsistent state.

Review also identified that several installer config values were still passed unescaped into CATSUtility::changeConfigSetting(), which then writes them directly into executable PHP in config.php. Escaping those values closes that remaining installer hardening gap without changing the intended installer flow.

@anonymoususer72041 anonymoususer72041 added the security Pull requests that address a security vulnerability label Mar 5, 2026
@anonymoususer72041 anonymoususer72041 force-pushed the security/restrict-ajax-during-upgrade branch from 999e9cb to 1f2c1c1 Compare March 18, 2026 09:53
@RussH
Copy link
Copy Markdown
Member

RussH commented Apr 15, 2026

Thanks — definitely in the right direction, but checks show installer security is not fully hardened after this.

The remaining gap is that modules/install/ajax/ui.php still passes unescaped values into CATSUtility::changeConfigSetting(), which then writes them directly into executable PHP in config.php.

Could this PR also harden the config write paths by safely escaping the PHP string values before writing them, it could be as easy as using var_export($value, true) instead of concatenating raw input inside quotes before passing it to changeConfigSetting(), for;

  • DATABASE_USER
  • DATABASE_PASS
  • DATABASE_HOST
  • DATABASE_NAME
  • MAIL_SENDMAIL_PATH
  • MAIL_SMTP_HOST
  • MAIL_SMTP_USER
  • MAIL_SMTP_PASS
  • ANTIWORD_PATH
  • PDFTOTEXT_PATH
  • HTML2TEXT_PATH
  • UNRTF_PATH

That'd be ideal!

@anonymoususer72041 anonymoususer72041 force-pushed the security/restrict-ajax-during-upgrade branch from 1f2c1c1 to ec805b8 Compare April 15, 2026 10:39
@anonymoususer72041 anonymoususer72041 changed the title security: restrict ajax.php to installer actions when INSTALL_BLOCK is missing security: restrict AJAX during upgrade and escape installer config writes Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security Pull requests that address a security vulnerability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants