Summary
A critical SQL injection vulnerability in Friendica allows unauthenticated remote attackers to inject arbitrary SQL statements through the photo-view order parameter. Because the parameter is concatenated into a database query without adequate escaping, attackers may read, modify, or delete application data.
Affected context
The vulnerability occurs in Friendica's photo-view functionality when the order parameter is incorporated into a SHOW COLUMNS query through a direct database query API. Deployments are at risk when this endpoint is publicly reachable and request parameters can reach the query without strict validation or parameterization.
Exploit preconditions
- Attack surface: Publicly accessible photo-view functionality
- Required access: No authentication may be required
- Trigger point: Processing of the photo-view order parameter
- Why exploitation is possible: User-controlled input is concatenated into a SQL statement and executed through a database query interface that permits stacked statements
Why this happens
The underlying defect is the construction of SQL statements by concatenating untrusted request data into a query string. This insecure pattern allows input to alter query structure and, where the database interface permits multiple statements, extend execution beyond the intended operation. The issue maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Potential impact
- Attackers may read sensitive database records
- Attackers could modify application, user, or configuration data
- Attackers may delete database contents
- The application could suffer data integrity loss or service disruption
- Compromised data could support further account or infrastructure attacks
General mitigation guidance
Mitigation generally focuses on ensuring that untrusted values cannot influence SQL syntax.
Common defensive patterns include:
- Using parameterized queries or prepared statements for all variable values
- Applying strict allowlist validation for order fields and directions
- Avoiding database APIs that permit unintended stacked statement execution
- Restricting database credentials to the minimum required operations
- Separating application and administrative database privileges
- Treating client-supplied sorting and filtering values as untrusted by default
These controls should be combined with consistent query-construction standards and centralized database access helpers.
How teams detect issues like this
Organizations can look for:
- Static analysis findings involving string concatenation or interpolation in SQL calls
- Code review signals where request parameters flow directly into query-building logic
- Database API usage that executes dynamically assembled statements
- Runtime monitoring for unusual query syntax, stacked statements, or unexpected schema access
- Web application firewall and database audit policies covering injection indicators
Automated code review and security scanning tools can help identify unsafe data flows, but findings should be validated against actual query construction and database behavior.

