Update documentation to emphasize sanitized context text usage for security #917
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.
This PR addresses the need to better document the security benefits of using sanitized context text (
needs.task.outputs.text) instead of rawgithub.contextvalues in agentic workflows.Problem
The existing documentation showed examples mixing raw
github.eventfields with sanitized context text, but didn't emphasize the critical security differences. Users could inadvertently use insecure patterns like:# INSECURE: Raw user input vulnerable to injection Title: "${{ github.event.issue.title }}" Body: "${{ github.event.issue.body }}"This exposes workflows to prompt injection, unintended @mentions, bot trigger execution, and other security risks from untrusted user content.
Solution
Updated documentation across four key files to guide users toward the secure sanitized approach:
# SECURE: Use sanitized context text Analyze this content: "${{ needs.task.outputs.text }}"Security Benefits Highlighted
The
needs.task.outputs.textprovides critical protections that raw context values lack:@userto`@user`to prevent unintended notificationsfixes #123to`fixes #123`to prevent accidental commandsChanges Made
pkg/cli/templates/instructions.md: Added comprehensive sanitized context section with security benefits and usage patternsdocs/reference/command-triggers.md: Enhanced context text documentation with security comparisonsdocs/reference/markdown.md: Updated examples to show secure patterns first with security rationaledocs/guides/security.md: Added critical security guidance section emphasizing sanitized context usageThe documentation now clearly distinguishes between secure sanitized content access and potentially dangerous raw context field usage, helping users make informed security decisions.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.contoso.com/tmp/go-build4012539661/b281/cli.test -test.testlogfile=/tmp/go-build4012539661/b281/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true(dns block)/tmp/go-build1890621262/b281/cli.test -test.testlogfile=/tmp/go-build1890621262/b281/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true(dns block)/tmp/go-build3783155744/b281/cli.test -test.testlogfile=/tmp/go-build3783155744/b281/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.