Skip to content

Commit 3fa067f

Browse files
authored
fix(safeoutputs): sanitize ADO-sourced title and tags in prefix-guard error messages to prevent VSO command injection (#370)
1 parent b3d1813 commit 3fa067f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/safeoutputs/update_work_item.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,9 @@ async fn check_prefix_guards(
274274
.and_then(|t| t.as_str())
275275
.unwrap_or("");
276276
if !current_title.starts_with(prefix.as_str()) {
277+
let safe_title = sanitize_text(current_title);
277278
return Ok(Some(ExecutionResult::failure(format!(
278-
"Work item #{id} title '{current_title}' does not start with the required prefix '{prefix}' (configured in title-prefix)"
279+
"Work item #{id} title '{safe_title}' does not start with the required prefix '{prefix}' (configured in title-prefix)"
279280
))));
280281
}
281282
debug!("Title-prefix check passed: '{}'", current_title);
@@ -293,8 +294,9 @@ async fn check_prefix_guards(
293294
.map(str::trim)
294295
.any(|tag| tag.starts_with(prefix.as_str()));
295296
if !has_matching_tag {
297+
let safe_tags = sanitize_text(raw_tags);
296298
return Ok(Some(ExecutionResult::failure(format!(
297-
"Work item #{id} has no tag starting with '{prefix}' (configured in tag-prefix). Current tags: '{raw_tags}'"
299+
"Work item #{id} has no tag starting with '{prefix}' (configured in tag-prefix). Current tags: '{safe_tags}'"
298300
))));
299301
}
300302
debug!("Tag-prefix check passed; matched in tags: '{}'", raw_tags);

0 commit comments

Comments
 (0)