Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesPull RequestsActionsSecurityInsightsSettings
✨ AI
More
claude/adoring-hopper-5x74bqclaude/affectionate-feynman-ykrf1hclaude/architecture-audit-design-wxprenclaude/build-status-update-3MXsfclaude/charming-meitner-mllb5rclaude/compare-gate-gluecron-s4mFQclaude/confident-faraday-tikcwbclaude/continue-work-XMTlIclaude/crontech-gluecron-deploy-7MIECclaude/crontech-platform-setup-SeKfwclaude/design-2026claude/ecstatic-ptolemy-jMdigclaude/enhance-github-integration-QNHdGclaude/fix-aa-loop-issue-PonMQclaude/fix-actions-and-processclaude/fix-desktop-errors-XqoW8claude/fix-red-workflowsclaude/fix-website-access-6FKJNclaude/gatetest-integration-hardeningclaude/github-audit-improvements-bDFr9claude/gluecron-launch-status-FoMRlclaude/hopeful-lamport-olfCTclaude/issue-to-pr-and-protectionsclaude/jolly-heisenberg-2sg1Qclaude/launch-preparation-QmTb6claude/new-session-xk1l7claude/plan-platform-architecture-kkN4yclaude/platform-analysis-roadmap-1nUGLclaude/platform-launch-assessment-8dWV8claude/polish-platform-release-AeDrUclaude/resume-previous-work-KzyLwclaude/review-crontech-handoff-qYEVqclaude/review-project-completeness-lHhS2claude/review-readme-docs-ulqPKclaude/serene-edison-rj87weclaude/setup-multi-repo-dev-BCwNQclaude/ship-fixes-and-tests-Jvz1cclaude/site-audit-competitive-pctlwgclaude/site-migration-vercel-XstpKclaude/standalone-product-repos-XHFTDcopilot/feat-smart-empty-states-keyboard-first-enhancementcopilot/feat-smart-morning-digest-review-context-restorecopilot/fix-and-process-workflowscopilot/update-ai-powered-code-reviewfeat/debt-mapfeat/push-policy-codeowners-hardeningfeat/smart-digest-contextfeat/stage-impactfeat/t1-secret-migrationfeat/u-polishfeat/w-self-hostfeat/w2-claude-configfix/agent-journey-orphan-sweepfix/audit-sweep-2026-07-26gatetest/auto-fix-1776586424172gatetest/auto-fix-1776586534814gatetest/auto-fix-1776590685143gatetest/auto-fix-1776590808199mainops/redeploy-retriggerstyle/dxt-cta-themeworktree-agent-a3377aad30d55da26worktree-agent-a7ef607b7ee1d6c74
webhook-ssrf-redirect.test.ts3.8 KB · 94 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
 * Webhook delivery SSRF: redirect hops and the DNS layer.
 *
 * Two independent bypasses of the guard that webhook delivery relies on:
 *
 * 1. `fetch()` defaults to `redirect: "follow"`. assertPublicUrl only ever saw
 *    the URL the user registered, so a genuinely public endpoint could answer
 *    302 → http://169.254.169.254/latest/meta-data/ and fetch would follow it.
 *    One redirect defeated the entire guard.
 *
 * 2. resolvesToPrivate() — the DNS layer that catches a public-looking
 *    hostname pointing at a private address — existed, was fully unit-tested,
 *    and had ZERO production callers. Only src/__tests__/ssrf-guard.test.ts
 *    imported it. `evil.example.com A 127.0.0.1` passed the literal check.
 *
 * These assertions are structural. A functional test would need to bind a
 * redirecting server on localhost, but the guard deliberately default-allows
 * private addresses under the test env, so the harness would have to disable
 * the very behaviour under test. The guard's own address-classification logic
 * is already covered functionally by ssrf-guard.test.ts.
 */

import { describe, expect, it } from "bun:test";
import { readFileSync } from "fs";

const SRC = readFileSync("src/lib/webhook-delivery.ts", "utf8");
const fn = SRC.slice(
  SRC.indexOf("async function deliverFollowingRedirects"),
  SRC.indexOf("// ---", SRC.indexOf("async function deliverFollowingRedirects"))
);

describe("redirects cannot escape the guard", () => {
  it("never lets fetch follow redirects itself", () => {
    expect(fn).toContain('redirect: "manual"');
  });

  it("no bare fetch(row.url) with default redirect handling remains", () => {
    // The original call site. If this reappears the guard is bypassable again.
    expect(SRC).not.toMatch(/await fetch\(row\.url, \{\s*\n\s*method: "POST"/);
  });

  it("re-validates the URL on every hop, not just the first", () => {
    // assertPublicUrl must be inside the loop.
    const loopStart = fn.indexOf("for (let hop");
    const guardCall = fn.indexOf("assertPublicUrl(url)");
    expect(loopStart).toBeGreaterThan(-1);
    expect(guardCall).toBeGreaterThan(loopStart);
  });

  it("bounds the hop count so a redirect cycle cannot spin", () => {
    expect(SRC).toContain("MAX_REDIRECTS");
    expect(fn).toContain("hop <= MAX_REDIRECTS");
    expect(fn).toContain("more than ${MAX_REDIRECTS} redirects");
  });

  it("resolves a relative Location against the current hop", () => {
    // `Location: /latest/meta-data/` on a redirect must not be treated as
    // an absolute URL or silently dropped.
    expect(fn).toContain("new URL(location, url)");
  });

  it("treats a 3xx with no Location as a terminal response", () => {
    expect(fn).toContain("if (!location) return { status: res.status }");
  });
});

describe("the DNS layer is actually wired in", () => {
  it("webhook delivery calls resolvesToPrivate", () => {
    // It had zero production callers before this.
    expect(SRC).toContain("resolvesToPrivate");
    expect(fn).toContain("await resolvesToPrivate(guard.url.hostname)");
  });

  it("checks DNS before issuing the request", () => {
    const dns = fn.indexOf("resolvesToPrivate");
    const req = fn.indexOf("await fetch(url");
    expect(dns).toBeLessThan(req);
  });

  it("honours the same allow-private escape hatch as assertPublicUrl", () => {
    // Without this the DNS layer blocks 127.0.0.1 under SSRF_ALLOW_PRIVATE=1
    // and in the test env, breaking suites that point webhooks at a local
    // Bun.serve() — which is exactly what it did on the first attempt.
    expect(fn).toContain("ssrfPrivateAllowed()");
    expect(fn).toContain("enforcing &&");
  });
});

describe("blocked deliveries are reported as blocked", () => {
  it("surfaces an SSRF block distinctly from an HTTP error", () => {
    expect(SRC).toContain("blockedReason");
    expect(SRC).toContain("(SSRF protection)");
  });
});