Short · Software engineering · 22 min read

How Do You Keep Pull-Request CI From Exposing Secrets?

Run untrusted pull-request code in an environment without the credentials, network access or persistent state reserved for trusted work, and treat its outputs as untrusted when a privileged workflow consumes them. Withholding a secret variable is only part of that boundary. A job may still have an automatic repository token, permission to obtain a cloud credential, access to internal services, or a way to influence a later release job.

You want contributors to get useful test results without giving their proposed code production authority. I would start with the commands the proposal can cause to run, then inspect the authority available at each execution point. Reviewing the workflow's YAML alone misses scripts, dependency hooks, test fixtures and downloaded files that the workflow executes on its behalf.

This paper develops a proposed assessment using sixteen original government, project and platform sources checked on October 29, 2026. Its review record, acceptance cases and fictional example are original synthesis, not an empirically validated containment standard. No repository, runner or cloud account was tested. The scope is pull-request execution and its privileged handoffs; release approval and artifact-attestation verification remain separate decisions.

A trusted workflow can execute untrusted instructions

The location of the workflow definition does not determine the trustworthiness of everything it runs. A protected definition may invoke a build script from the proposed revision. That script can invoke dependency installation or load a plugin controlled by the same revision. The actual executable input is the resulting chain, not merely the first file someone approved.

OWASP calls this indirect poisoned pipeline execution: an attacker changes files referenced by the pipeline rather than changing the pipeline definition itself. Its examples include build files, tests and configuration that loads external code (OWASP Foundation, n.d.). That mechanism explains why protecting the workflow directory is useful but insufficient when privileged jobs still execute contributor-controlled project content.

This is not an argument against running tests. Executing proposed code is often exactly what CI is supposed to do. The security question is what that execution can affect. A test job allowed to read a synthetic fixture differs from a test job allowed to fetch a production credential, even if both run the same test command and return the same result.

For each job, I would record the origin of the workflow, the checked-out revision, all executable inputs, effective credentials, reachable services and state that survives completion. Include inputs arriving through metadata and outputs of earlier jobs. That record makes a specific claim possible: these proposed changes may execute here, but they cannot exercise authority reserved for a different class of work.

Inspect the event and the effective policy together

Event names are not interchangeable security labels. A pull-request test, repository automation that labels an issue, and a deployment after review have different needs. Choose the trigger according to the operation, then inspect the actual permissions and input handling. Changing the event merely to make a missing credential available can silently change the trust boundary.

GitHub documents pull_request_target as operating with elevated base-repository trust. The dangerous transition occurs when a workflow in that context executes code taken from an untrusted proposal (GitHub, n.d.-h). That is the distinction to preserve: trusted automation may process a proposal as data, but executing the proposal gives it the automation's available authority.

Current safeguards also matter. As checked on October 29, 2026, the same GitHub guide describes a default public-repository event policy in evaluate mode, with enforcement scheduled for December 2, 2026 for affected repositories. It excludes private/internal repositories and existing applicable policies, and describes checkout protection with limited coverage (GitHub, n.d.-h). Verify your repository's effective policy and action version; don't assume a documented future enforcement date has already protected it.

Private repositories require their own review. GitHub exposes private-fork settings that can permit write tokens or secrets in pull-request workflows (GitHub, n.d.-e). A private repository is therefore not evidence that every reader who can propose a change should receive build or deployment privileges. Treat visibility, contributor trust, event permission and job authority as separate facts.

Enumerate credentials that are not called secrets

A credential inventory should include automatic tokens, persisted checkout credentials, cloud federation, package-registry access, host identities and any credentials provided by the runner environment. Inspect what the process can use, not just what appears under a workflow's secrets expressions. Otherwise a review can remove one visible password while leaving an equivalent capability available through another path.

