Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Reject hidden workflow trust structure
pulse-triage[bot]8cd5c2cae57a
diff --git a/.github/workflows/README.md b/.github/workflows/README.mdindex 4fdb776ca7..5a5fe8f3c5 100644--- a/.github/workflows/README.md+++ b/.github/workflows/README.md@@ -7,6 +7,13 @@ smoke suite. Remote actions and reusable workflows must use full commit SHAs,container actions must use SHA-256 digests, and GitHub-hosted runners must usedated image labels rather than moving `-latest` aliases.+The audit also requires trust-bearing workflow structure to remain directly+visible in canonical block YAML. Escaped or explicit mapping keys,+anchors/aliases/tags, non-empty flow mappings, inline `jobs` or `steps`, and+noncanonical job declarations are rejected because YAML expansion can+otherwise hide permissions, runner identity, dependencies, or executable+steps from lexical policy checks.+Checkout pins additionally belong to a reviewed allowlist whose current floorincludes GitHub's fail-closed fork-PR protection for privileged events. Theaudit prohibits `pull_request_target` entirely and rejects checkout'sdiff --git a/scripts/check_workflow_trust.py b/scripts/check_workflow_trust.pyindex 0aee0104e9..17cb422cbb 100644--- a/scripts/check_workflow_trust.py+++ b/scripts/check_workflow_trust.py@@ -11,9 +11,23 @@ from pathlib import Pathdef _yaml_key(name: str) -> str:- """Return a pattern for a plain or simply quoted YAML mapping key."""+ """Return a pattern for equivalent plain, single-, or double-quoted keys."""escaped = re.escape(name)- return rf'(?:{escaped}|"{escaped}"|\'{escaped}\')'+ # YAML double-quoted scalars can spell any ASCII character through \x, \u,+ # or \U escapes. GitHub decodes those spellings before interpreting the+ # workflow, so the trust audit must do the same lexical matching. Without+ # this, e.g. "permi\x73sions" or "u\u0073es" bypasses the corresponding+ # permissions and dependency checks while remaining an ordinary Actions+ # key. The security-relevant key vocabulary is ASCII, so matching each+ # character's three exact escaped forms is sufficient and avoids a YAML+ # parser dependency in this early validation script.+ double_quoted = "".join(+ rf"(?:{re.escape(character)}|"+ rf"(?i:\\(?:x{ord(character):02x}|u{ord(character):04x}|"+ rf"U{ord(character):08x})))"+ for character in name+ )+ return rf'(?:{escaped}|"{double_quoted}"|\'{escaped}\')'ACTION_SHA_RE = re.compile(r"^[0-9a-f]{40}$")@@ -142,6 +156,21 @@ RUNS_ON_RE = re.compile(rf"^(\s*){_yaml_key('runs-on')}\s*:")TIMEOUT_RE = re.compile(rf"^(\s*){_yaml_key('timeout-minutes')}\s*:\s*(.*?)\s*$")+EXPLICIT_MAPPING_KEY_RE = re.compile(r"^\s*(?:-\s*)?\?\s")+ESCAPED_MAPPING_KEY_RE = re.compile(+ r'''^\s*(?:-\s*)?"(?:[^"\\]|\\.)*\\(?:[^"\\]|\\.)*"\s*:'''+)+LEADING_YAML_PROPERTY_RE = re.compile(+ r"^\s*(?:-\s*)?(?:[&*][A-Za-z0-9_-]+|![^\s,\]}]+)(?:\s|$)"+)+YAML_VALUE_PROPERTY_RE = re.compile(+ r'''^\s*(?:-\s*)?(?:[A-Za-z0-9_.-]+|"[^"]+"|'[^']+')'''+ r"\s*:\s*(?:[&*][A-Za-z0-9_-]+|![^\s,\]}]+)(?:\s|$)"+)+NONEMPTY_FLOW_MAPPING_RE = re.compile(+ r'''^\s*(?:-\s*)?(?:[A-Za-z0-9_.-]+|"[^"]+"|'[^']+')'''+ r"\s*:\s*\{(?!\s*\}\s*$)"+)# OIDC-backed delivery identity is only trusted when GitHub owns the runner# lifecycle. Keep the accepted image labels explicit and reviewable so a job# cannot move to persistent or dynamically selected compute without changing@@ -330,6 +359,103 @@ def _run_script_lines(lines: list[str], run_index: int) -> list[tuple[int, str]]return script+def _audit_yaml_trust_shape(path: Path, lines: list[str]) -> list[Finding]:+ """Reject YAML forms whose expansion can hide workflow trust structure."""+ findings: list[Finding] = []+ script_indexes = {+ script_index+ for index, line in enumerate(lines)+ if RUN_RE.match(line.split("#", 1)[0])+ for script_index, _ in _run_script_lines(lines, index)+ if script_index != index+ }+ structural_block_re = re.compile(+ rf"^\s*(?:{_yaml_key('jobs')}|{_yaml_key('steps')})\s*:\s*(.*?)\s*$"+ )++ for index, line in enumerate(lines):+ if index in script_indexes:+ continue+ code = line.split("#", 1)[0]+ if not code.strip():+ continue+ if EXPLICIT_MAPPING_KEY_RE.match(code):+ findings.append(+ Finding(+ path,+ index + 1,+ "explicit YAML mapping keys are prohibited because they can "+ "hide workflow trust fields",+ )+ )+ if ESCAPED_MAPPING_KEY_RE.match(code):+ findings.append(+ Finding(+ path,+ index + 1,+ "escaped YAML mapping keys are prohibited; use the canonical "+ "literal key spelling",+ )+ )+ if LEADING_YAML_PROPERTY_RE.match(code) or YAML_VALUE_PROPERTY_RE.search(code):+ findings.append(+ Finding(+ path,+ index + 1,+ "YAML anchors, aliases, and tags are prohibited because expanded "+ "nodes can bypass lexical workflow trust checks",+ )+ )+ structural_match = structural_block_re.match(code)+ if structural_match and structural_match.group(1):+ findings.append(+ Finding(+ path,+ index + 1,+ "jobs and steps must use block mappings and sequences so every "+ "trust-bearing field is directly auditable",+ )+ )+ if NONEMPTY_FLOW_MAPPING_RE.match(code) or re.match(r"^\s*-\s*\{", code):+ findings.append(+ Finding(+ path,+ index + 1,+ "non-empty flow mappings are prohibited because they can hide "+ "workflow trust fields on one line",+ )+ )++ jobs_index = next(+ (+ index+ for index, line in enumerate(lines)+ if JOBS_RE.match(line.split("#", 1)[0])+ ),+ None,+ )+ if jobs_index is not None:+ jobs_end = _mapping_end_index(lines, jobs_index)+ job_indent = _direct_mapping_indent(lines, jobs_index, jobs_end)+ if job_indent is not None:+ for index in range(jobs_index + 1, jobs_end):+ code = lines[index].split("#", 1)[0]+ if (+ code.strip()+ and _indent(code) == job_indent+ and not JOB_RE.match(code)+ ):+ findings.append(+ Finding(+ path,+ index + 1,+ "each job must use a canonical literal ID and block mapping",+ )+ )++ return findings++def _step_env_bindings(lines: list[str], run_index: int) -> dict[str, str]:"""Return literal step env names and values for a run declaration."""run_match = RUN_RE.match(lines[run_index])@@ -953,7 +1079,8 @@ def _audit_privileged_job_caches(path: Path, lines: list[str]) -> list[Finding]:def audit_workflow(path: Path) -> list[Finding]:lines = path.read_text(encoding="utf-8").splitlines()- findings = _audit_runner_job_timeouts(path, lines)+ findings = _audit_yaml_trust_shape(path, lines)+ findings.extend(_audit_runner_job_timeouts(path, lines))findings.extend(_audit_oidc_runner_trust(path, lines))findings.extend(_audit_privileged_job_caches(path, lines))findings.extend(_audit_workflow_run_trigger(path, lines))diff --git a/scripts/tests/test_workflow_trust.py b/scripts/tests/test_workflow_trust.pyindex a45e27bb2d..10fa259695 100644--- a/scripts/tests/test_workflow_trust.py+++ b/scripts/tests/test_workflow_trust.py@@ -216,6 +216,75 @@ jobs:)self.assertEqual(findings, [])+ def test_yaml_escaped_keys_cannot_bypass_trust_policy(self) -> None:+ findings = self.audit(+ r'''"o\x6e":+ "pull_request_targ\u0065t":+permissions: {}+"jo\u0062s":+ attest:+ "runs-\U0000006fn": self-hosted+ "timeout-\x6dinutes": 10+ "permi\x73sions":+ "id-\u0074oken": write+ steps:+ - "u\x73es": owner/action@main+ - "\U00000072un": echo "${{ inputs.name }}"+'''+ )+ self.assertTrue(+ any("pull_request_target is prohibited" in finding for finding in findings)+ )+ self.assertTrue(+ any("trusted delivery identity" in finding for finding in findings)+ )+ self.assertTrue(any("full commit SHA" in finding for finding in findings))+ self.assertTrue(+ any("must enter run scripts through env" in finding for finding in findings)+ )++ def test_yaml_expansion_and_flow_forms_cannot_hide_trust_fields(self) -> None:+ explicit = self.audit(+ '''permissions: {}+jobs:+ attest:+ runs-on: self-hosted+ timeout-minutes: 10+ ? "permissions"+ :+ id-token: write+ steps:+ - run: echo attest+'''+ )+ self.assertTrue(any("explicit YAML mapping keys" in item for item in explicit))++ anchored = self.audit(+ '''permissions: {}+jobs:+ attest: &shared_job+ runs-on: self-hosted+ timeout-minutes: 10+ permissions:+ id-token: write+ steps:+ - run: echo attest+ copied: *shared_job+'''+ )+ self.assertTrue(any("YAML anchors" in item for item in anchored))++ flow = self.audit(+ '''permissions: {}+jobs:+ test:+ runs-on: ubuntu-24.04+ timeout-minutes: 10+ steps: [{uses: owner/action@main}]+'''+ )+ self.assertTrue(any("block mappings and sequences" in item for item in flow))+def test_rejects_implicit_or_unjustified_checkout_credentials(self) -> None:omitted = self.audit(f"""permissions: {{}}