Summary
A SQL injection vulnerability in the YesWiki Bazar module allows user-controlled data from $_POST['id_fiche'] to be concatenated directly into a raw SQL query without sanitization or parameterization.
Under typical deployments where attackers can submit or modify id_fiche values, this flaw can enable unauthorized database access, data exfiltration, or manipulation through crafted input.
Affected context
This vulnerability occurs within the YesWiki Bazar module's EntryManager functionality, where incoming POST requests carry an id_fiche parameter.
The issue is present when:
- The application accepts
id_fichevia HTTP POST (e.g., form submissions or AJAX calls), - The value is passed to
EntryManager.phpand concatenated into a SQL query at line 704, - No database abstraction with prepared statements or centralized input validation is enforced for this field.
Any deployment that exposes the Bazar module to untrusted users may be affected.
Exploit preconditions
- Attack surface: Web-facing endpoints that invoke the Bazar
EntryManagerand process$_POST['id_fiche']. - Required access: Ability to send POST requests to the vulnerable endpoint (often anonymous or low-privileged user access is sufficient).
- Trigger point: Submission of a specially crafted
id_fichevalue that alters the structure of the SQL query. - Why exploitation is possible: The application embeds
$_POST['id_fiche']directly into a SQL statement without parameter binding or escaping, allowing user input to be interpreted as SQL syntax instead of data.
Why this happens
The root cause is the direct concatenation of user-supplied data into a SQL query string, a classic case of CWE-89: SQL Injection.
Instead of treating id_fiche purely as data using prepared statements or query parameterization, the value is inserted into the query text, letting attackers inject additional SQL fragments.
This insecure pattern arises when application logic builds SQL dynamically in PHP without using database APIs that separate query structure from user input.
Potential impact
- Unauthorized reading of database records that the application would not normally expose
- Modification or deletion of application data, including wiki content and associated metadata
- Bypassing of application-level authorization checks enforced in the database layer
- Potential creation of new privileged application accounts or manipulation of existing ones
- In some configurations, possible execution of additional database-level commands that impact availability or integrity
General mitigation guidance
Effective mitigation focuses on eliminating dynamic SQL that mixes user input with query syntax and reducing trust in incoming parameters.
Common defensive patterns include:
- Using prepared statements with bound parameters for all queries, especially those involving request data such as
$_POST['id_fiche']. - Centralizing database access through a data access layer that enforces parameterization by default, rather than allowing raw query construction.
- Applying strict server-side validation and type enforcement for identifiers (e.g., ensuring
id_ficheis treated as an integer or a constrained token). - Limiting database privileges of the application user so that injected queries have minimal impact, following least-privilege principles.
- Designing queries and schemas to avoid exposing unnecessary tables or sensitive fields to the application account.
How teams detect issues like this
Organizations can detect this kind of SQL injection risk using a combination of code-centric and behavior-centric approaches:
- Static analysis: Configure SAST tools or linters to flag string concatenation involving
$_POST,$_GET, and similar superglobals in SQL query construction, especially around the Bazar module. - Code review: Look for raw query building functions (e.g.,
$db->query("...$variable...")) and verify that all user input is passed through prepared statements or parameter binding APIs. - Policy enforcement: Establish coding policies that prohibit ad-hoc SQL construction and require ORM or parameterized query helpers for all database interactions.
- Runtime monitoring: Use web application firewalls or database activity monitoring solutions to detect anomalous SQL patterns and potential injection attempts in production logs.

