Repository navigation
fix(jawn): close cross-tenant IDOR in prompt version forking - #5825
Closed
lokeshramchand-ctrl wants to merge 2 commits into
Closed
lokeshramchand-ctrl wants to merge 2 commits into
lokeshramchand-ctrl wants to merge 2 commits into
Conversation
createNewPromptVersion resolved the parent version via
`SELECT * FROM prompts_versions WHERE id = $1` with no organization
filter, and used the same unscoped predicate for the optional
major-version bump lookup. The controller (promptController.ts,
POST /v1/prompt/version/{promptVersionId}/subversion[-from-ui]) passes
promptVersionId straight from the URL path with no ownership check, so
any authenticated caller could name another organization's
prompts_versions id.
The forged row is inserted with organization = the caller's own org,
but prompt_v2 = the victim's real prompt_v2 id (copied from
ppv.prompt_v2). Every read path that serves compiled/production prompt
content authorizes via prompt_v2.organization, not
prompts_versions.organization:
getCompiledPromptVersions (POST /v1/prompt/{name}/compile) and
getPormptVersionsTemplates both join
`prompt_v2 on prompt_v2.id = prompts_versions.prompt_v2` and filter
`WHERE prompt_v2.organization = $1`, with no check on
prompts_versions.organization at all.
So the forged row is indistinguishable from a legitimate version of
the victim's prompt once it is marked production. And
promotePromptVersionToProduction only checks
`prompts_versions.organization = caller`, which the attacker satisfies
trivially since they own the row they just inserted. Net effect: an
attacker who obtains any org's prompt version id can fork it with an
arbitrary attacker-controlled template, promote their own fork to
production, and have it served back to the victim org as their live
production prompt on their next /compile call - a cross-tenant write
into another tenant's LLM request path, not just a read.
Scope both CTEs to organization = $4 (the caller's own org), matching
the pattern already used by every sibling method in this file
(editPromptVersionTemplate, promotePromptVersionToProduction,
editPromptVersionLabel, etc). Also stop mapping an empty RETURNING set
through resultMap, which silently produced {data: undefined, error:
null} - return an explicit error instead so a blocked fork attempt is
unambiguous.
No behavior change for legitimate same-org forks.
Fixes Helicone#5824
Contributor
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Author
|
@chitalian Flagging for priority review — #5825 fixes a cross-tenant write into another org's production prompt (same bug class as CIRT-77/81/82), reported in #5824. Would appreciate a quick look given the severity. |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Bugbot is paused — your team has an unpaid invoiceBugbot is paused because your team has an unpaid invoice. Pay it from the billing page in the Cursor dashboard and Bugbot resumes automatically. (requestId: f60d6fde-90ec-448b-8d35-091263cf78e3) |
Author
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5824
Summary
PromptManager.createNewPromptVersion(used byPOST /v1/prompt/version/{promptVersionId}/subversionand.../subversion-from-ui) forks a prompt version by id with no organization filter:promptVersionIdcomes directly from the URL path (promptController.ts), and nothing upstream checks that it belongs to the caller's org.Impact
The new row is inserted with
organization = <caller's own org>butprompt_v2 = <victim's real prompt id>(copied straight from the unscoped parent). Every read path that serves production prompt content authorizes onprompt_v2.organization, never onprompts_versions.organization:getCompiledPromptVersions— backsPOST /v1/prompt/{name}/compile, the endpoint customers call at request time to fetch their production prompt template.getPormptVersionsTemplates— same pattern, backs.../template.Both do:
Since
prompt_v2.organizationis the victim's org (the real owner of the prompt), a forged row with the victim'sprompt_v2id passes this check regardless of who's inprompts_versions.organization.Combined with
promotePromptVersionToProduction, which only checksprompts_versions.organization = caller(trivially true — the attacker owns the row they just inserted), the full chain is:prompts_versionsid belonging to another org (e.g. leaked via logs, a shared link, support thread).POST /v1/prompt/version/{victimVersionId}/subversionwith an arbitrarynewHeliconeTemplate. This inserts a version owned by the attacker's org but linked to the victim'sprompt_v2.POST /v1/prompt/version/{forgedId}/promote. Passes, because the forged row'sorganizationis the attacker's own./v1/prompt/{name}/compile(which they'd make to fetch their production prompt for a real LLM request) can return the attacker's forged template instead of their own, since the query never checks who authored the version row — only that it points at the victim'sprompt_v2and is flagged production.This is a cross-tenant write into another tenant's live prompt template — not just a data-exposure read — with follow-on impact on whatever the victim's production LLM traffic does with that prompt.
Fix
Scope both the parent-version and bump-version CTEs to
organization = $4(the caller's own org, already a bound parameter in this query), matching every other method inPromptManager.ts. An out-of-orgpromptVersionIdnow resolves to zero rows, the INSERT inserts nothing, and the manager returns an explicit error instead of silently mappingundefinedthroughresultMap.Testing
prompts_versions.organizationvsprompt_v2.organizationinPromptManager.tsto confirm this is the only method with the gap.Result<PromptVersionResult, string>return type and mirrors theok/errpattern already used elsewhere in this file.yarn test:jawn/tsc --noEmitworkspace build in my environment; would appreciate CI running the full suite on this PR.