/

CVE-2026-49498

Severity:

HIGH RISK

(8.8)

SQL Injection (CWE-89) in Ghidra Postgres Password Logic

CVE-2026-49498

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Privilege Escalation to Database Superuser and Full DB Compromise

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A SQL injection flaw in Ghidra's PostgresFunctionDatabase changePassword() method allows unescaped usernames to be interpolated into ALTER ROLE statements.

When an authenticated user sends a crafted PasswordChange network message, they may inject arbitrary SQL and potentially escalate to PostgreSQL superuser, gaining full control over the backing database.

Affected context

This vulnerability arises in Ghidra deployments that use the PostgresFunctionDatabase backend and process password changes via the PasswordChange network message.

It specifically affects the code path where ALTER ROLE SQL commands are constructed using the supplied username without correctly escaping double quotes or otherwise safely parameterizing the value.

The issue is relevant when authenticated users can trigger password change functionality and the Ghidra service has sufficient privileges on the PostgreSQL instance to execute role-altering statements.

Exploit preconditions

  • Attack surface: Ghidra server's password change handling path, typically exposed over the internal Ghidra protocol rather than directly via SQL.
  • Required access: Valid, authenticated access to Ghidra that permits sending a PasswordChange network message (e.g., a normal user account).
  • Trigger point: Invocation of PostgresFunctionDatabase.changePassword(), which builds and executes an ALTER ROLE statement containing the attacker-controlled username.
  • Why exploitation is possible: Usernames are interpolated directly into SQL without properly escaping double quotes or using bound parameters, allowing crafted values to break out of the intended string context and append arbitrary SQL statements.

Why this happens

The root cause is the construction of SQL statements using string concatenation with untrusted data, a classic manifestation of CWE-89: Improper Neutralization of Special Elements used in an SQL Command.

In this case, the changePassword() method forms an ALTER ROLE statement that includes the username, assuming simple quoting is sufficient. The implementation fails to correctly handle special characters such as double quotes, leaving the query interpreter exposed to injected syntax.

Conceptually, this is an insecure pattern where identity or configuration fields (like usernames) are treated as safe literals rather than untrusted input that must be passed via parameterized queries or rigorously normalized before use in dynamic SQL.

Potential impact

  • Attackers may escalate their PostgreSQL privileges to superuser level.
  • An attacker could gain full control of the associated Ghidra database, including creating, altering, or dropping schemas, tables, and roles.
  • Stored analysis data and project metadata could be read, modified, or destroyed.
  • Compromised database-level credentials and configuration could be leveraged for further lateral movement in the environment.

General mitigation guidance

Effective mitigation centers on eliminating direct string interpolation of untrusted input into SQL and tightening privilege boundaries around database operations:

  • Replace dynamically concatenated SQL in password change workflows with parameterized queries or well-tested helper APIs that safely quote identifiers and literals.
  • Treat usernames and similar identity attributes as untrusted input even when coming from authenticated clients, applying strict normalization and escaping rules before they can influence SQL syntax.
  • Limit the database role used by Ghidra so it has only the minimum privileges required, avoiding superuser-level accounts for routine application operations.
  • Introduce defensive checks or allowlists on acceptable username formats to reduce the attack surface presented by identifier injection.
  • Apply secure-by-default patterns in database access layers, such as centralizing SQL execution in a small, audited component rather than scattering ad-hoc query construction throughout the codebase.

How teams detect issues like this

Detection typically involves a mix of code-centric analysis and runtime monitoring:

  • Use static analysis or linters to flag string-based SQL construction that embeds user-controlled fields like usernames, especially in authentication and account management code paths.
  • During code review, scrutinize any ALTER ROLE or privilege-changing SQL to ensure it uses parameterization or robust identifier-quoting routines rather than direct concatenation.
  • Implement security-focused tests or fuzzing for username handling and password change endpoints to ensure special characters cannot alter SQL structure.
  • At the database layer, enable logging of SQL statements and monitor for anomalous ALTER ROLE or superuser-related operations, feeding these into alerting systems for investigation.

Sources

SourceLink
github.comgithub.com/NationalSecurityAgency/ghidra/security/advisories/GHSA-vv7r-2rhf-5h7g
vulncheck.comvulncheck.com/advisories/ghidra-sql-injection-in-postgresql-password-change-via-unescaped-username

Frequently asked

questions

Yes, in typical deployments it can be triggered remotely by an authenticated user who can reach the Ghidra server and invoke the password change mechanism, even though the actual SQL is executed on the backend PostgreSQL database.

In general, yes. The vulnerable changePassword() method is invoked via PasswordChange network messages, which are normally available only to authenticated users or components that can act as such.

The robust fix is to remove all direct string interpolation of usernames into SQL and instead use parameterized queries or dedicated APIs that correctly quote identifiers and literals, combined with least-privilege database roles.

Establish a standard data access layer that enforces parameterization by default, prohibit ad-hoc SQL concatenation in coding guidelines, apply automated checks in CI, and regularly review high-risk areas like authentication, authorization, and privilege management for unsafe query construction.

Find out what's already
exploitable in your codebase.