Skip to content

Instantly share code, notes, and snippets.

@bfrancom
Created September 5, 2025 16:52
Show Gist options
  • Save bfrancom/76a89d4a7bf2e24144da4bc4ebcfaf5c to your computer and use it in GitHub Desktop.
Save bfrancom/76a89d4a7bf2e24144da4bc4ebcfaf5c to your computer and use it in GitHub Desktop.
Retrieve GitHub Action Secrets Securely
#From this website: https://meirg.co.il/2022/07/01/how-to-recover-secrets-from-github-actions/
name: Recovering secrets
# Assumption:
# You've created the following GitHub secrets in your repository:
# MY_CLIENT_SECRET - encrypt/decrypt with openssl - useful for public and public repositories
# MY_OPENSSL_PASSWORD - used to protect secrets
# MY_OPENSSL_ITER - Use a number of iterations on the password to derive the encryption key.
# High values increase the time required to brute-force the resulting file.
# This option enables the use of PBKDF2 algorithm to derive the key.
on:
push:
workflow_dispatch:
jobs:
openssl:
name: Recover With OpenSSL
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- env:
MY_CLIENT_SECRET: ${{ secrets.MY_CLIENT_SECRET }}
MY_OPENSSL_PASSWORD: ${{ secrets.MY_OPENSSL_PASSWORD }}
MY_OPENSSL_ITER: ${{ secrets.MY_OPENSSL_ITER }}
run: |
echo "MY_CLIENT_SECRET (***) = ${MY_CLIENT_SECRET}"
echo "MY_CLIENT_SECRET (openssl) = $(echo "${MY_CLIENT_SECRET}" | openssl enc -e -aes-256-cbc -a -pbkdf2 -iter ${MY_OPENSSL_ITER} -k "${MY_OPENSSL_PASSWORD}")"
echo "Copy the above value, and then execute locally:"
echo "echo PASTE_HERE | openssl base64 -d | openssl enc -d -pbkdf2 -iter \$MY_OPENSSL_ITER -aes-256-cbc -k \$MY_OPENSSL_PASSWORD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment