Repository navigation
fix(citry-core): check functions passed to other functions in the sandbox; release citry-core 2.1.2 and citry 1.0.3 - #797
Merged
Conversation
…unction Reading `format` or `format_map` from any string, exact `str` and `UserString` included, is now refused, as it already was for subclasses. A call is also refused when one of its arguments is a function the sandbox would not call itself, because a function such as `list.sort` calls its `key=` argument without the sandbox's call check. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
…uments the check cannot read Django's lazy strings are not `str`, but their `format` follows paths too, so the read check now treats them as strings. An argument whose own attribute lookup raises during the check is refused instead of raising its own error. Prose fixes from the review. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
… arguments A function passed to a call can be called by the function that receives it, so a caller's `validate_callable` hook must see it too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
…cause of a failed check A bound `format` of a Django lazy string is named `__wrapper__`, so the call check now also compares the function with the one on the class. When checking an argument raises, the `SecurityError` keeps that error as its cause. Changelog and docs follow the second review. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
This was referenced Nov 19, 2026
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.
(Opus 5.5)
What changed
The template expression sandbox in citry-core checked the function an expression calls, but not a function passed as an argument to another function that then calls it (such as the
keyoflist.sort). It also allowed reading a string'sformatmethod and refused only a direct call.formatandformat_mapon any string (str,UserString, Django lazy strings) now raisesSecurityError.SecurityErrorwhen one of its arguments is a function the sandbox would not call itself: a method marked@unsafeoralters_data, an unsafe built-in, a string format method, or afunctools.partialof one.validate_callablehook passed tosafe_eval()now also receives every function and class passed as an argument.citry-core==2.1.2, changelogs anduv.lock.The fix is Python only (
citry_core/safe_eval/sandbox.py,eval.py), with 30 regression tests that fail without it.Checks
Run on the fix before this rebase (only the release values commit is new):
cargo test -p python_safe_eval: 344 passed.--platform linux) clean on the touched files.Versioning
A security fix that refuses expressions citry-core 2.1.1 ran, allowed under the security-fix clause; the changelog says what is refused and what to use instead (an f-string). citry 1.0.3 is a patch that raises the exact citry-core pin.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED