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 template injection in executable action inputs
pulse-triage[bot]22cc59cc2c6a
diff --git a/.github/workflows/README.md b/.github/workflows/README.mdindex 5a5fe8f3c5..e404963bf5 100644--- a/.github/workflows/README.md+++ b/.github/workflows/README.md@@ -49,6 +49,12 @@ be interpolated into the generated shell program. Outputs remain data evenwhen an intermediate step parsed or validated them, because later substitutionwould turn their value back into shell source.+The same boundary applies to action inputs that are themselves executable+source. The audit recognizes the script inputs of `actions/github-script`,+`azure/cli`, and `azure/powershell` and rejects workflow or event data embedded+in those programs. Pass the value through step `env` and read it from the+script's process environment instead.+Jobs that receive confidential repository secrets or a write-capable`GITHUB_TOKEN` do not restore or save caches. This includes setup-actiondependency caches, direct Actions caches, and external BuildKit cache imports:diff --git a/scripts/check_workflow_trust.py b/scripts/check_workflow_trust.pyindex 929af89b95..a332d5285e 100644--- a/scripts/check_workflow_trust.py+++ b/scripts/check_workflow_trust.py@@ -36,6 +36,7 @@ HOSTED_LATEST_RE = re.compile(r"\b(?:ubuntu|windows|macos)-latest\b")USES_RE = re.compile(rf"^\s*(?:-\s*)?{_yaml_key('uses')}\s*:\s*([^\s#]+)")+WITH_RE = re.compile(rf"^(\s*)(?:-\s*)?{_yaml_key('with')}\s*:\s*(.*)$")RUN_RE = re.compile(rf"^(\s*)(?:-\s*)?{_yaml_key('run')}\s*:\s*(.*)$")ENV_RE = re.compile(rf"^(\s*)(?:-\s*)?{_yaml_key('env')}\s*:\s*$")ENV_ENTRY_RE = re.compile(r"^\s*([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*?)\s*$")@@ -138,6 +139,15 @@ WRITE_PERMISSION_RE = re.compile(# configuration mechanism. Confidential credentials have no PR exception.NON_CONFIDENTIAL_PULL_REQUEST_SECRETS = frozenset({"PULSE_LICENSE_PUBLIC_KEY"})CHECKOUT_PREFIX = "actions/checkout@"+# These action inputs are programs, not ordinary data. GitHub's Actions+# CodeQL models treat the same actions as code-injection sinks: expression+# substitution happens before the action's JavaScript, PowerShell, or CLI+# interpreter receives the generated source.+GENERATED_CODE_ACTION_INPUTS = {+ "actions/github-script@": frozenset({"script"}),+ "azure/cli@": frozenset({"inlinescript"}),+ "azure/powershell@": frozenset({"inlinescript"}),+}# v7.0.1 includes checkout's fail-closed fork-PR protection for privileged# pull_request_target and workflow_run events. Keep this exact-pin allowlist# reviewable: a dependency refresh must not silently discard that boundary.@@ -295,22 +305,88 @@ def _permission_mapping_grants_scope_write(return False-def _checkout_block(lines: list[str], uses_index: int) -> list[tuple[int, str]]:- """Return lines belonging to the checkout step after its uses declaration."""+def _action_block(lines: list[str], uses_index: int) -> list[tuple[int, str]]:+ """Return every line belonging to the action step containing ``uses``."""uses_indent = _indent(lines[uses_index])+ step_start = uses_index+ step_indent = uses_indent+ if not lines[uses_index].lstrip().startswith("- "):+ for index in range(uses_index - 1, -1, -1):+ line = lines[index]+ if (+ line.strip()+ and _indent(line) < uses_indent+ and line.lstrip().startswith("- ")+ ):+ step_start = index+ step_indent = _indent(line)+ break+block: list[tuple[int, str]] = []- for index in range(uses_index + 1, len(lines)):+ for index in range(step_start, len(lines)):line = lines[index]stripped = line.strip()- if stripped and (- _indent(line) < uses_indent- or (_indent(line) == uses_indent and stripped.startswith("- "))+ if index != step_start and stripped and (+ _indent(line) < step_indent+ or (_indent(line) == step_indent and stripped.startswith("- "))):breakblock.append((index, line))return block+def _action_generated_code_lines(+ lines: list[str], uses_index: int, input_names: frozenset[str]+) -> list[tuple[int, str]]:+ """Return source lines from executable inputs to an action step."""+ uses_indent = _indent(lines[uses_index])+ field_indent = (+ uses_indent + 2+ if lines[uses_index].lstrip().startswith("- ")+ else uses_indent+ )+ block = _action_block(lines, uses_index)+ if not block:+ return []+ block_end = block[-1][0] + 1+ generated_lines: list[tuple[int, str]] = []++ for index, line in block:+ code = line.split("#", 1)[0]+ with_match = WITH_RE.match(code)+ if not with_match:+ continue+ with_field_indent = len(with_match.group(1)) + (+ 2 if code.lstrip().startswith("- ") else 0+ )+ if with_field_indent != field_indent:+ continue+ with_end = min(_mapping_end_index(lines, index), block_end)+ input_indent = _direct_mapping_indent(lines, index, with_end)+ if input_indent is None:+ continue+ input_re = re.compile(+ rf"^(\s*)(?:{'|'.join(_yaml_key(name) for name in input_names)})"+ r"\s*:\s*(.*)$",+ re.IGNORECASE,+ )+ for input_index in range(index + 1, with_end):+ input_match = input_re.match(lines[input_index])+ if not input_match or len(input_match.group(1)) != input_indent:+ continue+ value = input_match.group(2).strip()+ if value not in {"|", "|-", "|+", ">", ">-", ">+"}:+ generated_lines.append((input_index, input_match.group(2)))+ continue+ for script_index in range(input_index + 1, with_end):+ script_line = lines[script_index]+ if script_line.strip() and _indent(script_line) <= input_indent:+ break+ generated_lines.append((script_index, script_line))++ return generated_lines++def _runner_job_ranges(lines: list[str]) -> list[tuple[int, int, int]]:"""Return (start, end, indent) for each locally executed workflow job."""jobs_index = next(@@ -1018,7 +1094,7 @@ def _audit_privileged_job_caches(path: Path, lines: list[str]) -> list[Finding]:))elif dependency.startswith(SETUP_CACHE_ACTION_PREFIXES):- action_block = _checkout_block(lines, index)+ action_block = _action_block(lines, index)unsafe_cache_lines: list[int] = []for cache_index, cache_line in action_block:cache_match = CACHE_INPUT_RE.match(cache_line.split("#", 1)[0])@@ -1205,6 +1281,28 @@ def audit_workflow(path: Path) -> list[Finding]:dependency = match.group(1).strip("'\"")if dependency.startswith("./"):continue+ dependency_lower = dependency.lower()+ generated_input_names = next(+ (+ input_names+ for prefix, input_names in GENERATED_CODE_ACTION_INPUTS.items()+ if dependency_lower.startswith(prefix)+ ),+ None,+ )+ if generated_input_names:+ for script_index, script_line in _action_generated_code_lines(+ lines, index, generated_input_names+ ):+ if _is_untrusted_expression(script_line):+ findings.append(+ Finding(+ path,+ script_index + 1,+ "workflow data must enter executable action inputs "+ "through env instead of generated source",+ )+ )if has_workflow_run_trigger and dependency.lower().startswith(WORKFLOW_RUN_ARTIFACT_ACTION_PREFIX):@@ -1250,7 +1348,7 @@ def audit_workflow(path: Path) -> list[Finding]:"protection baseline",))- checkout_block = _checkout_block(lines, index)+ checkout_block = _action_block(lines, index)if has_workflow_run_trigger and any(WORKFLOW_RUN_CODE_REF_RE.search(block_line.split("#", 1)[0])for _, block_line in checkout_blockdiff --git a/scripts/tests/test_workflow_trust.py b/scripts/tests/test_workflow_trust.pyindex d5f0bbf4bc..042f7a521f 100644--- a/scripts/tests/test_workflow_trust.py+++ b/scripts/tests/test_workflow_trust.py@@ -776,6 +776,51 @@ jobs:5,)+ def test_rejects_template_data_in_executable_action_inputs(self) -> None:+ findings = self.audit(+ f"""permissions: {{}}+jobs:+ unsafe:+ runs-on: ubuntu-24.04+ timeout-minutes: 10+ steps:+ - uses: actions/github-script@{PIN}+ with:+ script: |+ const title = '${{{{ github.event.issue.title }}}}';+ const requested = '${{{{ inputs.name }}}}';+ - with:+ inlineScript: echo "${{{{ secrets.DEPLOY_TOKEN }}}}"+ uses: azure/cli@{PIN}+ - uses: azure/powershell@{PIN}+ with:+ inlineScript: |+ Write-Output '${{{{ steps.prepare.outputs.command }}}}'+"""+ )+ self.assertEqual(+ sum("executable action inputs" in finding for finding in findings),+ 4,+ )++ safe = self.audit(+ f"""permissions: {{}}+jobs:+ safe:+ runs-on: ubuntu-24.04+ timeout-minutes: 10+ steps:+ - uses: actions/github-script@{PIN}+ env:+ TITLE: ${{{{ github.event.issue.title }}}}+ with:+ script: |+ const title = process.env.TITLE;+ const source = '${{{{ github.sha }}}}';+"""+ )+ self.assertEqual(safe, [])+def test_rejects_step_and_job_outputs_in_generated_shell(self) -> None:findings = self.audit("""permissions: {}