Skip to content

fix(tools): stop a publication ID from simap from sending requests outside /api - #160

Merged
mathieumaf merged 1 commit into
mainfrom
security/simap-id-path
Dec 3, 2026
Merged

mathieumaf merged 1 commit into
mainfrom
security/simap-id-path

Conversation

@mathieumaf

@mathieumaf mathieumaf commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

When get_tender_details is called without publicationId, it reads the latest publication's ID from simap's project header and puts it into the next request path without checking it. The URL parser then resolves dot segments, so an ID such as ../../../../../../auth/whoami sends the request to https://www.simap.ch/auth/whoami, outside /api. fullRaw returns what that path answers. This breaks invariant 2 of SECURITY.md. Only simap can set that ID, so the severity is Low. The threat model already listed it as a known limit.

The fix:

  • the handler applies the same UUID check to that ID as to the publicationId argument, and returns an isError result without requesting anything;
  • buildUrl() refuses an endpoint that the URL parser would rewrite (dot segments, ?, #, a missing leading /), so the rule holds for every endpoint.
  // get-tender-details.ts, publicationId omitted
  latestId = header.latestPublication.id
+ if (!publicationIdSchema.safeParse(latestId).success) return toolErrorResult(...)
  details = await fetchDetails(latestId)

  // client.ts buildUrl()
  url.pathname = base + endpoint
+ if (!endpoint.startsWith("/") || url.pathname !== base + endpoint) throw ...

SECURITY.md (invariant 6), the threat model (the known limit is removed) and ARCHITECTURE.md are updated. This finding comes from a local security review. #161 fixes the other one.

Related issue

None, found by a security review.

Type of change

  • Bug fix

Evidence

Proof of concept with fetch stubbed, so nothing reaches the network. simap's project header returns a hostile latestPublication.id:

# main
simap id "../../../../../../auth/whoami"
  -> request: https://www.simap.ch/auth/whoami
  -> tool isError=false; raw block returned: true
simap id "x/../../../../../../../../robots.txt"
  -> request: https://www.simap.ch/robots.txt
  -> tool isError=false; raw block returned: true

# this branch: all 6 hostile IDs
  -> last request: .../project/<uuid>/project-header   (nothing after it)
  -> tool isError=true; raw block returned: false

The same proof sends 12 hostile values through 18 tool arguments, and 0 requests leave https://www.simap.ch/api/, both before and after the fix.

Tests: 5 hostile IDs in tests/tools/get-tender-details.test.ts, 10 cases for buildUrl() in tests/api/client.test.ts. They fail on main and pass here. All five checks of AGENTS.md pass: 444 tests on this branch, 455 merged with #161.

Live call with the default path (no publicationId), against the real simap API:

SIMAP_MCP_DEBUG=1 npx fastmcp call --file dist/server.js:createServer get_tender_details projectId=46e8fe6a-579c-4e84-833b-c6be2020cbe7
GET .../project/46e8fe6a-.../project-header
GET .../project/46e8fe6a-.../publication-details/b699a0ce-5f1b-4c94-85fa-7c8957ef2907
# Tender Details ... (rendered as before)

The fix assumes that simap's publication IDs are always UUIDs. In a live search_tenders (20 results), all 20 publication IDs were UUIDs.

Risk

Tier: High, because it touches src/api/client.ts (the only outbound path) and SECURITY.md / docs/security/threat-model.md.
Blast radius: if simap ever returns a publication ID that is not a UUID, get_tender_details without publicationId fails for that project with a clear error. Passing publicationId still works. buildUrl() only refuses endpoints whose path the parser would change, and none of the endpoints in ENDPOINTS do that.
Revert: git revert. The fix is a patch changeset and adds no new parameter.

Checklist

  • Added or updated tests
  • Added a changeset if the change is user-visible (npx changeset)
  • Updated documentation if needed

Created with Claude Mythos 5.2 in a sandboxed Claude Code session. Verified, re-signed and filed with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

…ng it

get_tender_details, called without publicationId, took the ID of the
latest publication from simap's project header and put it into the
request path. The header schema only checks that it is a string, and the
URL parser resolves dot segments, so an ID such as
"../../../../../../auth/whoami" sent the request to
https://www.simap.ch/auth/whoami: any path of www.simap.ch, outside
/api. The answer is parsed with a schema whose fields are all optional,
so with fullRaw the tool returned whatever JSON object that path served.

The host could not change, and only simap can set this ID, so this is
defence in depth: the threat model listed it as a known limit.

- The handler holds the ID from the header to the UUID check the
  publicationId argument already has, and returns an isError result
  without requesting anything.
- buildUrl() refuses an endpoint the URL parser would rewrite (dot
  segments, "?", "#", a missing leading slash), so the rule holds for
  every endpoint, not only this caller. The message carries the endpoint
  and never the query values.

SECURITY.md and the threat model no longer list the limit.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Dec 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d9b09c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@digilac/simap-mcp Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T07:25:15.666193Z d9b09c8 PR opened
🔒 Security Review ✅ Completed 2026-12-03T07:26:47.630545Z d9b09c8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mathieumaf
mathieumaf merged commit dc381e1 into main Dec 3, 2026
6 checks passed
@mathieumaf
mathieumaf deleted the security/simap-id-path branch December 3, 2026 07:27
@github-actions github-actions Bot mentioned this pull request Dec 3, 2026
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