Summary
A path traversal issue in pygeoapi's STAC FileSystemProvider plugin allows crafted collection requests to traverse directories using raw string path concatenation.
When pygeoapi is deployed without a front-end that normalizes .. segments, unauthenticated clients may be able to access directories and files outside the intended STAC collection paths.
Affected context
This vulnerability appears in pygeoapi deployments that:
- Use a resource of type
stac-collectionbacked by the FileSystemProvider plugin - Rely on raw filesystem paths derived from HTTP request paths
- Are deployed directly (e.g., via a built-in server or minimal reverse proxy) without URL normalization that strips or resolves
..path segments
In such setups, the STAC collection endpoint can inadvertently expose directory listings or file content beyond the intended STAC collection root.
Exploit preconditions
- Attack surface: HTTP(S) interface of pygeoapi, specifically STAC collection endpoints using the FileSystemProvider.
- Required access: Network access to the affected pygeoapi instance; no authentication is needed if the STAC collection endpoint is publicly exposed.
- Trigger point: An HTTP request to a STAC collection URL that includes crafted relative path components such as
../in the path. - Why exploitation is possible: The plugin concatenates user-controlled URL path segments directly to a filesystem base path without normalizing or validating against a fixed root, allowing traversal outside the intended directory.
Why this happens
The underlying flaw is improper validation and sanitization of path components derived from user-controlled URLs.
Instead of resolving and enforcing paths against a fixed, canonical root directory, the STAC FileSystemProvider performs raw string concatenation when mapping request paths to the filesystem.
This behavior corresponds to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where relative path elements like .. are not rejected or normalized, enabling an attacker to traverse up the directory tree and access unintended locations.
Potential impact
- Exposure of directory structures that may reveal file names, layouts, or internal organization
- Read access to configuration files, metadata, or other non-public assets located near or above the STAC collection root
- Leakage of sensitive information that could aid further attacks (e.g., credentials stored in files, internal endpoints, or system paths)
- Violation of data segregation between collections or tenants if multiple datasets share the same filesystem
General mitigation guidance
Effective mitigation focuses on constraining filesystem access and normalizing paths before use:
- Canonicalize and validate request-derived paths against a fixed STAC root directory, rejecting any path that escapes the configured base.
- Avoid raw string concatenation of user-controlled segments; instead, use path-joining utilities that operate on canonicalized components and enforce that the resulting path remains within the allowed root.
- Apply strict configuration of which directories are exposed via the STAC FileSystemProvider, limiting file types and subdirectories where possible.
- Place pygeoapi behind a capable reverse proxy or web server that normalizes and rejects URLs containing
..or other potentially dangerous path patterns. - Run the pygeoapi process with least-privilege filesystem permissions so that even if traversal occurs, access to sensitive system files is constrained.
How teams detect issues like this
Organizations can identify and monitor for this class of issue using a mix of code- and runtime-based techniques:
- Static analysis and code review:
- Flag any use of raw string concatenation to build filesystem paths from HTTP route parameters or query values.
- Check that all path-manipulation logic canonicalizes inputs and enforces containment within a configured root directory.
- Review plugin implementations (such as FileSystemProvider) for direct use of untrusted path components.
- Configuration and policy checks:
- Validate that reverse proxies or web servers are configured to normalize URLs and reject suspicious path patterns, including
.., encoded traversals, or repeated slashes. - Enforce policies that disallow exposing backend filesystem roots directly via HTTP.
- Runtime monitoring and logging:
- Log requests containing
..or encoded equivalents in STAC collection paths and alert on unusual access patterns. - Use web application firewalls (WAF) or API gateways with rules that detect and block path traversal signatures.
- Automated tooling:
- Incorporate security scanners or SAST tools that specifically check for CWE-22 patterns in Python web applications.

