Summary
A critical authentication bypass in ChurchCRM's API middleware allows attackers to reach protected API endpoints without valid credentials by crafting URLs that contain the string api/public anywhere in the path.
Under these conditions, all data and system information normally protected by authentication may become accessible to unauthenticated users over the network.
Affected context
This vulnerability affects ChurchCRM deployments whose API layer relies on the AuthMiddleware in ChurchCRM/Slim/Middleware/AuthMiddleware.php to enforce authentication.
The issue arises when route protection is implemented using path-based checks that treat any URL containing api/public as public, regardless of its actual endpoint semantics.
Environments exposing the ChurchCRM API over the network—especially those reachable from the internet—are at particular risk if URL patterns can be freely controlled by an attacker.
Exploit preconditions
- Attack surface: HTTP(S) API endpoints exposed by the ChurchCRM application.
- Required access: Network access to the ChurchCRM server (no valid user account required).
- Trigger point: Any request URL that includes the substring
api/publicwithin the path to an endpoint that should normally be protected. - Why exploitation is possible: The authorization logic in the API middleware incorrectly assumes that the presence of
api/publicin the URL is sufficient to treat the request as public, bypassing authentication checks for endpoints that should remain protected.
Why this happens
The root cause is a flawed authorization decision based on brittle string matching rather than explicit route-level access control.
Instead of binding authentication requirements to well-defined route metadata or middleware configuration, the code infers "public" access from the presence of api/public in the request path.
This pattern maps to CWE-284: Improper Access Control, where incorrect enforcement of security policies allows unauthorized access to resources.
The underlying bug class is logic-based: a misapplied, overly broad condition that classifies requests as unauthenticated-safe when they are not, leading to full authentication bypass for any endpoint reachable via a crafted URL.
Potential impact
- Unauthorized retrieval of church member records and associated personal information.
- Exposure of internal system configuration data and operational metadata.
- Ability to enumerate users, roles, and potentially sensitive church-related information.
- Increased likelihood of follow-on attacks such as targeted phishing, account takeover attempts, or social engineering.
- Loss of confidentiality and potential non-compliance with data protection and privacy regulations.
General mitigation guidance
Mitigation centers on replacing path-fragment-based authorization logic with explicit, route-centric access control.
Recommended secure patterns include:
- Defining authentication and authorization requirements at the route or controller level, avoiding substring or pattern-based "public" checks.
- Using a centralized access control policy that ties each endpoint to required roles or authentication states, rather than inferring trust from URL structure.
- Implementing a default-deny posture for API routes: any endpoint not explicitly marked as public should require authentication.
- Separating public and private routes into distinct namespaces or modules with clearly differentiated middleware chains.
- Minimizing reliance on user-controlled URL components for security decisions, using framework routing metadata instead.
How teams detect issues like this
Detection efforts can focus on both code and behavior:
- Static analysis and code review:
- Search for authorization decisions based on string operations on URLs or paths (e.g.,
strpos($path, 'api/public')). - Flag middleware that uses naming conventions or path substrings as the primary signal for public vs protected endpoints.
- Verify that all privileged API routes are explicitly bound to authentication and authorization middleware.
- Dynamic and behavioral checks:
- Perform authenticated vs unauthenticated comparisons for API endpoints to confirm that protected routes cannot be accessed without credentials.
- Use automated API scanners or integration tests to attempt access to protected resources while injecting
api/publicor similar markers into URLs. - Policy and tooling:
- Enforce security review gates on route definitions and middleware configuration.
- Integrate security linters or SAST tools configured with custom rules for brittle path-based access control patterns.

