Repository navigation
Reject multi-argument and selector answers in delegated prompt sessions - #112
Merged
Merged
Conversation
Answers in sessions started by /consoledelegate or /playerdelegate must be a single argument (no whitespace, no leading @) unless the prompt opts in with the new -allowargs flag. Non-delegated sessions are unchanged.
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
CyR1en
requested changes
Nov 26, 2026
CyR1en
left a comment
Owner
There was a problem hiding this comment.
Requesting changes before merge — there is a selector-check bypass via post-validation sanitization, plus two smaller issues with allowsArgs() and the README documentation:
- Selector bypass via
PromptSession.sanitize:ScreenManager.validateAnswerchecksanswer.startsWith("@")beforePromptSession.submitAnswer/submitAnswersrunsPromptSession.sanitize(enabled by default on tags without-ds). BecausePromptSession.sanitizestrips legacy color codes ([§&][0-9a-fklmnor]) andCOLOR_SYMBOLS([{}[\]<>()$§&\u00A7]+), inputs like&a@a,$@a, or(@a)passvalidateAnswerand then sanitize into literal@abefore console dispatch. allowsArgs()treats"false"as enabled:flags.containsKey(ALLOW_ARGS_FLAG)returnstrueeven for"allowargs": "false"in JSON presets or-allowargs:falseon custom keys, andCommandLineParserstores""instead of"true"for built-in tags (which also causes/cmdp preset saveto persist"").- Wrong JSON path in
README.md:flagsmust be nested underbehavior("behavior": {"flags": {"allowargs": "true"}}), not at the top level of a preset object.
CyR1en
approved these changes
Nov 26, 2026
CyR1en
left a comment
Owner
There was a problem hiding this comment.
LGTM — all three findings are cleanly addressed:
isUnsafeDelegatedAnswernow checks both the raw answer andPromptSession.sanitize(answer)(closing the color-code/symbol bypass) with parameterized regression tests.CommandLineParserstores"true"consistently andPromptTag.allowsArgs()strictly checks"true".equalsIgnoreCase(value.trim()).README.mddocuments the correct"behavior": {"flags": {"allowargs": "true"}}JSON path.
CyR1en
added a commit
that referenced
this pull request
Nov 28, 2026
…-args Reject multi-argument and selector answers in delegated prompt sessions
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.
Summary
Fixes an argument-injection path in sessions started by
/consoledelegateand/playerdelegate. Answers were only stripped of C0 control characters and then joined verbatim into the command template byParsedCommand.buildPartialCommand, so the prompted player could answer@aor1 extraand change a command that runs as console (or with a temporary permission attachment).ScreenManager.validateAnswernow rejects, in delegated sessions only, any answer that contains whitespace (including non-breaking and other Unicode spaces) or starts with@. The player getsvalidation.delegated_single_argumentand the prompt is shown again; nothing is dispatched.Opt-in is a new
-allowargsflag, stored inPromptTag.flags()(PromptTag.allowsArgs()):CommandLineParserstrips it for built-in keys, on both single and compound tags."flags": {"allowargs": "true"}.Things to know when reviewing:
-allowargs, even if it already has a validator. A validator alone does not opt in. This also applies to non-typed answers with spaces, such as dialog choice values./playerdelegateis covered too, not only console mode, because the command runs with granted permissions.startSession, andstartDelegatedSessionwithDispatchMode.NORMAL).Tests:
DelegateCommandsIntegrationTestsubmits@a,1 extra, a non-breaking-space answer and1 @ato delegated prompts and asserts no dispatch plus a re-prompt, then checks the-allowargsopt-in and the unchanged non-delegated path.CustomFlagsParserTestcovers parsing of the flag.:prompt-core:testand:prompt-paper:testpass locally on JDK 25.:prompt-core:spotlessApplyfails locally on files this PR does not touch (google-java-format 1.27.0 cannot parse_identifiers), so theprompt-coreedits were formatted by hand.Link to Devin session: https://app.devin.ai/sessions/f4dab422581e46599539ea68fda71f1c
Open in Devin Desktop: https://app.devin.ai/desktop/session/f4dab422581e46599539ea68fda71f1c?variant=devin
Requested by: @CyR1en
🟢 Devin Review found nothing to fix · View findings · Follow Devin's work