Summary
A SQL injection vulnerability in Ghostfolio's getHistorical() method allows attackers to bypass symbol validation and inject arbitrary SQL into database queries.
When exploited, this can enable reading, modifying, or deleting sensitive financial data for all users, especially in deployments where user-controlled input is used to query historical portfolio or market data.
Affected context
The vulnerability appears in Ghostfolio instances where client-supplied identifiers (such as asset or symbol fields) are passed through the getHistorical() method and incorporated into SQL queries without strict parameterization.
It is most relevant when:
- The application exposes endpoints or features that call getHistorical() based on user input
- Symbol validation can be bypassed or partially skipped
- The database account used by Ghostfolio has broad read/write/delete privileges on financial and user-related tables
Exploit preconditions
- Attack surface: HTTP(S) endpoints or internal APIs that invoke getHistorical() using user-supplied symbol or asset data.
- Required access: Ability to submit crafted requests (usually as an authenticated or sometimes unauthenticated user, depending on how the relevant endpoints are exposed).
- Trigger point: The getHistorical() method constructs a SQL statement incorporating the symbol value after symbol validation has been bypassed or circumvented.
- Why exploitation is possible: The query-building logic does not consistently use parameterized statements or proper escaping for the symbol field, allowing attacker-controlled input to be interpreted as part of the SQL command instead of as data.
Why this happens
This issue is rooted in constructing SQL queries by concatenating or interpolating user-controlled values into query strings, without enforcing proper parameterization for the symbol input.
When symbol validation can be bypassed, the application effectively trusts attacker input in a position that directly affects SQL syntax and semantics.
This maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where insufficient input handling allows malicious tokens (such as quotes, operators, or additional statements) to alter the intended database query.
Potential impact
- Attackers may read sensitive financial data for all users, including holdings, transactions, and performance metrics.
- Malicious actors could modify or delete portfolio records, transaction histories, or configuration data.
- Data integrity for financial analytics and reports can be corrupted, leading to incorrect balances and misleading performance calculations.
- Persistent tampering with stored data can undermine trust in the system and potentially impact downstream systems that rely on exported or synchronized data.
- In some deployments, attackers may escalate their access by abusing database-level privileges or stored procedures.
General mitigation guidance
Effective mitigation focuses on isolating user input from SQL syntax and constraining how symbol values are used in queries.
Common defensive patterns include:
- Using parameterized queries or prepared statements for all database access, especially where symbol or asset identifiers are involved.
- Implementing strict allowlists for symbols and other identifiers, ensuring that only pre-approved, schema-conforming values are accepted and translated into queries.
- Centralizing query construction logic, avoiding ad hoc string concatenation or manual interpolation of user-supplied values.
- Applying the principle of least privilege to the database user so that even if a query is compromised, it cannot perform broad administrative actions.
- Validating and normalizing identifiers at the boundary (e.g., matching against known symbol formats or stored reference tables) and rejecting requests that fail validation rather than attempting to correct them.
How teams detect issues like this
Organizations can look for this class of issue using a combination of static and dynamic techniques:
- Static application security testing (SAST) rules targeting direct string concatenation into SQL queries, especially in data access layers or methods like getHistorical().
- Code review checklists that highlight red flags such as:
- Dynamic query construction using template literals or string concatenation
- Use of raw SQL helper functions without parameters
- Conditional validation flows that can be bypassed or short-circuited
- Runtime application security monitoring that detects anomalous query patterns, such as stacked queries, tautological WHERE clauses, or unexpected schema access.
- Database-level logging and anomaly detection on query logs to flag suspicious patterns indicative of injection attempts.
- Incorporating automated security tests into CI/CD that attempt to send benign injection payloads to endpoints using getHistorical() and related query builders.

