Skip to content

Security question about ACTIONS_RUNTIME_TOKEN #1053

Open

Description

@aomarks

Background

I am working on an application that makes use of https://github.com/actions/toolkit/tree/main/packages/cache to cache GitHub Action output artifacts.

The @actions/cache library needs access to 2 environment variables in order to write to the cache HTTP service: ACTIONS_CACHE_URL and ACTIONS_RUNTIME_TOKEN. These environment variables are automatically available to re-usable action main scripts, but not to standard workflow steps. However, this application needs to run in standard workflow run steps, so it cannot access these variables by default.

So, my current solution is to first run an action that simply re-exports these 2 environment variables to subsequent workflow steps by writing them to the $GITHUB_ENV file.

Question

The above workaround works great, however I am concerned about the security implications of making the ACTIONS_RUNTIME_TOKEN environment variable more widely available (previously just re-usable actions, now to all workflow steps).

What power does ACTIONS_RUNTIME_TOKEN grant? Does it include any powers beyond the ability to upload cache artifacts?

Is this token valid after the workflow ends? Could the token be re-used outside of the particular workflow run that it was created for?

I can see that it is a JWT with the following structure, and the scp field seems to give some hint about what the powers might be:

{
  nameid: 'dddddddd-dddd-dddd-dddd-dddddddddddd',
  scp: 'Actions.GenericRead:00000000-0000-0000-0000-000000000000 Actions.UploadArtifacts:00000000-0000-0000-0000-000000000000/1:Build/Build/12 LocationService.Connect ReadAndUpdateBuildByUri:00000000-0000-0000-0000-000000000000/1:Build/Build/12',
  IdentityTypeClaim: 'System:ServiceIdentity',
  'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/sid': 'DDDDDDDD-DDDD-DDDD-DDDD-DDDDDDDDDDDD',
  'http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid': 'dddddddd-dddd-dddd-dddd-dddddddddddd',
  aui: 'REDACTED',
  sid: 'REDACTED',
  ac: '[{"Scope":"refs/heads/master","Permission":3}]',
  acsl: '10',
  orchid: 'REDACTED.tests.__default',
  iss: 'vstoken.actions.githubusercontent.com',
  aud: 'vstoken.actions.githubusercontent.com|vso:REDACTED',
  nbf: 1649863186,
  exp: 1649864686
}

Thanks for any information!

(Also sorry, I realize this is not a bug, but I cannot remove the label)

Activity

  1. added
    bug
    on Apr 13, 2022
  2. webknjaz commented on Dec 17, 2023

    @webknjaz

    So, my current solution is to first run an action that simply re-exports these 2 environment variables to subsequent workflow steps by writing them to the $GITHUB_ENV file.

    Looks like https://github.com/peaceiris/actions-export-envs does just that.

  3. lazka commented on Apr 26, 2026

    @lazka
    Contributor

    A more secure way, and without depending on third-party actions would be:

    - name: Get credentials
      id: vars
      uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
      with:
        script: |
          core.setOutput('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
          core.setOutput('ACTIONS_RESULTS_URL', process.env['ACTIONS_RESULTS_URL'])
    
    - name: Use them
      env:
        ACTIONS_RUNTIME_TOKEN: ${{ steps.vars.outputs.ACTIONS_RUNTIME_TOKEN }}
        ACTIONS_RESULTS_URL: ${{ steps.vars.outputs.ACTIONS_RESULTS_URL }}
      run: |
        echo foo
    • Use the official actions/github-script to retrieve them
    • Only pass them to the steps that need them

    What power does ACTIONS_RUNTIME_TOKEN grant? Does it include any powers beyond the ability to upload cache artifacts?

    It at least allows creating/deleting/listing workflow artifacts as well. Plus generating signed URLs for workflow artifacts that require no auth.

    Is this token valid after the workflow ends? Could the token be re-used outside of the particular workflow run that it was created for?

    From my testing it gets invalidated when the workflow ends (I got "Failed request: (403) Forbidden: job is complete"). But if it is exfiltrated during the run everything goes.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions