Skip to content

Using permission-* option with actions/create-github-app-token does not restrict token permissions #237

Closed
@waqaskayani

Description

@waqaskayani

I'm using the actions/create-github-app-token action and trying to leverage the permission-<permission name> inputs as defined here to request a token with a reduced set of permissions compared to what the App installation has been granted.

Expected Behavior:

Based on the action's documentation and the standard behavior of the GitHub API (POST /app/installations/{installation_id}/access_tokens), providing specific permission-* inputs should result in an installation access token that has permissions limited to the intersection of the requested permissions and the permissions granted to the App installation.

Actual Behavior:

Even when specifying a subset of permissions using permission-* inputs, the generated token appears to retain all the permissions originally granted to the App installation. It does not seem to be restricted to the subset requested in the workflow.

Steps to Reproduce:

  1. Configure a GitHub App with the following permissions granted to its installation:
    • contents: write
    • pull-requests: write
  2. Use the actions/create-github-app-token action in a workflow, requesting only read permissions for pull-requests and contents:
name: Test App Token Permissions

on: [push]

jobs:
  test-token:
    runs-on: ubuntu-latest
    steps:
      - name: Generate restricted token
        id: generate-token
        uses: actions/create-github-app-token@v2
        with:
          app-id: ${{ secrets.APP_ID }}
          private-key: ${{ secrets.APP_PRIVATE_KEY }}
          permission-contents: read
          permission-pull-requests: read

      - name: Create Pull Request
        # This step should ideally fail if permissions were restricted correctly
        uses: peter-evans/create-pull-request@v7
        with:
          token: ${{ steps.generate-token.outputs.token }}
  1. Observe that operations requiring permissions not explicitly requested in the workflow step (i.e. pull-requests: write) still succeed when using the generated token. In my specific case, I was able to create Pull Requests using the token generated with only checks: read and contents: read requested.

Is this the intended behavior, or is there potentially an issue with how the permission-* inputs are processed and passed to the GitHub API? According to the documentation, I would expect the token's permissions to be strictly limited to those requested via the inputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions