Summary
Invoice Ninja v5.12.46 and v5.12.48 contain a Server-Side Request Forgery (SSRF) issue in CheckDatabaseRequest.php, allowing crafted inputs to trigger outbound HTTP requests from the server.
When an attacker can influence database check or connectivity URLs, they may cause the application server to connect to arbitrary internal or external endpoints, exposing internal services or metadata.
Affected context
This vulnerability appears in the database connectivity or validation logic implemented in CheckDatabaseRequest.php within Invoice Ninja.
It is relevant where:
- The application performs server-side checks to validate database hosts or related endpoints.
- User-controlled or tenant-controlled data can influence the target of these checks.
- Outbound network egress from the application server is allowed, including to internal addresses or metadata services.
The issue is most impactful in deployments where the Invoice Ninja server has network visibility into internal infrastructure not intended to be exposed to end users.
Exploit preconditions
- Attack surface: HTTP(S) interface where database configuration or connectivity checks are initiated (e.g., setup, configuration, or admin flows).
- Required access: Ability to submit or modify parameters used by
CheckDatabaseRequest.php(such as host, URL, or connection string fields). This may require authenticated access depending on deployment. - Trigger point: Invocation of the database check routine, which initiates an outbound request using attacker-influenced input.
- Why exploitation is possible: The server-side code treats untrusted input as a network target and issues backend requests without sufficient validation or restriction of destination hosts, protocols, or IP ranges, matching the SSRF pattern described in CWE-918.
Why this happens
The underlying flaw is the lack of strict validation and sanitization around how destination hosts or endpoints are derived for server-side connectivity checks in CheckDatabaseRequest.php.
User-supplied or otherwise untrusted parameters are used to construct outbound network requests, and the server executes those requests with its own network privileges.
This reflects CWE-918: Server-Side Request Forgery, where an attacker leverages server-initiated HTTP requests to interact with arbitrary internal or external resources.
In abstract terms, the bug class is: "Application logic that converts untrusted configuration-like input directly into network destinations, without applying allow-listing, DNS/IP filtering, or scheme restrictions."
Potential impact
- Access to internal services that are not directly exposed to the internet (e.g., databases, message queues, admin panels).
- Interaction with cloud metadata endpoints, which may disclose credentials, tokens, or configuration.
- Port scanning or network reconnaissance of internal addresses from the server's perspective.
- Potential data exfiltration from internal endpoints that respond with sensitive information.
- Abuse of the server as a proxy to reach external targets, possibly bypassing IP-based access controls.
General mitigation guidance
Effective mitigation focuses on reducing trust in user-controlled network destinations and constraining server-initiated requests:
- Introduce strict allow-lists for hosts or networks that database connectivity checks are permitted to contact (e.g., known DB hosts or internal ranges only).
- Enforce validation on protocol and port, disallowing non-expected schemes (such as HTTP) when only database protocols are intended.
- Implement IP and DNS resolution filtering to block requests to loopback, link-local, private network ranges, and cloud metadata endpoints unless explicitly required.
- Decouple user input from direct network calls by mapping user-selectable options to predefined, server-side configuration rather than free-form hostnames or URLs.
- Run the application with least-privilege network exposure, limiting outbound connectivity where possible via firewall rules or network policies.
How teams detect issues like this
Detection approaches generally combine code-centric analysis with runtime monitoring:
- Static analysis / code review:
- Search for HTTP clients or low-level socket usage in
CheckDatabaseRequest.phpand related classes where destination URLs/hosts derive from request data or configuration fields. - Flag patterns where user-controlled fields (e.g., "host", "url", "server") are passed into network client constructors without validation or allow-list enforcement.
- Review database connectivity helpers for any generic URL parsing that supports unexpected schemes or ports.
- Policy enforcement:
- Implement secure coding guidelines that prohibit direct network calls to unvalidated user-provided addresses.
- Use automated SAST or custom linters to identify potential SSRF sinks (HTTP clients, database drivers) fed by request parameters.
- Operational monitoring:
- Monitor outbound connections from the Invoice Ninja host for anomalous destinations, such as link-local IPs, 169.254.0.0/16, 127.0.0.0/8, or unusual external hosts triggered by user actions.

