Skip to content

fix(security): re-verify PR head SHA in performance workflow - #5172

Open
causten wants to merge 1 commit into
developfrom
mythos/pr-perf-toctou
Open

fix(security): re-verify PR head SHA in performance workflow#5172
causten wants to merge 1 commit into
developfrom
mythos/pr-perf-toctou

Conversation

@causten

@causten causten commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Re-check PR headRefOid via gh pr view after ok-to-test gate to close TOCTOU window

JIRA

  • ROCM-26604

Test plan

  • Exercise performance workflow on labeled external PR

Made with Cursor

Addresses ROCM-26604.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI lite review requested due to automatic review settings August 21, 2026 23:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR strengthens the performance workflow’s external PR security gate and updates manual-dispatch repository defaults.

Changes:

  • Rechecks the PR head SHA after the ok-to-test gate.
  • Updates repository defaults to internal repositories.
  • Documents the mutable reusable workflow reference.
Suppressed comments (2)

.github/workflows/performance.yaml:181

  • The reusable workflow remains referenced by the mutable @testing branch, while this pull_request_target path passes BENCHMARK_UTILS_READ_TOKEN to it. Anyone able to change that branch, or a compromised upstream maintainer account, could alter the workflow to exfiltrate the token or run arbitrary work on the privileged runner. Pin this reference to a reviewed full commit SHA before relying on this workflow as a security boundary; the added comment currently defers that mitigation.
    # Pin to immutable commit once available in migraphx-benchmark; @testing is mutable.

.github/workflows/performance.yaml:100

  • security_gate has no checkout, so gh pr view cannot resolve the current repository unless --repo is supplied; this new command will fail on the external-PR path. Also, although it requests labels, jq discards them, so removing ok-to-test after dispatch still lets the stale event-label check pass. Scope the query to ${{ github.repository }} and require the current labels to contain ok-to-test before accepting the SHA.
          PR_HEAD=$(gh pr view ${{ github.event.pull_request.number }} --json headRefOid,labels --jq '.headRefOid')
          if [[ "$PR_HEAD" != "${{ github.event.pull_request.head.sha }}" ]]; then

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

echo "is_ok_to_test=false" >> $GITHUB_OUTPUT
exit 1
fi
PR_HEAD=$(gh pr view ${{ github.event.pull_request.number }} --json headRefOid,labels --jq '.headRefOid')
exit 1
fi
PR_HEAD=$(gh pr view ${{ github.event.pull_request.number }} --json headRefOid,labels --jq '.headRefOid')
if [[ "$PR_HEAD" != "${{ github.event.pull_request.head.sha }}" ]]; then
@gh-app-migraphx-bot-pr-write

Copy link
Copy Markdown
Test Batch New Rate (c502fe) Old Rate (3a503c)* Diff Status
torchvision-resnet50 64 3,324.59 3,264.92 1.83%
torchvision-resnet50_fp16 64 7,873.53 7,548.67 4.30%
torchvision-densenet121 32 2,489.96 2,483.99 0.24%
torchvision-densenet121_fp16 32 5,026.06 5,004.24 0.44%
torchvision-inceptionv3 32 2,070.22 2,058.51 0.57%
torchvision-inceptionv3_fp16 32 4,460.17 4,416.99 0.98%
cadene-inceptionv4 16 817.88 820.61 -0.33%
cadene-resnext64x4 16 781.78 782.78 -0.13%
slim-mobilenet 64 8,379.87 8,386.36 -0.08%
slim-nasnetalarge 64 228.36 228.86 -0.22%
slim-resnet50v2 64 3,238.93 3,180.91 1.82%
bert-mrpc-onnx 8 1,170.58 1,168.84 0.15%
bert-mrpc-tf 1 498.46 498.63 -0.03%
pytorch-examples-wlang-gru 1 492.00 473.35 3.94%
pytorch-examples-wlang-lstm 1 411.79 384.83 7.01% 🔆
torchvision-resnet50_1 1 1,046.86 1,046.63 0.02%
cadene-dpn92_1 1 449.25 437.32 2.73%
cadene-resnext101_1 1 366.54 365.89 0.18%
onnx-taau-downsample 1 847.18 844.09 0.37%
dlrm-criteoterabyte 1 32.28 32.42 -0.44%
dlrm-criteoterabyte_fp16 1 51.58 51.80 -0.43%
agentmodel 1 15,099.19 9,209.12 63.96% 🔆
unet_fp16 2 58.27 58.80 -0.90%
resnet50v1_fp16 1 1,437.88 1,366.11 5.25% 🔆
resnet50v1_int8 1 1,764.27 1,883.96 -6.35% 🔴
bert_base_cased_fp16 64 1,098.09 1,098.16 -0.01%
bert_large_uncased_fp16 32 345.72 345.59 0.04%
bert_large_fp16 1 206.64 206.59 0.03%
distilgpt2_fp16 16 2,085.27 2,092.89 -0.36%
yolov5s 1 551.93 558.33 -1.15%
tinyllama 1 45.84 45.83 0.01%
vicuna-fastchat 1 44.25 44.20 0.12%
whisper-tiny-encoder 1 413.26 411.87 0.34%
whisper-tiny-decoder 1 410.23 408.48 0.43%
llama2_7b 1 20.87 20.84 0.16%
qwen1.5-7b 1 23.64 23.58 0.27%
phi3-3.8b 1 26.77 26.72 0.21%
llama3-8b 1 21.72 21.80 -0.39%
whisper-large-encoder 1 10.17 10.18 -0.06%
whisper-large-decoder 1 105.88 105.30 0.55%
mistral-7b 1 23.75 23.78 -0.12%
FLUX.1-schnell 1 764.20 755.22 1.19%

Regressions detected 🔴

* No develop baseline was found for this PR's branch point; compared against the latest available develop run instead.

@gh-app-migraphx-bot-pr-write

Copy link
Copy Markdown
Test Status Result
bert-mrpc-onnx PASSED: MIGraphX meets tolerance
bert-mrpc-tf ERROR - check error output
traceback
Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 377, in
main()
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 313, in main
import tensorflow as tf
File "/usr/local/lib/python3.12/dist-packages/tensorflow/init.py", line 40, in
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow # pylint: disable=unused-import
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 37, in
self_check.preload_check()
File "/usr/local/lib/python3.12/dist-packages/tensorflow/python/platform/self_check.py", line 63, in preload_check
from tensorflow.python.platform import _pywrap_cpu_feature_guard
ImportError: libnuma.so.1: cannot open shared object file: No such file or directory
pytorch-examples-wlang-gru PASSED: MIGraphX meets tolerance
pytorch-examples-wlang-lstm PASSED: MIGraphX meets tolerance
dlrm-criteoterabyte PASSED: MIGraphX meets tolerance
agentmodel PASSED: MIGraphX meets tolerance
unet PASSED: MIGraphX meets tolerance
resnet50v1 PASSED: MIGraphX meets tolerance
bert_base_cased_fp16 PASSED: MIGraphX meets tolerance
bert_large_uncased_fp16 🔴 FAILED: MIGraphX is not within tolerance - check verbose output
bert_large PASSED: MIGraphX meets tolerance
yolov5s PASSED: MIGraphX meets tolerance
tinyllama PASSED: MIGraphX meets tolerance
vicuna-fastchat PASSED: MIGraphX meets tolerance
whisper-tiny-encoder PASSED: MIGraphX meets tolerance
whisper-tiny-decoder PASSED: MIGraphX meets tolerance
distilgpt2_fp16 🔴 FAILED: MIGraphX is not within tolerance - check verbose output
llama2_7b PASSED: MIGraphX meets tolerance
qwen1.5-7b PASSED: MIGraphX meets tolerance
phi3-3.8b PASSED: MIGraphX meets tolerance
llama3-8b PASSED: MIGraphX meets tolerance
whisper-large-encoder PASSED: MIGraphX meets tolerance
whisper-large-decoder PASSED: MIGraphX meets tolerance
mistral-7b PASSED: MIGraphX meets tolerance
FLUX.1-schnell PASSED: MIGraphX meets tolerance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants