Skip to content

fix(security): least-privilege workflow permissions (SonarCloud New Code)#58

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/sonar-least-privilege
Jul 21, 2026
Merged

fix(security): least-privilege workflow permissions (SonarCloud New Code)#58
hyperpolymath merged 1 commit into
mainfrom
fix/sonar-least-privilege

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

main is green as of #57. This addresses the one original red that had gone unexamined all programme: SonarCloud Quality Gate — C Security Rating on New Code (required ≥ A).

Getting the findings without dashboard access

SonarCloud's project is public, so its API lists them directly:

https://sonarcloud.io/api/issues/search?componentKeys=hyperpolymath_krl&types=VULNERABILITY

15 vulnerabilities, all inside the new-code period. Two are fixed here — including one this programme introduced.

Fixed

e2e.yml"Replace read-all with specific permissions"

This one is mine. e2e.yml was rewritten in #53 and carried the RSR template's permissions: read-all. Narrowed to contents: read, which is all four jobs need.

pages.yml ×3 — "Move this read/write permission from workflow level to job level"

The workflow granted contents:read + pages:write + id-token:write to both jobs, but only deploy needs the pages and id-token scopes. Now split per job:

Job Permissions
build contents: read
deploy contents: read, pages: write, id-token: write

That matters here beyond satisfying the linter: the build job runs a container image and executes the SSG over repository content. It should not be holding deploy credentials while doing so.

Not fixed — deliberately, so this stays reviewable

Finding Location
Only pass required secrets to this workflow secret-scanner.yml:18, mirror.yml:12
Dependencies without locked resolved versions release.yml:38
Not enforcing HTTPS release.yml:91, static-analysis-gate.yml:30,31,229,230, setup.sh:144,156
Workflow-level permission static-analysis-gate.yml:11

The rating will not reach A until those are triaged too. Several of the HTTPS findings may be false positives and need reading in context before anything is changed — which is exactly why they aren't bundled into a PR about permissions.

Verified

actionlint 0 · K9 0 errors · A2ML 0 errors · e2e 4/4 · aspect 4/4 · smoke 20/20

…ode)

SonarCloud's Quality Gate has been red on 'C Security Rating on New Code'
(required >= A) since before this programme started, and had not been looked
at. Its public API lists the findings without needing dashboard access:

  https://sonarcloud.io/api/issues/search?componentKeys=hyperpolymath_krl&types=VULNERABILITY

15 vulnerabilities, all inside the new-code period. Two of them are addressed
here, including one this programme introduced.

* .github/workflows/e2e.yml — 'Replace "read-all" with specific permissions'.
  This one is mine: e2e.yml was rewritten in #53 and carried the template's
  `permissions: read-all`. Narrowed to `contents: read`, which is all four
  jobs need.

* .github/workflows/pages.yml — three findings, 'Move this read/write
  permission from workflow level to job level'. The workflow granted
  contents:read + pages:write + id-token:write to BOTH jobs, but only deploy
  needs the pages and id-token scopes. Split per job so the build job — the one
  that runs a container image and executes the SSG over repository content —
  never holds deploy credentials.

Not addressed here, and left for a separate pass so this PR stays reviewable:

  secret-scanner.yml:18   Only pass required secrets to this workflow
  mirror.yml:12           Only pass required secrets to this workflow
  release.yml:38          Dependencies without locked resolved versions
  release.yml:91          Not enforcing HTTPS
  static-analysis-gate.yml:11   Workflow-level permission
  static-analysis-gate.yml:30,31,229,230   Not enforcing HTTPS
  setup.sh:144,156        Not enforcing HTTPS

The rating will not reach A until those are triaged too; several may be
false positives (the HTTPS findings need reading in context before changing).

Verified: actionlint 0, K9 0, A2ML 0, e2e 4/4, aspect 4/4, smoke 20/20.
@sonarqubecloud

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath merged commit 638e957 into main Jul 21, 2026
38 of 39 checks passed
@hyperpolymath
hyperpolymath deleted the fix/sonar-least-privilege branch July 21, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant