Skip to content

Harden benchmark runners and pipelines - #162

Merged
Jake Bailey (jakebailey) merged 7 commits into
mainfrom
harden-benchmark-artifact-handling
Oct 20, 2026
Merged

Jake Bailey (jakebailey) merged 7 commits into
mainfrom
harden-benchmark-artifact-handling

Conversation

@jakebailey

Copy link
Copy Markdown
Member

While we only run benchmarks on trusted PRs, do a bit of work to harden the pipeline against AzDO commands, and sandbox the builds/benchmark runs.

Approved compiler builds can still produce unexpected files. Artifact
handling must not follow links into the agent filesystem, block
on special files, or expose logging commands through filenames in
upload tasks.

Apply the same checks to packaged API artifacts and require a regular
compiler manifest before identifying the implementation.
Scenario installers and compiler runs share source trees with later
host-side setup. Protect Git metadata from installer writes and keep
hooks disabled so a later checkout cannot execute retained repository
configuration as an unintended host-side action.

Pass the selected scenario commit through a validated metadata handoff
rather than giving general setup output variable-publication authority.
Downloaded compiler artifacts and unscheduled files must not become
additional report inputs. Use the setup matrix as the source of
expected result names, including API jobs, and reject missing or
nonregular files.

Report labels belong in literal arguments, not shell source. Keeping
filenames and labels as data avoids broad artifact globs and shell
interpretation while preserving the original benchmark text.
Rendering benchmark data does not require blob-write credentials. Keep
upload authority in a separate job whose eligibility comes from setup,
without treating job separation as authentication of the reported data.

Reporting needs a GitHub token only when posting a PR comment. Limit
that token to pull-request write permission, create it after result
processing, and avoid revocation attempts when token creation was
skipped or failed.
Compiler and benchmark text must not gain pipeline authority simply
because the agent recognizes a logging command in it. Agent-enforced
step capabilities are a better boundary than repeatedly rewriting
output.

Intentional variable publication needs a narrower boundary than
general data processing. Required metadata and result handoffs let
later steps detect missing output even if an earlier task reports
success prematurely.

Preserve original benchmark text while retaining protocol escaping
and inert diagnostics where a step is authorized to publish variables.
Benchmark hosts let every user run pyperf as root with any arguments.
pyperf can launch arbitrary commands, so any code running as the agent
user, including a compiler under test, could become root and persist
beyond the job.

The pipeline only needs one tuning operation with host-specific CPUs,
so grant the agent user exactly that and nothing else.
Maintainer approval remains the primary trust decision. Isolation adds
protection if harmful compiler or dependency behavior slips through.

Even without sudo, code running directly as the agent user can read
agent credentials, reach the network, and modify the agent, cached
hosts, or scenario repositories to affect later jobs. Running builds
and benchmarks in bubblewrap confines them to the files each step needs
and prevents privilege elevation, without the runtime overhead of a VM
or gVisor. API packaging and consumer subprocesses need the same
boundaries.
@jakebailey
Jake Bailey (jakebailey) merged commit da3edd1 into main Oct 20, 2026
31 checks passed
@jakebailey
Jake Bailey (jakebailey) deleted the harden-benchmark-artifact-handling branch October 20, 2026 18:43
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.

1 participant