desk/services/sync.py: Post-Merge PR Title/Body Edits by Untrusted Contributors Force Unfixed Tickets to patched, Bypassing ASSESSMENT_HELD to Leak Held Assessments
Report
In desk/desk/services/sync.py, link_pull() (lines 178-216) and _follow_pull_state() (lines 224-251) allow any merged GitHub Pull Request whose title or body matches gh.closing_refs() (Fixes #N, Closes #N, Resolves #N) to transition the referenced Desk ticket all the way to status = "patched", regardless of trusted = pull_is_maintainers(ctx, pull), based on line 232:
if state == "merged":
target, reason = "patched", f"{ref} merged" # a merge is a maintainer's act whoever wrote the PR
However, on GitHub, any external contributor (author_association == "CONTRIBUTOR", trusted == False) whose PR has ever been merged into a tracked repository retains permanent permission to edit the title and body of their own PR after it has been merged.
-
Post-merge PR edit triggers unauthenticated state transition to
patched(desk/desk/services/sync.py:184-215, 231-244, 287-291, 450-452): When an untrusted contributor edits the title or body of an already-merged PR (e.g., an old docs/typo PR) to appendFixes #1 Fixes #2 ..., GitHub sends apull_request(action: "edited") webhook tohandle_webhook()(sync.py:450-452), which callslink_pull()without checkingactionor whether the closing reference existed at merge time;import_repo()(sync.py:287-291) also re-processes the PR on the next poll becausepull["updated_at"]advances. Becausepull["merged_at"]is non-null,state == "merged", and_follow_pull_state()ignorestrusted=Falseand callstsvc.set_status_via_path(ctx, db, SYSTEM, t, "patched", ...), walking every referenced ticket inPRE_PATCH = ("new", "triaging", "needs-info", "accepted", "fixing")to"patched". -
Complete bypass of
ASSESSMENT_HELDconfidentiality embargo and permanent draft lock (desk/desk/services/tickets.py:230-238, 661-664, 931-941): While a confirmed bounty report is inASSESSMENT_HELD = ("new", "triaging", "needs-info", "accepted", "fixing"),tickets.to_dict()withholdsassessed_tier,verdict,internal_ref, andinternal_urlfrom public callers untilpatched. Forcing unfixed tickets inacceptedorfixingtopatchedimmediately setsassessment_held(t) == False, exposing the confidentialassessed_tier,verdict,internal_ref, andinternal_urlof every unpatched vulnerability in that repository onGET /v1/ticketsandGET /v1/tickets/{ticket_id}. Simultaneously, steppingnew/triaging/needs-infotickets throughacceptedpermanently setst.body_editable = False(tickets.py:663), locking reporters out of editing their own drafts.
Remediation
If not trusted and state == "merged", do not allow newly added closing references discovered after merged_at (such as on pull_request edited events) to transition tickets to "patched"; only honor closing PatchRef links that were present at merge time or verified via GitHub's closing-issues event metadata.
Thread
Thanks for the report. We have read it and can follow the behaviour you describe in the desk's GitHub sync; it is being handled and we will update this ticket when there is more to say.