Skip to content

Add failing tests for content path traversal - #11

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/content-path-traversal-tests-f6f8
Draft

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/content-path-traversal-tests-f6f8

Conversation

@cursor

@cursor cursor Bot commented Nov 20, 2026

Copy link
Copy Markdown

Summary

These tests pin down a path traversal in the content client. get, list, create, update, and delete join the endpoint name and the content id into the request path as raw text. Guzzle then resolves parent-directory segments against https://{service}.microcms.io/api/v1/, so an id such as ../inquiries is sent as a request for a different content API, still carrying the X-MICROCMS-API-KEY header.

The tests fail on purpose until that input is rejected. A fix should throw InvalidArgumentException before the HTTP handler runs for any endpoint name or content id that is not a single safe path segment. No production code is changed here.

testOrdinaryContentIdIsStillRequested passes today and should keep passing.

How to run

composer install --prefer-dist --no-progress
vendor/bin/phpunit tests/ContentPathTraversalTest.php

On the current code this exits non-zero: 44 tests fail because a request is sent to the resolved URL of another API. vendor/bin/phpunit tests/ClientTest.php still passes.

Open in Web Open in Cursor 

Content ids and endpoint names are joined into the request path without being confined to one segment, so parent-directory values are resolved onto other APIs. These tests expect that input to be rejected before any request is sent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant