Skip to content

Fix CodeQL alerts in benchmark comments and regex dump - #403

Merged
Vladimir Morozov (vmoroz) merged 1 commit into
microsoft:mainfrom
vmoroz:PR/codeql-alerts
Nov 3, 2026
Merged

Vladimir Morozov (vmoroz) merged 1 commit into
microsoft:mainfrom
vmoroz:PR/codeql-alerts

Conversation

@vmoroz

@vmoroz Vladimir Morozov (vmoroz) commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes the three open CodeQL alerts from the new advanced setup.

  • Code injection in Post Benchmark Results (critical, alert 30). The
    workflow pasted the PR number from the benchmark artifact straight into its
    github-script source. That artifact is written by the PR's own copy of the
    Benchmarks workflow, so a fork could inject code that runs in the base
    repository with a token that can write PR comments. The workflow now accepts
    only a decimal PR number, passes it through an environment variable, and
    comments only when that PR's head commit is the one that was benchmarked, so
    a forged number cannot target another PR.
  • Suspicious add with sizeof (high, alerts 59 and 60). The regex bytecode
    dump found the characters after MatchNChar8 and MatchNCharICase8 with
    insn + sizeof(regex::Insn), which is pointer arithmetic on the instruction
    type. It worked only because sizeof(regex::Insn) is 1. It now uses
    insn + 1, as the regex executor does. Output is unchanged. The same code
    is in upstream Hermes.

Test Plan

  • .\dev build --targets hermesc --platform x64 --configuration release
    (separate output folder): passed.
  • hermesc -dump-bytecode -target=HBC -non-strict test\hermes\regexp_bytecode.js
    and hermesc -O -dump-bytecode test\BCGen\HBC\store_to_env.js: output is
    byte-identical to a hermesc built before this change, and contains every
    MatchNChar8 and MatchNCharICase8 CHECK line in both tests.
  • PR-number check run in bash: accepts 402 and 401\n; rejects
    1');require('child_process').execSync('id');//, 0x1F, an empty file
    and an 11-digit value.
  • actionlint on both benchmark workflows: passed.
  • The comment path itself runs only after a PR's Benchmarks run; this PR's
    benchmark comment exercises it.
Microsoft Reviewers: Open in CodeFlow

Post Benchmark Results pasted the PR number from the benchmark artifact
into its github-script source. The artifact is written by the PR's own
copy of the Benchmarks workflow, so a fork could inject code that runs
with a token that can write PR comments. Accept only a decimal PR number,
pass it through an environment variable, and comment only when that PR's
head commit is the one that was benchmarked.

The regex bytecode dump located the characters after MatchNChar8 and
MatchNCharICase8 with insn + sizeof(regex::Insn). That is pointer
arithmetic on the instruction type and works only because sizeof(Insn)
is 1. Use insn + 1, as the regex executor does. Output is unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 2, 2026 23:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are identified for the benchmark-comment workflow hardening and regex bytecode dump changes.

No open issues 🎉

What changed in this PR

This PR addresses three CodeQL alerts by hardening benchmark-result commenting and correcting pointer arithmetic in regex bytecode dumps.

Changes:

  • Validates artifact-supplied PR numbers and passes them through an environment variable rather than embedding them in JavaScript.
  • Checks that the target PR’s current head matches the benchmark workflow’s head commit before commenting.
  • Uses insn + 1 to locate trailing character data in two regex instructions, preserving dump output.
File Description
lib/​Regex/​RegexSerialization.cpp Corrects character-data pointer arithmetic for two regex instruction dumps.
.github/​workflows/​benchmark-comment.yml Validates PR numbers, avoids script interpolation, and adds a head-commit check.

Review effort: Balanced

@vmoroz
Vladimir Morozov (vmoroz) merged commit 566cd0c into microsoft:main Nov 3, 2026
19 checks passed
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Benchmark Results

Total benchmarks: 204

Inputs: baseline/baseline.json, bench_result.json

v8 (6176ms, 3666ms) -40.6%
v8 hermes (CI) hermes (CI)
v8-crypto 622.6ms 369ms
v8-deltablue 739.4ms 417ms
v8-raytrace 127.8ms 67.2ms
v8-regexp 593ms 341.4ms
v8-richards 937ms 562.4ms
v8-splay 225.2ms 151.2ms
v8-crypto (static) 452ms 276.2ms
v8-deltablue (static) 661.6ms 400ms
v8-raytrace (static) 91.8ms 53.8ms
v8-regexp (static) 749.2ms 437.4ms
v8-richards (static) 781.4ms 447.8ms
v8-splay (static) 195ms 142.2ms
test-suites (317886ms, 168009ms) -47.1%
test-suites hermes (CI) hermes (CI)
box2d 2949.8ms 1511.8ms
earley-boyer 2564.8ms 1545.2ms
navier-stokes 5743.8ms 2630.8ms
pdfjs 1038.2ms 527.8ms
gbemu 2296ms 1214.6ms
code-load 4472.8ms 2949ms
typescript 3381.8ms 2088.4ms
simpleSum 8855.4ms 4487.4ms
propAccess 2691.2ms 1210.8ms
allocObj 252ms 152ms
allocObjLit 6371.8ms 3221.6ms
allocNewObj 20053ms 10505.8ms
allocArray 249ms 154.6ms
allocNewArray 34956.8ms 17836.2ms
arrayRead 115.6ms 50ms
arrayReadByIndex 550ms 301ms
largeArrayRead 827.2ms 332ms
arrayWrite 261.8ms 136.6ms
largeArrayWrite 2218ms 1145ms
interp-dispatch 2880ms 1388.8ms
wb-perf 8327ms 2986ms
arrayReverse 40.6ms 21ms
arrayMap 1472.6ms 763.6ms
arrayIndexOf 143.2ms 77.4ms
arrayLastIndexOf 148.6ms 81.2ms
arrayEvery 2308.8ms 1162.2ms
arraySome 2174.4ms 1187.4ms
arrayFill 2401.2ms 1194.8ms
arrayFilter 1866.4ms 1028.6ms
arrayFind 3207ms 1908.8ms
arrayFindIndex 3322ms 1865.8ms
arrayPop 1031.4ms 528.2ms
arrayReduce 1994.2ms 1131.8ms
arrayReduceRight 2075.8ms 1123ms
arrayShift 2065.8ms 1121.8ms
arrayUnshift 2109.4ms 1142.4ms
arrayIncludes 1216.6ms 608.4ms
arrayFrom 1102.8ms 647ms
arrayCopyWithin 1487ms 780.6ms
stringFromCharCode 92.6ms 53.2ms
arraySlice 786.2ms 450.4ms
arraySplice 26.8ms 16.4ms
arrayOf 1048.8ms 486.4ms
stringCharAt 1346.6ms 658.8ms
stringMatch 3192.4ms 1395.6ms
stringSearch 3508.2ms 1370ms
stringStartsWith 701ms 306.4ms
stringEndsWith 650.4ms 320.4ms
stringIncludes 1520.6ms 723.2ms
stringIndexOf 1555.6ms 955.4ms
stringLastIndexOf 1821.4ms 805.4ms
stringSplit 822ms 385.6ms
stringSlice 490ms 253ms
stringPadStart 2910.8ms 1440.8ms
stringPadEnd 2910ms 1437.8ms
regExpMatch 1506.2ms 817.2ms
regExpSearch 1227ms 632.8ms
regExpToString 1204ms 564.4ms
stringReplace 1394.8ms 807.2ms
regExpReplace 3309.2ms 486ms
regExpFlags 956.8ms 520ms
regExpSplit 1307.8ms 687.2ms
numberArrayReadWrite 2477.8ms 1240.8ms
protoCache 3594.6ms 1533.8ms
box2d (static) 1792.6ms 1004.8ms
earley-boyer (static) 1875.6ms 1043ms
navier-stokes (static) 3410.2ms 1888ms
pdfjs (static) 812.8ms 460.8ms
gbemu (static) 1797ms 969.2ms
code-load (static) 4199.2ms 2806ms
typescript (static) 2685.6ms 1711.4ms
simpleSum (static) 936.2ms 641.2ms
propAccess (static) 2298ms 1243ms
allocObj (static) 0.2ms 0ms
allocObjLit (static) 4154.4ms 2360.2ms
allocNewObj (static) 15749.2ms 9253.8ms
allocArray (static) 0.6ms 0.2ms
allocNewArray (static) 28494.2ms 16032.4ms
arrayRead (static) 74.2ms 41ms
arrayReadByIndex (static) 453.2ms 396.6ms
largeArrayRead (static) 552.2ms 375.2ms
arrayWrite (static) 178.4ms 99.4ms
largeArrayWrite (static) 1568.6ms 887.4ms
interp-dispatch (static) 1918.8ms 1510.8ms
wb-perf (static) 8991.2ms 4770.2ms
arrayReverse (static) 37ms 20.6ms
arrayMap (static) 1064.8ms 561ms
arrayIndexOf (static) 128.2ms 75ms
arrayLastIndexOf (static) 138.8ms 75.8ms
arrayEvery (static) 1397.6ms 788ms
arraySome (static) 1406.6ms 802ms
arrayFill (static) 1969.2ms 1107.2ms
arrayFilter (static) 1061ms 606.2ms
arrayFind (static) 2242.2ms 1367.4ms
arrayFindIndex (static) 2235.8ms 1331.2ms
arrayPop (static) 878ms 497ms
arrayReduce (static) 1311.8ms 752.6ms
arrayReduceRight (static) 1322.6ms 755.4ms
arrayShift (static) 1512ms 895.2ms
arrayUnshift (static) 1568.2ms 943ms
arrayIncludes (static) 963.4ms 523.6ms
arrayFrom (static) 1030.6ms 563.8ms
arrayCopyWithin (static) 1109.6ms 644.6ms
stringFromCharCode (static) 77ms 41ms
arraySlice (static) 571.6ms 350.2ms
arraySplice (static) 26ms 17.4ms
arrayOf (static) 868.8ms 441.4ms
stringCharAt (static) 1100.6ms 534.6ms
stringMatch (static) 2227.6ms 1275.6ms
stringSearch (static) 2219.2ms 1244.6ms
stringStartsWith (static) 494.2ms 257.6ms
stringEndsWith (static) 457.8ms 240.2ms
stringIncludes (static) 1437.4ms 708.8ms
stringIndexOf (static) 1440.8ms 872.4ms
stringLastIndexOf (static) 1956.6ms 1013.6ms
stringSplit (static) 651.2ms 340.6ms
stringSlice (static) 445.6ms 223.8ms
stringPadStart (static) 2294.4ms 1162.2ms
stringPadEnd (static) 2499.2ms 1156.8ms
regExpMatch (static) 1483.2ms 769.6ms
regExpSearch (static) 1296.2ms 651.6ms
regExpToString (static) 1326.6ms 591ms
stringReplace (static) 1455.6ms 796ms
regExpReplace (static) 851.8ms 428.8ms
regExpFlags (static) 870.6ms 452.4ms
regExpSplit (static) 1200ms 557.8ms
numberArrayReadWrite (static) 2132.8ms 1136ms
protoCache (static) 3595.8ms 1842.8ms
micros (60876ms, 41289ms) -32.2%
micros hermes (CI) hermes (CI)
getNodeById.js 5273ms 2695.4ms
setInsert.js 2864.8ms 2109.6ms
stringify-number.js 1823.4ms 1088.2ms
typed-array-sort.js 22381ms 15218.8ms
getNodeById.js (static) 3941ms 2243.6ms
setInsert.js (static) 2517.6ms 2116.4ms
stringify-number.js (static) 1663.6ms 915.2ms
typed-array-sort.js (static) 20411.4ms 14902ms
jit-benches (8563ms, 4426ms) -48.3%
jit-benches hermes (CI) hermes (CI)
idisp.js 2810.2ms 1389.4ms
idispn.js 3395.8ms 1299.6ms
idisp.js (static) 1906ms 1530.4ms
idispn.js (static) 450.8ms 206.8ms
many-subclasses (73437ms, 40694ms) -44.6%
many-subclasses hermes (CI) hermes (CI)
many.js 19104.8ms 11014.2ms
many-sh-1.js 7322.8ms 3980.6ms
many-sh-2.js 7329ms 3968.8ms
many-sh-3.js 7083.6ms 3881ms
many-sh-4.js 7235ms 3901.2ms
many.js (static) 15996ms 9114.4ms
many-sh-1.js (static) 2285.2ms 1173.6ms
many-sh-2.js (static) 2387ms 1280.2ms
many-sh-3.js (static) 2347.2ms 1185.2ms
many-sh-4.js (static) 2346ms 1195ms
map-objects (3627ms, 1927ms) -46.9%
map-objects hermes (CI) hermes (CI)
map-objects-untyped.js 1023.6ms 536.4ms
map-objects-typed.js 957.6ms 489.2ms
map-objects-untyped.js (static) 917.2ms 498.8ms
map-objects-typed.js (static) 728.8ms 402.6ms
map-strings (4335ms, 2483ms) -42.7%
map-strings hermes (CI) hermes (CI)
map-strings-untyped.js 1196.8ms 667.2ms
map-strings-typed.js 1139.2ms 639.2ms
map-strings-untyped.js (static) 1092.2ms 639.6ms
map-strings-typed.js (static) 906.8ms 537ms
nbody (3448ms, 1733ms) -49.7%
nbody hermes (CI) hermes (CI)
original/nbody.js 839.6ms 390.2ms
fully-typed/nbody.js 710ms 325.4ms
fully-typed/nbody.ts 865.2ms 373.8ms
original/nbody.js (static) 449.2ms 290.4ms
fully-typed/nbody.js (static) 135ms 72.8ms
fully-typed/nbody.ts (static) 449.2ms 280.2ms
string-switch (6503ms, 3117ms) -52.1%
string-switch (string-switch/plain) hermes (CI) hermes (CI)
bench.js 1316ms 745.8ms
bench.js (static) 5187ms 2371ms
raytracer (5608ms, 3142ms) -44.0%
raytracer (raytracer/original) hermes (CI) hermes (CI)
bench-raytracer.js 1550.4ms 825ms
raytracer.ts 1667.6ms 864.2ms
bench-raytracer.js (static) 1198.4ms 725.4ms
raytracer.ts (static) 1191.8ms 727.2ms
MiniReact (30332ms, 16694ms) -45.0%
MiniReact hermes (CI) hermes (CI)
no-objects/out/simple-stripped.js 2239.2ms 1185.8ms
no-objects/out/simple-lowered.js 2270.8ms 1240.6ms
no-objects/out/music-stripped.js 42.6ms 30.2ms
no-objects/out/music-lowered.js 47.2ms 35.4ms
no-deps/stripped/MiniReact.js 5004ms 2614.6ms
no-deps/MiniReact.js 5256.2ms 2501.6ms
no-objects/out/simple.js 2260.4ms 1186.4ms
no-objects/out/music.js 45.6ms 32.6ms
no-objects/out/simple-stripped.js (static) 1725.2ms 1029.8ms
no-objects/out/simple-lowered.js (static) 1725.4ms 1041.8ms
no-objects/out/music-stripped.js (static) 18.8ms 14.4ms
no-objects/out/music-lowered.js (static) 19.4ms 14.6ms
no-deps/stripped/MiniReact.js (static) 4024.8ms 2354.8ms
no-deps/MiniReact.js (static) 3938.2ms 2363.6ms
no-objects/out/simple.js (static) 1695.2ms 1033.4ms
no-objects/out/music.js (static) 19ms 14.6ms
widgets (12934ms, 6987ms) -46.0%
widgets hermes (CI) hermes (CI)
simple-classes/widgets.js 1758.2ms 877.6ms
original/es5/widgets.js 2798.8ms 1476.8ms
single-file/es5/widgets.js 2775.2ms 1501.4ms
simple-classes/widgets.js (static) 1012ms 568.6ms
original/es5/widgets.js (static) 2283.2ms 1273.6ms
single-file/es5/widgets.js (static) 2306.2ms 1288.8ms

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.

3 participants