fix: rule bodies cannot forge domain headings in the rendered block - #535
Merged
Conversation
renderDomain emitted rule bodies verbatim under the trusted '## NAME' heading, so a hostile rules.json rule could start a line with '#' to forge a domain heading, or smuggle control characters and ANSI escapes into the injected context block. sanitizeRuleBody strips control characters (keeping newline and tab) and indents any '#'-leading line one space, so the rendered '## NAME' lines stay the only headings — the injection contract host-side parsers rely on. Ported from the tested fix developed in the adaptor-lab checkout (2026-08-24/26 red-team rounds); the only change in transit is the post-org-rename module path on the termsafe import. Test written first and watched fail against the unpatched tree. Assisted-by: Claude:claude-fable-5
Resolves: iss-2608261550394120 Assisted-by: Claude:claude-fable-5
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.
sanitizeRuleBody strips control characters (keeping newline and tab) and space-indents any '#'-leading line at the one rule-body render site, so a hostile rules.json cannot forge '## DOMAIN' headings or smuggle ANSI/control sequences into the injected context block — the rendered headings stay the injection contract host-side parsers rely on. Test written first and watched fail against the unpatched tree; the forgery corpus (newline, CRLF, U+2028/2029, ANSI, NUL, hash-at-start) is the regression suite. Ported from the tested adaptor-lab fix; the only change in transit was the post-org-rename module path.
Resolves iss-2608261550394120 in the same diff with fixing-commit provenance (--impact fix).
Assisted-by: Claude:claude-fable-5