GitHub explicitly notes that an action can access GITHUB_TOKEN through the github.token context even when the workflow has not passed the token as an input. Its guidance is to restrict the token's permissions to the access required (GitHub, n.d.-i). The absence of an explicit token parameter is therefore not evidence of an unauthenticated job.

Checkout persistence is another example. The actions/checkout v6 README describes moving persisted credentials to a separate file under the runner's temporary directory; it also exposes the persist-credentials setting (GitHub, n.d.-a). That storage change should not be confused with removing the credential's authority. Disable persistence where it is unnecessary, while separately evaluating every other token source available to the job.

For each capability, record its resource scope, allowed operations, lifetime and method of acquisition. A short-lived credential reduces one kind of exposure but can still authorize a consequential operation while the job runs. A read-only token can still disclose material that the contributor was not entitled to read. Least privilege begins with the job's legitimate task, not with the smallest permission preset that happens to make it pass.

Keep metadata from becoming program text

Untrusted input does not have to arrive as a source file. Pull-request titles, branch names, issue comments and fields in an uploaded report may be processed by trusted automation. If a workflow inserts those values directly into generated command text, the boundary between a string and an instruction can disappear before the intended check runs.

GitHub's secure-use guidance recommends processing context values as action arguments or, for inline scripts, using an intermediate environment variable rather than generating shell source from the value (GitHub, n.d.-g). That recommendation addresses a particular injection mechanism. It does not establish that every downstream parser or command will treat the resulting argument safely.

I would trace each value to its final interpretation. Is it displayed as text, used as an option, interpreted as a filename, parsed as structured data, or evaluated as code? Validation should fit that use. A value allowed in a displayed title should not automatically be accepted as a destination path or command option. Avoid evaluating metadata simply because it came through an authenticated platform API; contributors may control the field within that authenticated response.

Use harmless test strings to challenge those distinctions in an authorized test repository. The expected result is literal handling, rejection or a clearly bounded transformation. No production secret is needed to show that a title remains data. Keep the test focused on the parser and consumer involved rather than claiming that one successful quoting test establishes the safety of an entire workflow.

Separate execution from privileged reporting

A useful design often separates an unprivileged test from a narrowly privileged reporting operation. The test may need to compile and execute proposed code. The reporter may need to update a check or post a summary, but it should not need to execute that code again. Giving these operations distinct authority makes the boundary reviewable.

Separation by workflow name alone is insufficient. GitHub's workflow_run documentation states that the later workflow can access secrets and write tokens even when its predecessor could not. It also says that triggering on completion does not itself require the preceding workflow to have succeeded (GitHub, n.d.-d). A privileged consumer must therefore evaluate the event, result and supplied material rather than treating completion as approval.

I would give the reporter a small, explicit input contract: which run it may report on, which repository and revision that run belongs to, which result fields are accepted, and what limited update it may make. Obtain authoritative run identity from the platform and compare it with the expected workflow relationship. A field inside a contributor-produced report should not select an arbitrary repository or destination for the privileged write.

The boundary should remain useful if the entire test output is hostile. A reporter that reads a bounded status document and performs a fixed update has a different exposure from one that sources a generated shell script or installs a plugin included in the artifact. Prefer the smallest transformation that satisfies the reporting need, and keep privileged deployment work on a separate authorization path.

Define when an artifact may gain authority

An uploaded artifact is a transport object, not a trust upgrade. Its filename, successful upload and association with a green job do not establish that its content may be executed by a more privileged consumer. Identify the producer, exact run and revision, then define what the consumer is permitted to do with the bytes.

The original design rule I would apply is simple: a low-trust producer must not choose executable instructions or privileged operation targets for a higher-trust consumer without an independent authorization decision. This is a proposed boundary condition, not a proof that every parser or platform component is secure. It forces the reviewer to find the point where data begins controlling authority.

For a report, enforce a bounded schema and permitted values, constrain its size, and avoid unpacking it into a directory that supplies executable tools or configuration. If an archive must be unpacked, review path handling and the destination's later uses. Content validation and extraction safety are different checks. A perfectly valid test report can still be used incorrectly if its fields select a privileged resource outside the intended scope.

For executable outputs, the decision is harder. Rebuilding reviewed source within an authorized environment may be appropriate, but a rebuild is not automatically equivalent to the tested artifact. Record the new artifact identity and rerun the evidence needed for release. If promotion of the existing output is required, establish its origin, review status and explicit release authorization; don't infer those properties from the artifact transport mechanism.

Treat caches as shared inputs with platform-specific scope

Caches deserve a separate inventory because they can carry both confidential content and future executable inputs. Record who can read and write each cache, what files it contains, and which later jobs consume those files. A key that looks unique is not an access-control policy. The relevant question is which workflow contexts can address the cache under the platform's rules.

GitHub documents that pull-request runs can restore eligible base-branch caches, including in fork scenarios. Caches created for the pull-request merge reference have a narrower scope and cannot be restored by the base branch. Its current documentation also restricts low-trust default-branch triggers to read-only cache access unless a write-capable override is declared (GitHub, n.d.-c). Do not describe all pull-request caches as writable by, or visible to, every workflow.

My practical conclusion is to keep secrets out of any cache readable by untrusted work and inspect explicit write overrides before relying on the default restriction. Separate caches where the intended trust relationship differs. A privileged job should not assume that cached tools or generated files are trustworthy merely because restoring them saves time. Where a cache contributes executable content, its producer and validation belong in the execution review.

Test both a cache hit and a miss. A miss may cause the job to fetch dependencies through a different credential or network path; a hit may introduce content absent from the reviewed checkout. The expected authority should remain bounded in either case. Record the platform, event, branch scope and effective configuration used in the test rather than reporting a generic “cache poisoning prevented” result.

Give runner reuse its own acceptance decision

Removing job secrets does not remove the runner's authority. A process may reach a local service, shared filesystem, host credential or internal network destination. If another job later runs on the same machine, residual state can become a connection between otherwise separated workflows. The job's operating environment is part of the trust boundary.

GitLab's runner-security guidance warns that a malicious job on a non-ephemeral runner shared across projects can compromise other projects. It separately identifies the shell executor's host and network exposure because jobs execute with the runner user's permissions (GitLab, n.d.-b). These are deployment-specific risks, not a claim that every managed runner or container has identical isolation properties.

For untrusted execution, I would prefer a disposable environment with a documented lifecycle and no privileged workload sharing that boundary. Define what is replaced: workspace, process namespace, guest, host, attached storage and external state. Deleting the checkout directory is not the same as replacing the execution environment. Likewise, a disposable guest can still perform a harmful authorized operation against a reachable service before it is destroyed.

Review network access against legitimate test needs. Dependency downloads may be necessary; access to internal administrative services usually requires a separate justification. Use dedicated test services and synthetic data where possible. A network restriction can reduce available destinations, but it does not make a credential safe to expose to arbitrary code that can misuse it through an allowed endpoint.

The acceptance record should say what survives a job, what is reset, and how those claims were checked. Include failed and cancelled jobs; cleanup tied only to the ordinary success path may miss exactly the runs that need scrutiny. Any actual runner fault exercise requires its own bounded operational authorization. This manuscript does not authorize changes to shared build infrastructure.

OIDC changes credential acquisition, not the trust question

Replacing a stored cloud secret with federation can remove the need to keep that long-lived secret in CI. It does not answer whether an untrusted job should be able to request a cloud identity. The important boundary moves to token issuance, claims and the cloud role's trust conditions, plus the permissions granted after the exchange.

GitHub's OIDC reference distinguishes id-token: write, which enables requesting an OIDC token, from permission to write other resources. It describes audience and subject claims as inputs commonly used to scope cloud trust (GitHub, n.d.-f). The cloud provider's acceptance policy and resulting role permissions still need review; token-request permission is not itself a complete authorization model.

I would compare the claims from an intended deployment context with those from a pull-request context in an authorized test setup. The cloud trust rule should accept only the intended relationship, and the resulting role should grant only the intended operation. Don't copy a subject string from an old example without checking current claim format, customized subjects and environment behavior in your actual configuration.

A reusable workflow also needs scrutiny: which caller can invoke it, what parameters the caller controls, and which identity the cloud provider evaluates. A trusted workflow file does not sanitize arbitrary executable inputs passed by its caller. The same principle applies when a job obtains credentials from a broker rather than directly from the cloud: evaluate the broker's authorization decision, not merely the absence of a static secret.

Make the cloud trust policy reject the wrong job

For GitHub Actions accessing AWS, I would review three decisions separately: whether the job can request an identity token, whether AWS accepts that token for the production role, and what the resulting session can do. Removing a stored access key improves credential handling, but it doesn't settle any of those authorization decisions. A short-lived session issued to the wrong job is still production access issued to the wrong job.

AWS checks that a GitHub role trust policy contains a non-null subject condition that isn't solely a wildcard. That validation is useful, but AWS also documents broader patterns that permit multiple repositories or branches (Amazon Web Services, n.d.-b). A policy accepted by IAM is therefore not necessarily narrow enough for your deployment requirement. Review the eligible population expressed by the condition, including every alternative statement that can authorize the exchange.

The audience and subject answer different questions. GitHub's AWS guide shows sts.amazonaws.com as the audience used with the official credentials action and uses the subject to restrict the repository and execution context (GitHub, n.d.-b). The audience alone doesn't select your repository. Conversely, a repository-wide subject pattern can include contexts that shouldn't receive deployment authority. The acceptance test must challenge the boundary you intended, not merely demonstrate that a normal deployment gets credentials.

Avoid copying a subject example without inspecting the repository's actual format. Current GitHub guidance says repositories created after July 15, 2026, or opted into immutable subject claims include owner and repository IDs; it excludes GitHub Enterprise Server from that feature. The same guide explains that an environment-based job uses an environment subject and recommends environment protection rules (GitHub, n.d.-b). These are configuration-sensitive distinctions, not interchangeable strings.

That environment case needs a second review. Matching the production environment's subject doesn't independently establish that only a reviewed branch can reach that environment. Inspect its deployment restrictions and approval arrangements, along with who can change them. If the cloud condition relies on the environment to encode a trust decision, the controls governing entry into that environment are part of the cloud-access boundary. Naming an environment “production” doesn't make that boundary strong.

Reusable workflows add another identity relationship. GitHub documents caller information in the ordinary claims and the called workflow in job_workflow_ref. Where a provider cannot evaluate that custom claim directly, GitHub supports incorporating it into a customized subject (GitHub, n.d.-j). Its AWS guide says AWS doesn't support custom OIDC claims (GitHub, n.d.-b). Don't assume that adding an arbitrary claim name to an IAM condition creates a supported check.

I would record the approved caller and the approved reusable workflow separately, including the reference that selects its code. Trusting only the called workflow can be too broad when callers control executable inputs; trusting only the caller can miss a change in the deployment implementation. Any subject-template change also needs a migration plan: update the relying policy deliberately, verify intended admission, and remove superseded allowances rather than leaving both formats broadly trusted indefinitely.

AWS's web-identity API returns a separate set of temporary AWS credentials. Its documentation describes session duration and the use of optional session policies to restrict the role's identity-based permissions (Amazon Web Services, n.d.-a). This matters operationally: record the resulting session's expiry and permitted task, rather than using the OIDC token's expiry as shorthand for the lifetime of cloud access. Do not treat a policy supplied by the job as the sole restriction on an otherwise overpowered role.

A useful negative test changes one authorization-relevant condition while retaining valid surrounding inputs. Use a dedicated test role and harmless resource operation in an authorized test account. Compare the intended caller/context with a different repository, an unapproved branch where branch identity is evaluated, a pull-request context, and a disallowed reusable-workflow reference where that reference is actually bound into the policy. These are proposed cases, not tests performed for this paper.

Separate exchange denial from resource denial in the result. An untrusted job that successfully obtains the test role but cannot modify a particular object has crossed the role-admission boundary, even if a later resource policy limits the damage. An intended job that obtains credentials and performs its declared harmless operation provides a positive control. A failure caused by a malformed token, wrong endpoint or unavailable service is inconclusive about the intended subject restriction.

For the environment case, test whether an otherwise valid unapproved execution context can enter the protected environment before evaluating the role exchange. For reusable workflows, test the caller and called-workflow constraints independently. Preserve sanitized claim fields, effective policy versions, run identity and the observed admission result; don't print or retain bearer tokens as a debugging convenience. A readable token payload alone is not evidence that the relying party accepted its signature or claims.

There is a tradeoff: very narrow predicates require maintenance when repositories, workflows or deployment arrangements change. The answer is controlled policy migration and a clear owner, not a wildcard that removes the distinction being protected. This expansion does not establish every provider's claim mapping or every AWS permission interaction. It gives you a concrete way to review one GitHub-to-AWS relationship while keeping runner isolation, resource authorization and release approval as separate acceptance decisions.

Approval has to identify the code and authority being approved

Human approval can be useful, but its meaning must be explicit. Approval to spend CI minutes, approval to test a revision, approval to expose a protected environment, and approval to release software are different acts. A button labeled “Run” does not communicate which of those decisions the reviewer is making.

GitLab documents a parent-project merge-request pipeline that can use the fork branch's CI configuration with the parent project's resources and variables. Its protected-variable and runner rules are narrower: protected-resource access requires protected source and target branches in the same project and appropriate triggering-user access; fork merge requests cannot receive those protected resources (GitLab, n.d.-a). Preserve that distinction instead of assuming either unrestricted access or complete isolation.

Before authorizing a privileged run, identify the exact revision, executable-input changes, available authority and intended result. A later push may change the object of review. Bind the decision to the revision or require an appropriate new review; don't let a label or earlier approval silently confer permanent trust on a moving branch. The necessary enforcement mechanism depends on the platform and configuration.

NIST SP 800-204D calls for secure-build policies covering isolation, tools and authorization, and describes evidence generation at a higher trust or isolation level than the build it observes (Chandramouli et al., 2024, §5.1.1). I would apply that separation to approval evidence too. A test process should not be able to rewrite the record that supposedly authorized its own access.

Test authority boundaries with harmless probes

A meaningful assessment needs positive and negative cases. A workflow that rejects every contribution is not a useful CI service. First demonstrate that a normal untrusted change can run its intended tests and produce the allowed report. Then challenge specific authority boundaries using disposable fixtures, test identities and controlled destinations, without exposing real credentials.

The following matrix proposes acceptance cases. It reports no executed tests or success rate. Each negative case should retain valid surrounding conditions so that the intended boundary, rather than an unrelated parse error, determines the outcome.

Controlled variationExpected bounded observation
Normal untrusted revisionIntended tests run with the declared low-privilege authority
Job inspects a designated dummy secret locationPrivileged test secret is absent or inaccessible
Pull-request metadata contains harmless command-like charactersConsumer treats it as data or rejects it without executing it
Report requests a destination outside the approved repository/runPrivileged consumer refuses that destination
Untrusted output is presented where an executable input is expectedPromotion requires independent authorization or is denied
Cache hit and cache missBoth paths preserve the declared credential and network boundary
Second job follows a completed or cancelled test jobNo prohibited test marker or authority persists across the intended isolation boundary
Pull-request context requests a test cloud roleExchange or operation is denied under the intended trust policy

