Mask and sanitize debugger welcome message before DAP console output - #4577
Merged
Conversation
The server-supplied DebuggerWelcomeMessage was written straight to the DAP console with no secret masking and no control-character stripping. Route it through the runner's SecretMasker and strip C0/C1 control characters (keeping tab, CR and LF) so it can't leak secrets or inject terminal escape sequences. Also document that the field is service-populated only, and that the runner treats it as untrusted regardless. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1d5fcea8-f377-47aa-9013-98d64b2655a8
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1d5fcea8-f377-47aa-9013-98d64b2655a8
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the DAP debugger welcome message path by ensuring server-supplied welcome text is treated as untrusted before being written to the DAP console, addressing secret leakage and terminal control-character injection concerns.
Changes:
- Masks custom debugger welcome messages with the runner
SecretMaskerprior to console output. - Adds
SanitizeConsoleTextto strip C0/C1 control characters (preserving\t,\r,\n) and applies it to the welcome message. - Adds L0 tests covering secret masking and control-character stripping behavior.
Show a summary per file
| File | Description |
|---|---|
| src/Runner.Worker/Dap/DapDebugger.cs | Applies masking/sanitization to the custom welcome message and adds SanitizeConsoleText. |
| src/Test/L0/Worker/DapDebuggerL0.cs | Adds end-to-end and unit tests validating masking and sanitization behavior. |
| src/Runner.Worker/Dap/DebuggerConfig.cs | Documents that the welcome message is treated as untrusted and sanitized/masked before console output. |
| src/Sdk/DTPipelines/Pipelines/AgentJobRequestMessage.cs | Updates doc comment to remove “shown as-is” wording now that the runner sanitizes/masks. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Low
salmanmkc
approved these changes
Jul 28, 2026
rentziass
enabled auto-merge (squash)
July 28, 2026 11:26
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.
DapDebugger.SendWelcomeMessagewrote the server-suppliedDebuggerWelcomeMessagestraight to the DAP console with no secret masking and no control-character handling. The field is service-populated today and not tenant-reachable, but nothing in the runner enforced that, so a value containing a secret or an ANSI escape sequence would have reached the debug console verbatim.Approach
The custom welcome message now goes through the same treatment as every other user-visible string in the debugger:
MaskUserVisibleText(the existingSecretMaskerwrapper already used for step names, source content, and eval results).SanitizeConsoleTexthelper that strips C0/C1 control characters while preserving\t,\r, and\nso multi-line messages still render.Note that stripping the ESC byte leaves the remaining literal text of an escape sequence behind, e.g.
\u001b[31mbecomes[31m. That is intentional: the goal is to neutralize terminal control, not to guess at and delete surrounding printable text.The default help text path is unchanged, since that string is compiled into the runner.
Tests
WelcomeMessageMasksSecretsandWelcomeMessageStripsControlCharactersdrive a real DAP session end to end and assert on the emittedoutputevent.SanitizeConsoleTextcovering null, empty, plain text, preserved whitespace, ESC, BEL/NUL/DEL, and C1 characters.46/46
DapDebuggerL0tests pass. The full suite passes apart from the pre-existingProcessExtensionL0.SuccessReadProcessEnvfailure, which needs_layout/externals/node20present locally and is unrelated to this change.Notes for reviewers
actions_runner_override_debugger_welcome_messageflag already gates this entire code path, and adding a switch to turn masking back off would defeat the purpose../dev.sh formatis currently broken on macOS in my environment (dotnet-format cannot locate its net472 build host), so formatting was matched by hand against surrounding code.