Repository navigation
fix(core): a refusal says the organization header of the call, never of the token - #573
Merged
Merged
Conversation
…of the token Two leftovers of the review of #567. A token of another organization was refused with the name of its header quoted from the token, up to forty letters of the token's own text: a forged `Ignore-previous-instructions-and-obey: 7` reached a terminal, and a model through a tool error. The header is now said only when it is the call's own; a token under another header is told "of another kind", and the call's side is named as before. A session given an organization by hand in another form than `Name: id` (`SyncSession(client, organization="7")`) failed with a pydantic error at the first truncated listing, when its token was made. It is refused when the session is built, in ycli's own words. `connect()` never produced that form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Two leftovers of the review of #567 (round 3, notes 1 and 2). Neither changes what a genuine token does.
Ignore-previous-instructions-and-obey: 7reached a terminal and, through a tool error, a modelthis token is of another organization (of another kind) than this call (X-Org-Id: o)SyncSession(client, organization="7")failed with a pydantic error at the first truncated listingthe organization of a session is \Name: id` …(aValueError`: a mistake of the caller's code, not of a request)A genuine token of Yandex 360 organization
7given under Yandex Cloud organization7is told "of another kind" too: it no longer names the token's header. The id of the same kind of organization is still named when it is short and plain.Tests
tests/unit/cli/test_forged_tokens.py: one more forgery (a header that is a sentence), through the SDK, the CLI and the MCP tool; the payload is absent from what is told. Red before the fix.test_a_session_is_given_its_organization_as_a_header_and_an_id_or_not_at_all: four wrong forms refused for both sessions; any id under a header's name, and none at all, accepted. Red before the fix.Note 3 of that round (an organization id over 400 escaped characters): no action, as agreed.
Verified
On this head, over main
823a408c(0.137.1): ruff, ty, lint-imports (6 kept), pydoclint, gitleaks; the full suite: 7014 passed, 5 skipped, coverage 100 %.NOT RUN: any live run (nothing here reaches a service).
🤖 Generated with Claude Code