Summary
HotCRP's formula engine introduced in version 3.1 generated PHP code from user-defined formulas without adequate sanitization or validation, allowing crafted input to influence the generated code.
Under certain conditions, users could cause this generated code to execute arbitrary PHP, potentially leading to full compromise of the application environment.
Affected context
The vulnerability occurs in HotCRP's formula feature, where user-provided formula expressions are parsed and transformed into PHP code for evaluation.
It affects deployments that:
- Allow users to define or edit formulas (e.g., for scoring, search, or views),
- Dynamically generate and execute PHP code based on those formulas,
- Do not apply strict validation and escaping on formula tokens before code generation.
In such setups, the formula engine becomes part of the trusted execution path, even though it is fed by potentially untrusted input.
Exploit preconditions
- Attack surface: Web interface where users can input or configure formulas (e.g., search formulas, score formulas, or custom computed fields).
- Required access: Ability to create or modify formulas; this might be available to authenticated users such as reviewers, chairs, or administrators depending on configuration.
- Trigger point: Evaluation of a formula that has been converted into PHP code by the application (e.g., when a search is run, a report is generated, or a page using the formula is viewed).
- Why exploitation is possible: The formula compiler performs inadequate validation and sanitization, allowing user-controlled fragments to be injected into generated PHP code, which is then executed by the server.
Why this happens
This issue stems from improper input validation in a dynamic code-generation pathway.
The formula system takes structured user input, parses it, and emits executable PHP code without fully constraining or sanitizing all user-controlled elements.
As a result, user-supplied formula syntax can escape intended expression boundaries and become part of the PHP runtime logic, aligning with CWE-20: Improper Input Validation.
Conceptually, the bug is that the application treats user formulas as semi-trusted "specifications" and fails to strictly enforce a limited, safe grammar before turning them into server-side code.
Potential impact
- Execution of arbitrary PHP code with the privileges of the web server process.
- Reading, modifying, or deleting conference data, including submissions, reviews, and user information.
- Stealing session data or escalating privileges within the HotCRP instance.
- Installing backdoors or pivoting to other systems accessible from the application server.
- Disrupting conference operations through data corruption or service interruption.
General mitigation guidance
Long-term mitigation generally focuses on eliminating or strongly constraining dynamic code generation:
- Replace direct PHP code generation with safe evaluation mechanisms (e.g., an interpreted expression engine that never emits raw PHP).
- Enforce a strict, well-defined grammar for formulas and validate all input against it before use.
- Treat all formula content as untrusted data and avoid concatenating it into executable code paths.
- Constrain the execution environment so that even if expression handling fails, the process runs with minimal privileges and limited file and network access.
- Apply defense-in-depth by limiting who can define or edit formulas and by logging and reviewing changes to powerful configuration features.
How teams detect issues like this
Detection typically involves a combination of code analysis and operational monitoring:
- Static analysis: Search for patterns where user-provided formula strings or similar fields are transformed into PHP code, especially via
eval,create_function, dynamicinclude, or similar constructs. - Code review: Examine the formula parsing and compilation components for direct string interpolation into code, insufficient tokenization, or reliance on ad-hoc escaping instead of a formal parser.
- Policy enforcement: Establish guidelines that forbid new features from emitting dynamic PHP from user input and gate such changes through security review.
- Runtime monitoring: Enable detailed logging when formulas are created, modified, or evaluated; correlate unusual patterns (e.g., unexpected operators or function-like constructs) with security alerts.
- Automated SAST or custom linting rules can help flag risky use of user-controlled data in code generation paths before deployment.

