Summary
Admidio up to version 5.0.6 contains a second-order SQL injection vulnerability in the MyList configuration feature, where previously stored user-controlled values are later used to build SQL queries unsafely.
An authenticated attacker can craft malicious list configuration data that is safely stored via prepared statements but subsequently interpolated into dynamic SQL, allowing arbitrary query execution and potential full database compromise.
Affected context
The vulnerability occurs in Admidio's MyList configuration feature, which allows authenticated users to define custom list column layouts, sort directions, and filters.
Although these configuration values are initially persisted using prepared statements into the adm_list_columns table, they are later read back and injected directly into dynamically built SQL queries without proper sanitization or parameterization.
Environments where users can create or modify MyList configurations and where the application uses a shared database account with broad privileges are particularly exposed.
Exploit preconditions
- Attack surface: Web application interface for managing MyList configurations within Admidio.
- Required access: Authenticated user account with permission to create or modify MyList configuration entries.
- Stored input control: Ability to set or update column names, sort directions, or filter conditions that are persisted in the
adm_list_columnstable. - Trigger point: Any subsequent request or feature that loads these stored configuration values and uses them to construct SQL statements (for example, rendering customized lists).
- Why exploitation is possible: The application initially uses prepared statements to store user input (safe write), but later concatenates those stored values directly into SQL syntax without parameterization (unsafe read), enabling second-order SQL injection.
Why this happens
This issue stems from building SQL queries by concatenating previously stored user-controlled data directly into SQL strings without using bound parameters.
While the initial persistence of MyList configuration values uses prepared statements, the design assumes that data read from the database is inherently safe and can be embedded into SQL syntax to define columns, sorting, and filters.
This pattern matches CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), and specifically represents a second-order injection: input is safely stored but later reinterpreted as part of executable SQL.
The absence of strict whitelisting, robust escaping, or parameterized query construction for these dynamic SQL fragments makes it possible for crafted values to alter query structure.
Potential impact
- Execution of arbitrary SQL queries under the application's database account.
- Reading sensitive information from arbitrary tables, including user data or configuration details.
- Modifying or deleting application data, leading to integrity loss or denial of service.
- Creation or modification of application-level roles, permissions, or user records through database manipulation.
- Potential pivoting to access additional databases or features reachable by the same database credentials, depending on configuration.
General mitigation guidance
Mitigation generally focuses on eliminating dynamic SQL that directly incorporates user-controlled or derived values:
- Prefer parameterized queries for all user-influenced parts of SQL, including those read back from configuration tables.
- Use strict whitelisting and mapping for column names, sort directions, and filterable fields (e.g., mapping user choices to predefined, trusted identifiers rather than storing raw SQL fragments).
- Separate query structure from data: enforce that user or configuration data influence only parameters, never SQL keywords, operators, or identifiers.
- Introduce validation layers that normalize and constrain MyList configuration values (for example, restricting sort directions to an enum, and columns to a known set).
- Run the application with a database account that has least-privilege permissions, reducing the impact of any unexpected query execution.
How teams detect issues like this
Effective detection typically combines code-centric review with runtime monitoring:
- Perform static analysis to flag any dynamic SQL construction that concatenates data originating from user-editable configuration tables like
adm_list_columns. - During code review, trace data flows from user input through persistence layers back into query construction, specifically looking for "safe write, unsafe read" patterns indicative of second-order injection.
- Establish secure coding guidelines that require parameterization and whitelisting for query building, and use automated linters or SAST tools to enforce these patterns in pull requests.
- Monitor database logs for anomalous or unexpectedly complex queries originating from list rendering or configuration-driven features.
- Employ application-level logging to correlate suspicious MyList configuration changes with subsequent database errors or unusual query activity.

