Skip to content

ci: add read-only workflow token permissions#1050

Open
Alb3e3 wants to merge 1 commit into
OpenVPN:masterfrom
Alb3e3:harden-workflow-permissions
Open

ci: add read-only workflow token permissions#1050
Alb3e3 wants to merge 1 commit into
OpenVPN:masterfrom
Alb3e3:harden-workflow-permissions

Conversation

@Alb3e3

@Alb3e3 Alb3e3 commented Jun 11, 2026

Copy link
Copy Markdown

Summary

All four GitHub Actions workflows lacked an explicit workflow-level permissions: block. Without one, each run inherits the repository default GITHUB_TOKEN permissions, which can be broader than these jobs need.

This revision keeps the patch focused on workflow token permissions and sets the default token scope to read-only repository contents access.

Changes

  • build.yaml: add permissions: contents: read
  • coverity-scan.yml: add permissions: contents: read
  • doxygen.yml: add permissions: contents: read; the deploy job keeps its existing job-level pages: write and id-token: write permissions
  • test-ssllib.yml: add permissions: contents: read

Verification

python3 - <<'PY'
import pathlib, yaml
for p in pathlib.Path('.github/workflows').glob('*.yml'):
    yaml.safe_load(p.read_text())
for p in pathlib.Path('.github/workflows').glob('*.yaml'):
    yaml.safe_load(p.read_text())
print('yaml ok')
PY

Result: yaml ok.

@Alb3e3 Alb3e3 force-pushed the harden-workflow-permissions branch from 2915e48 to c1f1ee5 Compare June 11, 2026 22:28
@flichtenheld flichtenheld self-assigned this Jun 12, 2026
Comment thread .github/workflows/build.yaml Outdated
push:
pull_request:

permissions: read-all

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we change this I would prefer we document the actually needed permissions.

Comment thread .github/workflows/test-ssllib.yml Outdated
CXX: ${{matrix.cxx}}
UBSAN_OPTIONS: print_stacktrace=1
LIBPREFIX: /opt/${{inputs.libname}}
LIB_CONFIGURE: ${{inputs.libconfigure}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't exactly understand what this protects against? Injection by whom? This is all hard-coded stuff.

Comment thread .github/workflows/test-ssllib.yml Outdated
run: |
${{inputs.ovpnconfigureenv}} \
./configure --with-crypto-library=${{inputs.ovpnlibname}} ${{inputs.ovpnconfigureflags}}
env -S "$OVPN_CONFIGURE_ENV" \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not actually work. See GHA run.

env: only ${VARNAME} expansion is supported, error at: $LIBPREFIX/include" OPENSSL_LIBS="-L$LIBPREFIX/lib -lssl -lcrypto" LDFLAGS="-Wl,-rpath=$LIBPREFIX/lib"

Set explicit, least-privilege GitHub Actions token permissions for the CI, Coverity, Doxygen, and SSL library test workflows.

The build and test jobs only need repository contents read access. The Doxygen deploy job already declares its Pages and OIDC permissions at the job level, so the workflow default can stay read-only.
@Alb3e3 Alb3e3 force-pushed the harden-workflow-permissions branch from c1f1ee5 to 342051e Compare June 12, 2026 11:13
@Alb3e3 Alb3e3 changed the title ci: add read-only workflow token permissions and fix template injection ci: add read-only workflow token permissions Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants