Skip to content

Commit fe386b2

Browse files
committed
fix(github): sanitize issue comment and sub-issue bodies on read paths
Issue and PR title/body responses are passed through sanitize.Sanitize (invisible-glyph, BiDi, HTML-tag and code-fence-metadata stripping), but the two remaining body-bearing read paths were not: - convertToMinimalIssueComment returned comment bodies verbatim, so every comment read delivered raw attacker-controlled content. - GetSubIssues marshalled sub-issues (title+body) verbatim. A hostile comment could therefore carry hidden prompt-injection content (invisible Unicode tag block, BiDi overrides) straight into the model context, bypassing the control applied on every sibling path. Apply the same sanitize.Sanitize call in both places.
1 parent e7f7bb8 commit fe386b2

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

pkg/github/issues.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,15 @@ func GetSubIssues(ctx context.Context, client *github.Client, deps ToolDependenc
946946
subIssues = filteredSubIssues
947947
}
948948

949+
for _, subIssue := range subIssues {
950+
if subIssue.Title != nil {
951+
subIssue.Title = github.Ptr(sanitize.Sanitize(*subIssue.Title))
952+
}
953+
if subIssue.Body != nil {
954+
subIssue.Body = github.Ptr(sanitize.Sanitize(*subIssue.Body))
955+
}
956+
}
957+
949958
r, err := json.Marshal(subIssues)
950959
if err != nil {
951960
return nil, fmt.Errorf("failed to marshal response: %w", err)

pkg/github/minimal_types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,10 @@ func convertToMinimalIssuesResponse(fragment IssueQueryFragment) MinimalIssuesRe
820820

821821
func convertToMinimalIssueComment(comment *github.IssueComment) MinimalIssueComment {
822822
m := MinimalIssueComment{
823-
ID: comment.GetID(),
824-
Body: comment.GetBody(),
823+
ID: comment.GetID(),
824+
// Bodies carry the same invisible-glyph / HTML injection surface as
825+
// issue and PR bodies, which the read paths already sanitize.
826+
Body: sanitize.Sanitize(comment.GetBody()),
825827
HTMLURL: comment.GetHTMLURL(),
826828
User: convertToMinimalUser(comment.GetUser()),
827829
AuthorAssociation: comment.GetAuthorAssociation(),

0 commit comments

Comments
 (0)