Skip to content

Fix false prompt-injection alarm on PR Tooling Safety Check bypass labels - #20130

Merged
T-Gro merged 10 commits into
mainfrom
t-gro-fix-tooling-check-false-injection
Aug 6, 2026
Merged

Fix false prompt-injection alarm on PR Tooling Safety Check bypass labels#20130
T-Gro merged 10 commits into
mainfrom
t-gro-fix-tooling-check-false-injection

Conversation

@T-Gro

@T-Gro T-Gro commented Aug 3, 2026

Copy link
Copy Markdown
Member

The PR Tooling Safety Check runs a separate threat-detection LLM that only sees the workflow description plus the agent's output, not the process steps. When the agent correctly applies AI-Tooling-Check-Bypassed to a non-fork PR, the detector misreads the bypass label as the agent being manipulated into skipping its scan and raises a false prompt-injection alarm, aborting the run's label and memory outputs.

threat-detection.prompt now tells the detector that bypass-labeling non-fork PRs is the designed path defined in tooling-check-repo-rules.md, not an injection.

…bels

The threat-detection job is a separate LLM that only sees the workflow
description plus the agent's output, not the process steps. When the agent
correctly applies AI-Tooling-Check-Bypassed to a non-fork PR, the detector
misreads the bypass label as the agent being manipulated into skipping its
scan and raises a false prompt-injection alarm, aborting the run's label and
memory outputs. Give the detector context via threat-detection.prompt.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@T-Gro
T-Gro requested a review from a team as a code owner August 3, 2026 19:35
@github-actions github-actions Bot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label Aug 3, 2026
Copilot and others added 6 commits August 4, 2026 10:43
pull_request_target grants a read-only GITHUB_TOKEN whenever the pull
request modifies files under .github/workflows/ (a GitHub security
restriction). The release-notes summary comment then fails with HTTP 403
and fails the whole check, even though the release-notes gate itself
passed. Wrap the comment write in a try/catch that skips on 403 with a
notice, so posting the comment stays best-effort and workflow-modifying
PRs are no longer blocked by this check.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The release-notes comment failure is a non-required check that fails for
every PR modifying files under .github/workflows/: pull_request_target
grants a read-only GITHUB_TOKEN in that case, so the comment write returns
403. This cannot be fixed from a PR branch because pull_request_target runs
the base-branch (main) workflow, and it is already addressed by the
dedicated PR #20136. Keep this PR focused on the labelops threat-detection
fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…t 403

Rewriting the release-notes check in #20081 reduced the token to pull-requests: read, but posting a NEW PR comment (issues.createComment POST) requires pull-requests: write. Brand-new PRs with no existing bot comment (like #20130 and dependency PRs) therefore fail with 403 'Resource not accessible by integration', while PRs with a pre-existing comment pass via the updateComment PATCH path (allowed by issues: write).

Restore pull-requests: write (the fork-head checkout removed in #20081 stays removed, so no untrusted code runs and the comment body is passed via env var) and wrap the comment write in try/catch so the best-effort informational comment can never fail the release-notes gate. Supersedes the abandoned PR #20136.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro

T-Gro commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Note on the red check_release_notes here: this is expected and cannot go green from this PR branch.

check_release_notes runs via pull_request_target, which always executes the workflow definition from the base branch (main), not this PR's head. main's version still has pull-requests: read and posts the summary comment with an un-wrapped createComment, so brand-new PRs (no pre-existing bot comment) fail the POST with 403 Resource not accessible by integration (the gate itself passes — "No release notes required"). The failure log confirms the old, un-wrapped code path is what ran.

This branch already contains the fix (restore pull-requests: write + wrap the comment step in try/catch so it's best-effort), superseding the self-closed #20136. It will only take effect — and this check will only turn green for such PRs — once merged to main.

check_release_notes is not a required check (required: fsharp-ci, license/cla), so it does not block merge.

…ck-false-injection

# Conflicts:
#	.github/workflows/check_release_notes.yml
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

✅ No release notes required

@T-Gro T-Gro left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This review was generated by AI (@expert-reviewer agent). Findings may contain inaccuracies — please verify independently.

Reviewed the threat-detection hint change and its compiled .lock.yml. The generated lock file is consistent with the .md source (description + CUSTOM_PROMPT env match, frontmatter_hash regenerated), and CUSTOM_PROMPT is consumed by the standard setup_threat_detection.cjs step. One security-relevant scoping concern noted inline.

Comment thread .github/workflows/labelops-pr-security-scan.md Outdated
@T-Gro T-Gro added the AI-reviewed PR reviewed by AI review council label Aug 5, 2026
Copilot and others added 2 commits August 5, 2026 10:20
Address review feedback: the detector hint previously told the threat detector that applying AI-Tooling-Check-Bypassed to any PR is benign. Bypass-labeling is only the designed path for non-fork PRs; a fork PR carrying a bypass label instead of a diff scan is exactly the injection outcome this detector should catch. Scope the reassurance to the non-fork bypass / fork scanned-clean path and explicitly flag a bypass label on a fork PR as a deviation worth flagging.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro
T-Gro requested a review from abonie August 6, 2026 12:51
@T-Gro
T-Gro enabled auto-merge (squash) August 6, 2026 12:52
@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling Aug 6, 2026
@T-Gro
T-Gro merged commit 2c245dd into main Aug 6, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in F# Compiler and Tooling Aug 6, 2026
bartelink pushed a commit to bartelink/fsharp that referenced this pull request Aug 6, 2026
…bels (dotnet#20130)

* Fix false prompt-injection alarm on PR Tooling Safety Check bypass labels

The threat-detection job is a separate LLM that only sees the workflow
description plus the agent's output, not the process steps. When the agent
correctly applies AI-Tooling-Check-Bypassed to a non-fork PR, the detector
misreads the bypass label as the agent being manipulated into skipping its
scan and raises a false prompt-injection alarm, aborting the run's label and
memory outputs. Give the detector context via threat-detection.prompt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-reviewed PR reviewed by AI review council AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants