/

CVE-2026-54354

Severity:

HIGH RISK

(8.2)

SQL Injection (CWE-89) in MapServer PostGIS Filters

CVE-2026-54354

Awaiting Analysis

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Unauthorized data access and database query manipulation

Severity:

HIGH RISK

(8.2)

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 vulnerability in MapServer's PostGIS filter translation can treat attacker-controlled filter values as numeric without confirming that they are valid numeric literals. An unauthenticated remote attacker with access to an affected CGI or OGC API Features query endpoint may bypass predicates, retrieve unintended records, or influence database query behavior.

Affected context

The issue occurs in MapServer deployments that use the PostGIS connection type and configure item metadata indicating an Integer field. It becomes risky when attacker-controlled CGI query strings or OGC API Features feature identifiers reach the runtime filter translation path and are incorporated into generated PostgreSQL/PostGIS predicates without numeric validation.

Exploit preconditions

  • Attack surface: An exposed MapServer CGI or OGC API Features query endpoint backed by PostGIS
  • Required access: Unauthenticated network access to a vulnerable query interface
  • Trigger point: Processing a filter or featureId value associated with a field configured as an integer
  • Why exploitation is possible: The value is treated as numeric and concatenated into a database predicate without verifying that it is a numeric literal

Why this happens

The underlying bug is insufficient validation of attacker-controlled input before SQL expression generation. When metadata identifies a filter item as an integer, the translation logic assumes the input is safe for unquoted insertion into a PostgreSQL/PostGIS predicate instead of validating its syntax and preserving parameter boundaries. This behavior maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

Potential impact

  • An attacker may bypass intended query predicates
  • Unauthorized records could be enumerated or disclosed
  • Boolean-based or time-based SQL injection may be possible
  • Database resources could be consumed through expensive queries
  • Downstream GIS services may experience degraded availability
  • Database modification is not inherently established by this issue

General mitigation guidance

Mitigation generally focuses on ensuring that external filter values cannot become SQL syntax.

Common defensive patterns include:

  • Using parameterized queries or structured query-builder APIs instead of string concatenation
  • Validating integer fields with strict, canonical numeric parsing before query generation
  • Rejecting values that contain unexpected syntax, delimiters, or trailing content
  • Applying allowlisted field and operator mappings for externally supplied filters
  • Limiting database credentials to the minimum read and schema permissions required
  • Restricting public access to query endpoints and applying suitable request and resource policies
  • Preserving consistent validation across CGI and OGC API Features request paths

How teams detect issues like this

Organizations can look for this class of issue through:

  • Static analysis rules identifying concatenation of request parameters into SQL or PostGIS predicates
  • Code review checks for numeric type assumptions that do not perform strict parsing
  • Tests using malformed, boundary, boolean-like, and time-delay-oriented values against query interfaces
  • Monitoring for unusual predicate patterns, repeated query failures, excessive query duration, or unexpected record volumes
  • Database auditing that correlates application requests with abnormal query structures or resource consumption
  • Policy enforcement requiring parameterized database access and approved input-validation helpers

Automated application security and code review tools may help identify unsafe query construction patterns.

Sources

SourceLink
github.comgithub.com/MapServer/MapServer/commit/65f1b53c258df2abdf6ce1f437c29e75e9976247
github.comgithub.com/MapServer/MapServer/commit/bd59d49779d2ecc64ca8dc1281c53231a50b698e
github.comgithub.com/MapServer/MapServer/pull/7516
github.comgithub.com/MapServer/MapServer/releases/tag/rel-8-6-4
github.comgithub.com/MapServer/MapServer/security/advisories/GHSA-xp29-8wp5-wc3p
mapserver.orgmapserver.org/development/changelog/changelog-8-6.html#changelog-8-6

Frequently asked

questions

It may be remotely exploitable when a MapServer CGI or OGC API Features query endpoint is reachable by an attacker and uses the affected PostGIS filter path.

The described attack does not inherently require authentication. The relevant prerequisite is access to an exposed vulnerable query endpoint; deployment authentication and network controls may reduce the reachable scope.

The safest pattern is to prevent request values from being interpreted as SQL by using parameterized queries or structured query APIs, together with strict type validation for numeric fields.

Treat all query parameters and feature identifiers as untrusted, enforce allowlisted fields and operators, test every request path consistently, and apply least-privilege database permissions with monitoring for anomalous queries.

Find out what's already
exploitable in your codebase.