question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GitHub needs to digitally sign the ps1 scripts.

See original GitHub issue

Description

GitHub/Microsoft does not sign autogenerated ps1 scripted steps, this causes a failure on a self-hosted Windows runners.

For example, let’s take this step:

Run dotnet restore some.csproj

Which is turned into the following ps1 file that gets downloaded to the runner:

C:\actions-runner\_work\_temp\7af2df60-c729-42fb-85a1-d9de2fd74369.ps1

However, when the runner tries to execute it, you get the expected trust error:

The file C:\actions-runner\_work\_temp\7af2df60-c729-42fb-85a1-d9de2fd74369.ps1 is not digitally signed. You cannot run this script on the current system.

The workaround is to change execution policy, but this is extremely dangerous and a very bad idea. Microsoft should sign any ps1 steps it creates.

Area for Triage:

  • .NET Core
  • Scripting and command line

Question, Bug, or Feature?:

Bug

Virtual environments affected

  • macOS 10.15
  • Ubuntu 16.04 LTS
  • Ubuntu 18.04 LTS
  • Ubuntu 20.04 LTS
  • Windows Server 2016 R2
  • Windows Server 2019
  • Self-Hosted Windows Runner

Expected behavior

Steps work

Actual behavior

Steps fail due to unsigned ps1 file.

Run dotnet restore $env:SolutionPath --configfile $env:NugetConfigPath --runtime $env:RID

. : File C:\actions-runner\_work\_temp\7af2df60-c729-42fb-85a1-d9de2fd74369.ps1 cannot be loaded. The file 
C:\actions-runner\_work\_temp\7af2df60-c729-42fb-85a1-d9de2fd74369.ps1 is not digitally signed. You cannot run this 
script on the current system. For more information about running scripts and setting execution policy, see 
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ . 'C:\actions-runner\_work\_temp\7af2df60-c729-42fb-85a1-d9de2fd74369 ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
##[error]Process completed with exit code 1.

Repro steps
A description with steps to reproduce the issue. If your have a public example or repo to share, please provide the link.

  1. Create a Windows self-hosted runner
  2. Run a workflow that uses any steps that creates a ps1 file for the step’s instructions.

For a repro example, you can use the following:

name: GitHub Actions Repro

on:
  push

jobs:
  build:
    runs-on: self-hosted

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '3.1.302'

    # This will fail
    - name: NuGet Restore
      run: dotnet restore some.csproj --runtime win-x86

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:13

github_iconTop GitHub Comments

3reactions
jgwinnercommented, Jun 4, 2022

The net result is that Runners are broken for windows.

3reactions
GeorgeTsiokoscommented, Dec 21, 2021

Assuming a default install of the runner on Windows,

  • download psexec
  • execute psexec -i -u "nt authority\network service" powershell.exe
  • in the Powershell prompt, run Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser

Ideally the service should run with a virtual account instead of network service.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automatically sign your PowerShell scripts with GitHub ...
For this post the following prerequisites are required: Code signing certificate in PFX format; GitHub account. Add variables to GitHub actions#.
Read more >
Automatically signing PowerShell scripts via GitHub actions
Ever since I've been using it. I had modified it a bit to suit my needs – such as have the zip file...
Read more >
Signing Windows Software with GitHub Actions, Encrypted ...
Microsoft Authenticode is available to sign apps, libraries, drivers, scripts and more, but this post will focus mostly on signing PowerShell ...
Read more >
Fix for PowerShell Script Not Digitally Signed - Dr. Caio Moreno
When you run a .ps1 PowerShell script you might get the message saying “.ps1 is not digitally signed. The script will not execute...
Read more >
Signed powershell script not signed after source control
Rework the build / deploy process so that powershell scripts aren't required. I'm in the early stages, so this is my best option....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found