Record the event payload identity, revision, workflow/action versions, effective permissions, runner lifecycle, relevant policy and observed result. Avoid recording secrets themselves. An access denial from one test credential proves only that tested relationship. Review the other credential sources and bypass routes before treating it as evidence for the whole job.

Repeat the relevant cases when a trigger, action dependency, runner image, cache policy, cloud trust rule or reporting consumer changes. This is a proposed maintenance rule, not a platform-prescribed schedule. Preserve failed results and remediation decisions. Replacing an adverse observation with a later green summary makes it harder to determine which boundary was actually repaired.

A fictional workflow with a safe test and an unsafe handoff

Consider fictional Cedarwick, which runs pull-request tests without deployment secrets on disposable workers. The tests upload a result bundle. A separate privileged workflow downloads the bundle, posts a repository status, and invokes a helper included in the bundle to format a release summary. The initial test job has limited authority, but the helper is still controlled by the proposed code.

The decisive defect is the later execution, not the fact that artifacts were uploaded. Cedarwick can preserve the useful reporting design by moving the formatting implementation into trusted consumer code and limiting the producer to a defined data schema. The consumer obtains the run identity from trusted platform metadata and refuses report fields that attempt to choose another privileged destination.

The team also discovers that a shared dependency cache contains credentials from a private package setup. Its remedy is to remove those credentials from the cache design and assess exposure under the actual cache-access rules. That discovery requires an incident-response decision about any real credential that may have been exposed; merely fixing the next cache write would not settle past exposure.

After correction, Cedarwick would run the positive reporting case, a report with an unauthorized destination, and a dummy-marker persistence test. These are hypothetical proposed actions, not observations from a real client. The example demonstrates why “the PR job has no secrets” is a useful statement but an incomplete conclusion about the entire execution chain.

Choose useful isolation without pretending it is free

The strongest practical objection is that some tests require private dependencies or integrations. Those needs are real. Separate the least-privileged test capability from production access: a scoped dependency service, a dedicated test tenant or a controlled broker may satisfy the test without giving arbitrary proposed code the deployment role. Each arrangement introduces its own authorization and data-disclosure questions.

Some tests may need to wait until a revision passes the required review. That reduces immediate contributor feedback and can move defects later in the process. Make the tradeoff explicit: which checks run before trust increases, which run afterward, and what evidence permits that transition? Quietly switching to a privileged event to keep every test immediate hides the cost in security exposure rather than removing it.

Disposable workers and separated caches can also increase startup time and repeated downloads. Measure that cost alongside the boundaries they provide. Optimize within the required separation instead of gradually reconnecting the environments through shared credentials, writable tool directories or unrestricted artifact execution. A performance improvement that restores the original authority path has changed the security design.

This assessment does not establish that the proposed source is safe to ship. Use the separate release-evidence assessment for that decision, and the container build-attestation analysis to verify the artifact eventually admitted. Keeping those questions separate prevents a successful isolation test from becoming an unsupported release-security claim.

What the resulting evidence can support

The method depends on accurate configuration, complete input discovery and trustworthy enforcement components. It cannot prove the absence of runner vulnerabilities, identify every hidden credential or guarantee that an accepted cloud policy has no unintended interpretation. The platform sources are normative guidance and implementation documentation; they do not establish a measured incident-reduction rate for this combined assessment.

I would accept a workflow when its permitted execution, available authority and cross-job inputs match a documented purpose, and the consequential boundaries have relevant evidence. Unknown paths should remain visible with a decision about how to restrict or investigate them. The objective is useful contributor testing with controlled authority, not a reassuring claim that a green job was harmless.

If you need to establish that boundary, request a pull-request CI security assessment. Start with one workflow, its runner type and the privileged jobs that consume its outputs. I can help trace the effective authority, identify where proposed code acquires trust, and define a bounded acceptance exercise before a routine test job becomes a route to your release credentials.

References