Summary
An unauthenticated SQL injection in Metacat's /harvesterRegistration endpoint lets attackers inject arbitrary SQL into INSERT statements targeting the HARVEST_SITE_SCHEDULE table.
Because the PostgreSQL backend permits stacked queries and the servlet skips real LDAP identity verification, a remote attacker can gain full read/write/execute capabilities within the Metacat database context.
Affected context
The vulnerability occurs in Metacat's harvester registration functionality, specifically when handling requests to the /harvesterRegistration endpoint.
It affects deployments where the application accepts unauthenticated or weakly verified registration requests and forwards three parameters (unit, contactEmail, and documentListURL) into a dynamically constructed SQL INSERT against HARVEST_SITE_SCHEDULE.
Any environment where these parameters can be influenced by untrusted users, combined with a PostgreSQL backend that allows stacked queries, is at risk of database-level compromise.
Exploit preconditions
- Attack surface: HTTP(S) access to the
/harvesterRegistrationendpoint. - Required access: No valid application account is required; the servlet does not enforce a real LDAP-backed identity for this operation.
- Trigger point: Submission of crafted values in
unit,contactEmail, ordocumentListURLthat are concatenated into an SQL INSERT statement. - Why exploitation is possible:
HarvesterRegistration.dbInsert()builds SQL via string concatenation and relies on aquoteString()helper that only wraps inputs in single quotes without escaping or parameter binding, while PostgreSQL allows stacked queries viaStatement.executeUpdate().
Why this happens
This issue is rooted in constructing SQL statements by concatenating raw user input, rather than using parameterized queries or proper escaping.
The quoteString() helper exemplifies an insecure pattern: it merely surrounds untrusted data with single quotes, assuming that is sufficient to make it safe, but does not escape embedded quotes or other control characters.
As a result, attacker-controlled input is interpreted as part of the SQL syntax, enabling injection of arbitrary commands, including stacked statements in PostgreSQL.
The lack of effective authentication or identity verification on the servlet side (related to CWE-287) widens exposure by allowing unauthenticated users to reach this dangerous code path.
Potential impact
- Attackers may read sensitive data stored in any tables accessible to the Metacat database user.
- Attackers may modify or delete records, corrupting research metadata and repository state.
- Attackers may create new accounts, alter access control information, or tamper with harvester schedules.
- Attackers could execute stacked SQL commands that enable further database-level code execution features exposed by PostgreSQL.
- Attackers can use the compromised database as a pivot to impact data integrity and availability of the wider Metacat deployment.
General mitigation guidance
Effective mitigation centers on eliminating direct string concatenation in SQL construction and narrowing trust boundaries around registration endpoints.
Robust patterns include:
- Replacing ad hoc SQL building with prepared statements or parameterized query APIs for all user-controlled values (
unit,contactEmail,documentListURL, and similar parameters). - Removing or refactoring helpers like
quoteString()that perform manual quoting instead of using the database driver's parameter binding. - Introducing strict server-side validation and canonicalization for all input fields, rejecting unexpected formats before interacting with the database.
- Enforcing strong authentication and identity verification for registration and configuration endpoints to prevent unauthenticated access.
- Applying least-privilege to the Metacat database user so it has only the minimal rights needed and cannot perform dangerous operations outside its intended scope.
How teams detect issues like this
Detection commonly involves a mix of static inspection and runtime monitoring:
- Static analysis rules that flag any SQL built via string concatenation, especially where request parameters or other untrusted data flow into
Statement.executeUpdate()or similar APIs. - Code review checklists that require verification of parameterized queries and prohibit custom quoting helpers like
quoteString(). - Automated scanning of repository history and new pull requests for known unsafe patterns (e.g.,
"INSERT INTO" +with direct variable concatenation). - Web application firewalls or database activity monitoring tuned to detect atypical SQL patterns such as stacked queries or anomalous INSERT/DELETE/ALTER sequences from application accounts.
- Logging and alerting on failed or unusual database operations originating from the harvester registration path, enabling early detection of probing or exploitation attempts.

