@openwop/openwop-conformance 1.140.0 → 1.142.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/lib/spec-coherence.js +36 -9
- package/package.json +1 -1
- package/schemas/CORPUS-STAMP.json +2 -2
- package/src/lib/spec-coherence-registry.test.ts +22 -1
- package/src/lib/spec-coherence.ts +37 -9
- package/src/lib/webhook-receiver.test.ts +69 -1
- package/src/lib/webhook-receiver.ts +70 -0
- package/src/scenarios/webhook-signed-delivery.test.ts +134 -11
package/README.md
CHANGED
|
@@ -79,6 +79,8 @@ Run `npm run test` for normal CI cadence; `npm run test:strict` when claiming fu
|
|
|
79
79
|
| `OPENWOP_OTEL_COLLECTOR_GRPC_PORT=4317` | Bind the OTLP/gRPC collector on a specific port (default `4317`, OTLP/gRPC convention). The host MUST be configured with `OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:<port>` AND `OTEL_EXPORTER_OTLP_PROTOCOL=grpc`. |
|
|
80
80
|
| `OPENWOP_OTEL_COLLECTOR_PORT=14318` | Bind the OTel collector on a specific port (default `4318`). The host MUST be configured with `OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:<port>`. |
|
|
81
81
|
| `OPENWOP_WEBHOOK_ALLOW_PRIVATE=true` | Relaxes the webhook egress guard for the loopback test receiver used by `webhook-signed-delivery.test.ts`, `webhook-negative.test.ts`, and `replay-fanout-suppression.test.ts`. **The receiver is `http://127.0.0.1:{port}/`, which `webhooks.md` forbids three separate times, and the opt-in MUST relax all three to be witnessable:** (1) the **scheme** check — §"SSRF protection" bullet 1 rejects non-`https://`, and this gate fires FIRST on a host that validates scheme before address; (2) the **registration-time** address check — §"SSRF protection"; and (3) **delivery-time re-resolution** — §"Delivery-time egress validation (RFC 0093)". Gates 2 and 3 are independent MUSTs at different layers, so an opt-in reaching only one layer **cannot** produce a witness: delivery-only leaves registration returning `400 webhook_url_rejected`, registration-only leaves the dispatcher refusing to connect. A host whose opt-in reaches one layer is **not** non-conformant — it cannot witness these scenarios, which is a property of the test posture and not of its webhook signing. The scheme gate went unstated here until 2026-08-25; a tier-2 host validating scheme-then-address was blocked by a gate the documented contract never named. Relaxing gates 2 and 3 is **test-only posture** — see `SECURITY/threat-model-secret-leakage.md` §4.9 for why a registration-time relaxation is the more dangerous of the two. When the host rejects, the scenario records `blocked` (RFC 0148 §A), not a pass. |
|
|
82
|
+
| `OPENWOP_WEBHOOK_RECEIVER_URL=<https-url>` | **The route to a webhook witness that relaxes nothing.** A host refusing the loopback receiver on *two* independent grounds — private address **and** non-`https:` — cannot be unblocked by `OPENWOP_WEBHOOK_ALLOW_PRIVATE`, because the scheme arm still stands. This supplies **the public `https:` front for THIS SUITE'S OWN receiver** (tunnel / TLS-terminating proxy), never an arbitrary endpoint: the scenario asserts on what *this process* received, so pointing registration elsewhere makes every header assertion vacuous while the row turns green. Zero deliveries with it set is a **hard failure**, never a skip. Preferred over the flag — it waives nothing and writes no durable subscription row aimed at a private address (`SECURITY/threat-model-secret-leakage.md` §4.9). Pair with `OPENWOP_WEBHOOK_RECEIVER_PORT`. |
|
|
83
|
+
| `OPENWOP_WEBHOOK_RECEIVER_PORT=<port>` | Pins the in-process webhook receiver to a known port instead of an ephemeral one. Required in practice by `OPENWOP_WEBHOOK_RECEIVER_URL`: a tunnel must be aimed at a port known **in advance**, and the receiver binds `0` by default. Unset ⇒ ephemeral, as before. |
|
|
82
84
|
| `OPENWOP_MCP_FAKE_SERVER=true` | Boots the synthetic MCP peer for `mcp-tool-roundtrip.test.ts`. |
|
|
83
85
|
| `OPENWOP_MCP_REAL_SERVER_URL=<base-url>` | Points the MCP wire-shape probe at a real MCP server. The probe POSTs JSON-RPC and reads a single-JSON response — matches MCP's `streamable-http` transport in single-response mode. **Does NOT support** stdio transport (which is what most `modelcontextprotocol/servers` references default to) or SSE-streamed responses; an operator collecting interop evidence today runs a custom `StreamableHTTPServerTransport`-style server that returns a single JSON body per request. Adding SSE-frame parsing is tracked in `docs/PROTOCOL-GAP-CLOSURE-PLAN.md` Track 6. Assertions relax to shape-only. When both this and `OPENWOP_MCP_FAKE_SERVER` are set, the real URL wins. Phase 3 T3.4 interop-evidence path. |
|
|
84
86
|
| `OPENWOP_A2A_FAKE_PEER=true` | Boots the synthetic A2A peer for `a2a-task-roundtrip.test.ts`. |
|
|
@@ -55,16 +55,29 @@
|
|
|
55
55
|
* run and fails when the two disagree, which is the only thing that makes a
|
|
56
56
|
* hand-maintained set trustworthy.
|
|
57
57
|
*
|
|
58
|
-
* ## What is deliberately NOT here
|
|
58
|
+
* ## What is deliberately NOT here — and why it is a Set, not a sentence
|
|
59
59
|
*
|
|
60
|
-
* Seven scenarios gate on `V1_DIR` **and** drive the host
|
|
61
|
-
*
|
|
62
|
-
* `
|
|
63
|
-
* `
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
60
|
+
* Seven scenarios gate on `V1_DIR` **and** drive the host. They assert
|
|
61
|
+
* advertised host behaviour that could not be exercised because a dependency
|
|
62
|
+
* was unavailable — `blocked`, exactly as §A defines it. Classifying them
|
|
63
|
+
* `inapplicable` would tell a host "this does not apply to you" about a
|
|
64
|
+
* requirement that does.
|
|
65
|
+
*
|
|
66
|
+
* They are listed in `SPEC_COHERENCE_EXCLUDED` below rather than named in this
|
|
67
|
+
* prose, because naming them here made this file lie to a reasonable reader.
|
|
68
|
+
* A peer checking membership with `grep -c "<scenario>" spec-coherence.ts` got
|
|
69
|
+
* **1 hit for all three** of the ones the prose named — from this very
|
|
70
|
+
* paragraph — and was one step from reporting that host-behaviour rows had
|
|
71
|
+
* been downgraded to "does not apply to you" as a credit. They caught it only
|
|
72
|
+
* because two counts disagreed: 28 members and those 7 included cannot both be
|
|
73
|
+
* true.
|
|
74
|
+
*
|
|
75
|
+
* **A text search over this file still matches both sets** — that is inherent
|
|
76
|
+
* to any file that names what it excludes. So the exclusions are now an
|
|
77
|
+
* exported Set with the same standing as the inclusions: membership has a
|
|
78
|
+
* programmatic answer, `spec-coherence-registry.test.ts` asserts the two are
|
|
79
|
+
* disjoint and jointly exhaustive over the `V1_DIR`-gated files, and a comment
|
|
80
|
+
* is no longer the only place the exclusion reason lives.
|
|
68
81
|
*/
|
|
69
82
|
/** Scenarios whose subject is the corpus. Kept honest by `spec-coherence-registry.test.ts`. */
|
|
70
83
|
export const SPEC_COHERENCE_SCENARIOS = new Set([
|
|
@@ -97,6 +110,20 @@ export const SPEC_COHERENCE_SCENARIOS = new Set([
|
|
|
97
110
|
'workflow-chain-internal-flag.test.ts',
|
|
98
111
|
'workload-identity-profile.test.ts',
|
|
99
112
|
]);
|
|
113
|
+
/**
|
|
114
|
+
* Scenarios that gate on `V1_DIR` **and** drive the host, so their `blocked` is
|
|
115
|
+
* honest: advertised behaviour a missing dependency prevented exercising.
|
|
116
|
+
* Exported so membership is checkable in code rather than inferred from prose.
|
|
117
|
+
*/
|
|
118
|
+
export const SPEC_COHERENCE_EXCLUDED = new Set([
|
|
119
|
+
'artifact-type-registration-source.test.ts',
|
|
120
|
+
'artifact-type-store-emission.test.ts',
|
|
121
|
+
'data-residency-admission.test.ts',
|
|
122
|
+
'profile-discovery-core-alias.test.ts',
|
|
123
|
+
'replay-side-effect-suppression.test.ts',
|
|
124
|
+
'workflow-chain-deferred-parameters.test.ts',
|
|
125
|
+
'workflow-variable-format.test.ts',
|
|
126
|
+
]);
|
|
100
127
|
/** The reason recorded on such a row, written for the host operator reading it. */
|
|
101
128
|
export const SPEC_COHERENCE_DETAIL = 'inapplicable to any host: this scenario reads spec/v1/ to check the SPEC corpus is internally coherent and asserts nothing about a host. '
|
|
102
129
|
+ 'The published tarball does not bundle spec/v1/ (see lib/paths.ts), so it does not run here. '
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_comment": "Provenance of this vendored schemas/ copy. See conformance/README.md \u00a7\"Resolving the contract\". Compare against the stamp in your installed @openwop/openwop-conformance to detect a stale hand-copied contract.",
|
|
3
|
-
"suiteVersion": "1.
|
|
4
|
-
"corpusCommit": "
|
|
3
|
+
"suiteVersion": "1.142.0",
|
|
4
|
+
"corpusCommit": "aced8a6a82d751394c3b299fa4602b9dd5cc9971"
|
|
5
5
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import { describe, expect, it } from 'vitest';
|
|
15
15
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
16
16
|
import { join } from 'node:path';
|
|
17
|
-
import { SPEC_COHERENCE_SCENARIOS, SPEC_COHERENCE_DETAIL } from './spec-coherence.js';
|
|
17
|
+
import { SPEC_COHERENCE_SCENARIOS, SPEC_COHERENCE_DETAIL, SPEC_COHERENCE_EXCLUDED } from './spec-coherence.js';
|
|
18
18
|
import { resolveFileRecord } from './scenario-disposition.js';
|
|
19
19
|
|
|
20
20
|
const SCENARIOS = new URL('../scenarios/', import.meta.url).pathname;
|
|
@@ -41,6 +41,27 @@ describe('SPEC_COHERENCE_SCENARIOS is derivable, not asserted', () => {
|
|
|
41
41
|
expect(listed.filter((f) => !pure.includes(f)), 'in the registry but no longer qualifies — it now drives a host, or stopped reading spec/v1').toEqual([]);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
+
it('the EXCLUDED set is exactly the host-touching ones — the exclusions are checked, not asserted in prose', () => {
|
|
45
|
+
// These used to live only in a docblock sentence. A peer grepping this file
|
|
46
|
+
// for membership matched that sentence and read all three named scenarios
|
|
47
|
+
// as members — the opposite of the truth, and the dangerous direction: it
|
|
48
|
+
// would mean host-behaviour rows downgraded to "does not apply to you" as a
|
|
49
|
+
// credit. Naming them in prose made the file lie to a reasonable reader.
|
|
50
|
+
const { hostTouching } = derive();
|
|
51
|
+
expect([...SPEC_COHERENCE_EXCLUDED].sort()).toEqual(hostTouching);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('the two sets are disjoint and jointly exhaustive over the V1_DIR-gated files', () => {
|
|
55
|
+
// Disjoint: no scenario can be both "does not apply to any host" and
|
|
56
|
+
// "applies but was unwitnessable". Exhaustive: every V1_DIR-gated file has
|
|
57
|
+
// a decided disposition, so none falls back to the unclassified marker.
|
|
58
|
+
const { pure, hostTouching } = derive();
|
|
59
|
+
const overlap = [...SPEC_COHERENCE_SCENARIOS].filter((f) => SPEC_COHERENCE_EXCLUDED.has(f));
|
|
60
|
+
expect(overlap, 'a scenario cannot be both inapplicable-to-all-hosts and blocked-for-this-host').toEqual([]);
|
|
61
|
+
const union = new Set([...SPEC_COHERENCE_SCENARIOS, ...SPEC_COHERENCE_EXCLUDED]);
|
|
62
|
+
expect([...union].sort()).toEqual([...pure, ...hostTouching].sort());
|
|
63
|
+
});
|
|
64
|
+
|
|
44
65
|
it('excludes the host-touching ones, which are honestly `blocked`', () => {
|
|
45
66
|
// These assert ADVERTISED behaviour that a missing dependency prevented
|
|
46
67
|
// exercising — RFC 0148 §A's definition of `blocked`, verbatim. Calling
|
|
@@ -55,16 +55,29 @@
|
|
|
55
55
|
* run and fails when the two disagree, which is the only thing that makes a
|
|
56
56
|
* hand-maintained set trustworthy.
|
|
57
57
|
*
|
|
58
|
-
* ## What is deliberately NOT here
|
|
58
|
+
* ## What is deliberately NOT here — and why it is a Set, not a sentence
|
|
59
59
|
*
|
|
60
|
-
* Seven scenarios gate on `V1_DIR` **and** drive the host
|
|
61
|
-
*
|
|
62
|
-
* `
|
|
63
|
-
* `
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
60
|
+
* Seven scenarios gate on `V1_DIR` **and** drive the host. They assert
|
|
61
|
+
* advertised host behaviour that could not be exercised because a dependency
|
|
62
|
+
* was unavailable — `blocked`, exactly as §A defines it. Classifying them
|
|
63
|
+
* `inapplicable` would tell a host "this does not apply to you" about a
|
|
64
|
+
* requirement that does.
|
|
65
|
+
*
|
|
66
|
+
* They are listed in `SPEC_COHERENCE_EXCLUDED` below rather than named in this
|
|
67
|
+
* prose, because naming them here made this file lie to a reasonable reader.
|
|
68
|
+
* A peer checking membership with `grep -c "<scenario>" spec-coherence.ts` got
|
|
69
|
+
* **1 hit for all three** of the ones the prose named — from this very
|
|
70
|
+
* paragraph — and was one step from reporting that host-behaviour rows had
|
|
71
|
+
* been downgraded to "does not apply to you" as a credit. They caught it only
|
|
72
|
+
* because two counts disagreed: 28 members and those 7 included cannot both be
|
|
73
|
+
* true.
|
|
74
|
+
*
|
|
75
|
+
* **A text search over this file still matches both sets** — that is inherent
|
|
76
|
+
* to any file that names what it excludes. So the exclusions are now an
|
|
77
|
+
* exported Set with the same standing as the inclusions: membership has a
|
|
78
|
+
* programmatic answer, `spec-coherence-registry.test.ts` asserts the two are
|
|
79
|
+
* disjoint and jointly exhaustive over the `V1_DIR`-gated files, and a comment
|
|
80
|
+
* is no longer the only place the exclusion reason lives.
|
|
68
81
|
*/
|
|
69
82
|
|
|
70
83
|
/** Scenarios whose subject is the corpus. Kept honest by `spec-coherence-registry.test.ts`. */
|
|
@@ -99,6 +112,21 @@ export const SPEC_COHERENCE_SCENARIOS: ReadonlySet<string> = new Set([
|
|
|
99
112
|
'workload-identity-profile.test.ts',
|
|
100
113
|
]);
|
|
101
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Scenarios that gate on `V1_DIR` **and** drive the host, so their `blocked` is
|
|
117
|
+
* honest: advertised behaviour a missing dependency prevented exercising.
|
|
118
|
+
* Exported so membership is checkable in code rather than inferred from prose.
|
|
119
|
+
*/
|
|
120
|
+
export const SPEC_COHERENCE_EXCLUDED: ReadonlySet<string> = new Set([
|
|
121
|
+
'artifact-type-registration-source.test.ts',
|
|
122
|
+
'artifact-type-store-emission.test.ts',
|
|
123
|
+
'data-residency-admission.test.ts',
|
|
124
|
+
'profile-discovery-core-alias.test.ts',
|
|
125
|
+
'replay-side-effect-suppression.test.ts',
|
|
126
|
+
'workflow-chain-deferred-parameters.test.ts',
|
|
127
|
+
'workflow-variable-format.test.ts',
|
|
128
|
+
]);
|
|
129
|
+
|
|
102
130
|
/** The reason recorded on such a row, written for the host operator reading it. */
|
|
103
131
|
export const SPEC_COHERENCE_DETAIL =
|
|
104
132
|
'inapplicable to any host: this scenario reads spec/v1/ to check the SPEC corpus is internally coherent and asserts nothing about a host. '
|
|
@@ -12,13 +12,14 @@
|
|
|
12
12
|
* @see webhook-receiver.ts, spec/v1/webhooks.md §"Delivery headers"
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { describe, it, expect } from 'vitest';
|
|
15
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
16
16
|
import { createHmac } from 'node:crypto';
|
|
17
17
|
import {
|
|
18
18
|
SIGNATURE_PREFIX,
|
|
19
19
|
createReceiverState,
|
|
20
20
|
verifyWebhookDelivery,
|
|
21
21
|
signPayload,
|
|
22
|
+
resolveRegistrationUrl,
|
|
22
23
|
} from './webhook-receiver.js';
|
|
23
24
|
|
|
24
25
|
const SECRET = 'shhh-not-a-real-secret';
|
|
@@ -74,3 +75,70 @@ describe('webhook-receiver: the X-openwop-Signature prefix follows the spec', ()
|
|
|
74
75
|
expect(algorithmHeader).toBe('v1');
|
|
75
76
|
});
|
|
76
77
|
});
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* `OPENWOP_WEBHOOK_RECEIVER_URL` validation.
|
|
81
|
+
*
|
|
82
|
+
* Each case names the gate it is about, taken from `webhooks.md`, rather than
|
|
83
|
+
* restating the implementation: the point of the variable is to clear all three
|
|
84
|
+
* SSRF gates honestly, so a value that cannot clear one of them is an operator
|
|
85
|
+
* error the suite must refuse LOUDLY. A skip here would hide a
|
|
86
|
+
* misconfiguration behind a disposition that reads as "the host could not be
|
|
87
|
+
* exercised", which is a claim about the host and would be false.
|
|
88
|
+
*/
|
|
89
|
+
describe('resolveRegistrationUrl — OPENWOP_WEBHOOK_RECEIVER_URL', () => {
|
|
90
|
+
const LOCAL = 'http://127.0.0.1:54321/';
|
|
91
|
+
const saved = process.env.OPENWOP_WEBHOOK_RECEIVER_URL;
|
|
92
|
+
const set = (v: string | undefined) => {
|
|
93
|
+
if (v === undefined) delete process.env.OPENWOP_WEBHOOK_RECEIVER_URL;
|
|
94
|
+
else process.env.OPENWOP_WEBHOOK_RECEIVER_URL = v;
|
|
95
|
+
};
|
|
96
|
+
afterEach(() => set(saved));
|
|
97
|
+
|
|
98
|
+
it('unset ⇒ registers the local receiver unchanged, not tunnelled', () => {
|
|
99
|
+
set(undefined);
|
|
100
|
+
expect(resolveRegistrationUrl(LOCAL)).toEqual({ url: LOCAL, tunnelled: false });
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('whitespace-only is treated as unset rather than as a malformed URL', () => {
|
|
104
|
+
set(' ');
|
|
105
|
+
expect(resolveRegistrationUrl(LOCAL)).toEqual({ url: LOCAL, tunnelled: false });
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('a public https front is used for registration and marked tunnelled', () => {
|
|
109
|
+
set('https://tunnel.example.com/hook');
|
|
110
|
+
expect(resolveRegistrationUrl(LOCAL)).toEqual({
|
|
111
|
+
url: 'https://tunnel.example.com/hook',
|
|
112
|
+
tunnelled: true,
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('rejects http: — cannot clear gate 1 (webhooks.md §"Register": url MUST be https)', () => {
|
|
117
|
+
set('http://tunnel.example.com/hook');
|
|
118
|
+
expect(() => resolveRegistrationUrl(LOCAL)).toThrow(/MUST be https/i);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it.each([
|
|
122
|
+
['loopback name', 'https://localhost/hook'],
|
|
123
|
+
['loopback v4', 'https://127.0.0.1/hook'],
|
|
124
|
+
['RFC1918 10/8', 'https://10.1.2.3/hook'],
|
|
125
|
+
['RFC1918 192.168/16', 'https://192.168.1.9/hook'],
|
|
126
|
+
['RFC1918 172.16/12', 'https://172.20.0.5/hook'],
|
|
127
|
+
['link-local', 'https://169.254.169.254/hook'],
|
|
128
|
+
])('rejects %s — cannot clear gate 2 (registration-time address check)', (_label, url) => {
|
|
129
|
+
set(url);
|
|
130
|
+
expect(() => resolveRegistrationUrl(LOCAL)).toThrow(/publicly-resolvable/i);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('rejects a value that is not a URL at all', () => {
|
|
134
|
+
set('not a url');
|
|
135
|
+
expect(() => resolveRegistrationUrl(LOCAL)).toThrow(/not a valid URL/i);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('does not reject a public host that merely LOOKS private (172.32 is public)', () => {
|
|
139
|
+
// 172.16.0.0/12 ends at 172.31.255.255. A naive /^172\./ check would
|
|
140
|
+
// reject this and send an operator hunting a nonexistent misconfiguration.
|
|
141
|
+
set('https://172.32.0.1/hook');
|
|
142
|
+
expect(resolveRegistrationUrl(LOCAL).tunnelled).toBe(true);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -184,3 +184,73 @@ export async function discoverOwnedTenant(
|
|
|
184
184
|
// Pre-S29 hosts that copied the suite's misnamed field: tolerated, never asserted.
|
|
185
185
|
return typeof owner?.tenantId === 'string' && owner.tenantId.length > 0 ? owner.tenantId : undefined;
|
|
186
186
|
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* The public `https:` front for the conformance webhook receiver, when the operator
|
|
190
|
+
* has wired one (`OPENWOP_WEBHOOK_RECEIVER_URL`).
|
|
191
|
+
*
|
|
192
|
+
* This does NOT point the host at some third-party endpoint. The delivery must
|
|
193
|
+
* still land on the local `startReceiver()` server, because every assertion in
|
|
194
|
+
* the scenario reads `receiver.received` — an IN-PROCESS array. Registering an
|
|
195
|
+
* arbitrary URL would send the delivery somewhere the suite cannot observe, and
|
|
196
|
+
* the row would turn green while every header and HMAC assertion went vacuous.
|
|
197
|
+
* That is the precise defect this suite exists to catch, so the variable is
|
|
198
|
+
* specified as "a tunnel or TLS-terminating proxy in front of THIS receiver",
|
|
199
|
+
* never "an endpoint of your choosing".
|
|
200
|
+
*
|
|
201
|
+
* The suite cannot verify that the tunnel actually fronts this process — that
|
|
202
|
+
* is the operator's contract. What it CAN do is refuse to let a mis-wired
|
|
203
|
+
* tunnel look like a pass: with the variable set, zero observed deliveries is a
|
|
204
|
+
* hard assertion failure, never a soft-skip (see the delivery assertion below).
|
|
205
|
+
*
|
|
206
|
+
* Validation is deliberately strict and fails LOUDLY rather than skipping: a
|
|
207
|
+
* malformed value is an operator error, and turning it into a `blocked` row
|
|
208
|
+
* would hide the misconfiguration behind a disposition that reads as
|
|
209
|
+
* "the host could not be exercised".
|
|
210
|
+
*/
|
|
211
|
+
export function resolveRegistrationUrl(localUrl: string): { url: string; tunnelled: boolean } {
|
|
212
|
+
const raw = process.env.OPENWOP_WEBHOOK_RECEIVER_URL?.trim();
|
|
213
|
+
if (!raw) return { url: localUrl, tunnelled: false };
|
|
214
|
+
|
|
215
|
+
let parsed: URL;
|
|
216
|
+
try {
|
|
217
|
+
parsed = new URL(raw);
|
|
218
|
+
} catch {
|
|
219
|
+
throw new Error(
|
|
220
|
+
`OPENWOP_WEBHOOK_RECEIVER_URL is not a valid URL: ${JSON.stringify(raw)}`,
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Must clear gate 1 (scheme). An `http:` front cannot satisfy a host that
|
|
225
|
+
// validates scheme before address, which is the ordering that made the
|
|
226
|
+
// ALLOW_PRIVATE flag insufficient in the first place.
|
|
227
|
+
if (parsed.protocol !== 'https:') {
|
|
228
|
+
throw new Error(
|
|
229
|
+
`OPENWOP_WEBHOOK_RECEIVER_URL MUST be https: (got ${parsed.protocol}). ` +
|
|
230
|
+
'A plain-http front cannot clear the scheme gate, so it cannot witness this scenario.',
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Must clear gate 2 (registration-time address check). A loopback or private
|
|
235
|
+
// hostname here is just the local URL wearing a different scheme — it would
|
|
236
|
+
// be rejected for the same reason, and the operator would read the resulting
|
|
237
|
+
// failure as a host defect rather than as their own misconfiguration.
|
|
238
|
+
const host = parsed.hostname.toLowerCase();
|
|
239
|
+
const isLoopback =
|
|
240
|
+
host === 'localhost' || host === '::1' || host.startsWith('127.');
|
|
241
|
+
const isPrivate =
|
|
242
|
+
/^10\./.test(host) ||
|
|
243
|
+
/^192\.168\./.test(host) ||
|
|
244
|
+
/^172\.(1[6-9]|2\d|3[01])\./.test(host) ||
|
|
245
|
+
/^169\.254\./.test(host) ||
|
|
246
|
+
/^(fc|fd)/.test(host);
|
|
247
|
+
if (isLoopback || isPrivate) {
|
|
248
|
+
throw new Error(
|
|
249
|
+
`OPENWOP_WEBHOOK_RECEIVER_URL MUST be a publicly-resolvable host (got ${parsed.hostname}). ` +
|
|
250
|
+
'It is the PUBLIC front for the local receiver — a tunnel or TLS-terminating proxy — ' +
|
|
251
|
+
'not the receiver address itself.',
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return { url: raw, tunnelled: true };
|
|
256
|
+
}
|
|
@@ -63,6 +63,32 @@
|
|
|
63
63
|
* writes a durable subscription row that survives the flag being turned
|
|
64
64
|
* back off.
|
|
65
65
|
*
|
|
66
|
+
* `OPENWOP_WEBHOOK_RECEIVER_URL` — the route that relaxes NOTHING (added
|
|
67
|
+
* 2026-08-28). Set it to a public `https:` tunnel or TLS-terminating proxy
|
|
68
|
+
* standing in front of this scenario's own local receiver. Registration then
|
|
69
|
+
* uses that URL and all three gates are satisfied honestly: the scheme is
|
|
70
|
+
* `https:`, the registered address is public, and delivery-time re-resolution
|
|
71
|
+
* resolves a public address it is entitled to connect to. No guard is waived,
|
|
72
|
+
* no durable private-address row is written, and §4.9's hazard does not arise.
|
|
73
|
+
*
|
|
74
|
+
* This exists because the ALLOW_PRIVATE contract above is unsatisfiable for a
|
|
75
|
+
* host whose guard is strongest at registration time: reported by a tier-2
|
|
76
|
+
* host (2026-08-25) whose `classifyUrl` rejects on scheme AND address as two
|
|
77
|
+
* independent grounds returning one code, so relaxing the address check leaves
|
|
78
|
+
* the scheme check standing and the row `blocked` either way. Such a host is
|
|
79
|
+
* conformant and was simply unmeasurable. It is now measurable.
|
|
80
|
+
*
|
|
81
|
+
* Two things it deliberately does NOT do. It is not "register any endpoint":
|
|
82
|
+
* the assertions read an in-process array, so a third-party destination would
|
|
83
|
+
* turn the row green while every assertion went vacuous — see
|
|
84
|
+
* `resolveRegistrationUrl`. And it does not soften a rejection into a skip: a
|
|
85
|
+
* host that refuses a legitimate public https destination FAILS, because
|
|
86
|
+
* `blocked` would let it record a missing precondition forever instead of the
|
|
87
|
+
* finding it earned.
|
|
88
|
+
*
|
|
89
|
+
* Paired with a positive control (bottom of this file) so the tunnelled pass
|
|
90
|
+
* is attributable to a guard that works rather than to a guard that is absent.
|
|
91
|
+
*
|
|
66
92
|
* When the host rejects with `400 webhook_url_rejected`, this scenario
|
|
67
93
|
* records `blocked` (RFC 0148 §A) — NOT a pass. Under a plain
|
|
68
94
|
* `vitest run` the console still prints "1 passed", because that is
|
|
@@ -81,7 +107,7 @@ import { driver } from '../lib/driver.js';
|
|
|
81
107
|
import { discoveryFamilies } from '../lib/discovery-capabilities.js';
|
|
82
108
|
import { pollUntilTerminal } from '../lib/polling.js';
|
|
83
109
|
import { isFixtureAdvertised } from '../lib/fixtures.js';
|
|
84
|
-
import { discoverOwnedTenant } from '../lib/webhook-receiver.js';
|
|
110
|
+
import { discoverOwnedTenant, resolveRegistrationUrl } from '../lib/webhook-receiver.js';
|
|
85
111
|
|
|
86
112
|
interface DeliveredRequest {
|
|
87
113
|
readonly headers: Record<string, string>;
|
|
@@ -105,7 +131,16 @@ async function startReceiver(): Promise<{ server: Server; url: string; received:
|
|
|
105
131
|
res.end();
|
|
106
132
|
});
|
|
107
133
|
});
|
|
108
|
-
|
|
134
|
+
// Port 0 (ephemeral) by default — nothing outside this process needs to find
|
|
135
|
+
// it. But OPENWOP_WEBHOOK_RECEIVER_URL fronts THIS receiver through a tunnel,
|
|
136
|
+
// and a tunnel has to be pointed at a port the operator knows in ADVANCE. An
|
|
137
|
+
// ephemeral port makes that variable unusable by anyone not reading the port
|
|
138
|
+
// out of a running process — a gap found by standing up a real TLS front and
|
|
139
|
+
// trying to use the feature, not by reading the code. OPENWOP_WEBHOOK_RECEIVER_PORT
|
|
140
|
+
// pins it so `ngrok http <port>` (or a proxy) has a stable target.
|
|
141
|
+
const pinned = Number(process.env['OPENWOP_WEBHOOK_RECEIVER_PORT'] ?? '');
|
|
142
|
+
const bindPort = Number.isInteger(pinned) && pinned > 0 && pinned < 65536 ? pinned : 0;
|
|
143
|
+
await new Promise<void>((resolve) => server.listen(bindPort, '127.0.0.1', () => resolve()));
|
|
109
144
|
const addr = server.address();
|
|
110
145
|
if (typeof addr !== 'object' || addr === null) throw new Error('receiver address unavailable');
|
|
111
146
|
return { server, url: `http://127.0.0.1:${addr.port}/`, received };
|
|
@@ -150,23 +185,43 @@ describe('webhook-signed-delivery: end-to-end HMAC v1', () => {
|
|
|
150
185
|
// tenantId is 403'd by a host that scopes subscriptions by membership
|
|
151
186
|
// (RFC 0093). Single-tenant hosts return undefined ⇒ omit tenantId.
|
|
152
187
|
const ownedTenant = await discoverOwnedTenant(driver);
|
|
188
|
+
const registration = resolveRegistrationUrl(receiver.url);
|
|
153
189
|
const reg = await driver.post('/v1/webhooks', {
|
|
154
|
-
url:
|
|
190
|
+
url: registration.url,
|
|
155
191
|
events: ['run.completed'],
|
|
156
192
|
...(ownedTenant ? { tenantId: ownedTenant } : {}),
|
|
157
193
|
});
|
|
158
194
|
|
|
159
|
-
// SSRF guard
|
|
160
|
-
//
|
|
195
|
+
// SSRF guard: if the host rejects the destination, what that MEANS depends
|
|
196
|
+
// on which URL was registered.
|
|
197
|
+
//
|
|
198
|
+
// * No tunnel wired (loopback URL): the host is refusing a private
|
|
199
|
+
// address, which webhooks.md REQUIRES it to do. That is correct
|
|
200
|
+
// behaviour and the scenario is unwitnessable here — `blocked`.
|
|
201
|
+
// * Tunnel wired (public https URL): the host refused a destination the
|
|
202
|
+
// spec makes legitimate. RFC 0093 does not permit rejecting a public
|
|
203
|
+
// https host, so this is a FINDING, not a missing precondition. Fail.
|
|
204
|
+
//
|
|
205
|
+
// Soft-skipping the second case would let a host that rejects everything
|
|
206
|
+
// record `blocked` forever instead of the failure it earned.
|
|
161
207
|
if (reg.status === 400) {
|
|
162
208
|
const body = reg.json as { error?: string };
|
|
163
209
|
if (body.error === 'webhook_url_rejected') {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
'
|
|
210
|
+
if (!registration.tunnelled) {
|
|
211
|
+
// eslint-disable-next-line no-console
|
|
212
|
+
console.warn(
|
|
213
|
+
'[webhook-signed-delivery] host SSRF guard rejected the loopback receiver; ' +
|
|
214
|
+
'set OPENWOP_WEBHOOK_RECEIVER_URL to a public https tunnel in front of it ' +
|
|
215
|
+
'(preferred — relaxes no guard), or OPENWOP_WEBHOOK_ALLOW_PRIVATE=true on the host',
|
|
216
|
+
);
|
|
217
|
+
return softSkip('blocked', 'precondition not met — `body.error === \'webhook_url_rejected\'` returned early (seam, prior step, or fixture unavailable)');
|
|
218
|
+
}
|
|
219
|
+
expect.fail(
|
|
220
|
+
`host rejected the operator-supplied public https receiver (${registration.url}) with ` +
|
|
221
|
+
'webhook_url_rejected. A public https destination is legitimate under ' +
|
|
222
|
+
'webhooks.md §"SSRF protection" and RFC 0093 §"Delivery-time egress validation"; ' +
|
|
223
|
+
'rejecting it is a host defect, not an unmet precondition.',
|
|
168
224
|
);
|
|
169
|
-
return softSkip('blocked', 'precondition not met — `body.error === \'webhook_url_rejected\'` returned early (seam, prior step, or fixture unavailable)');
|
|
170
225
|
}
|
|
171
226
|
}
|
|
172
227
|
|
|
@@ -216,9 +271,19 @@ describe('webhook-signed-delivery: end-to-end HMAC v1', () => {
|
|
|
216
271
|
return false;
|
|
217
272
|
}
|
|
218
273
|
});
|
|
274
|
+
// With a tunnel wired this is the assertion that keeps a mis-wired front
|
|
275
|
+
// from reading as a pass. Registration succeeded, so the host believes it
|
|
276
|
+
// has a subscriber; if nothing arrived HERE, the delivery went somewhere
|
|
277
|
+
// this process cannot see and every assertion below it would be vacuous.
|
|
278
|
+
// It fails — it must never soft-skip.
|
|
219
279
|
expect(ourDeliveries.length, driver.describe(
|
|
220
280
|
'webhooks.md §"Delivery"',
|
|
221
|
-
|
|
281
|
+
registration.tunnelled
|
|
282
|
+
? 'host MUST POST at least one event for THIS run to the registered subscriber. ' +
|
|
283
|
+
'Registration was accepted, so zero deliveries observed on the local receiver means ' +
|
|
284
|
+
'either the host did not deliver, or OPENWOP_WEBHOOK_RECEIVER_URL does not actually ' +
|
|
285
|
+
'front this process. Both are failures; neither is a skip.'
|
|
286
|
+
: 'host MUST POST at least one event for THIS run to a registered subscriber after run.completed',
|
|
222
287
|
)).toBeGreaterThan(0);
|
|
223
288
|
|
|
224
289
|
// Validate the FIRST delivery's signature contract. Other deliveries
|
|
@@ -268,4 +333,62 @@ describe('webhook-signed-delivery: end-to-end HMAC v1', () => {
|
|
|
268
333
|
expect(del.status).toBeGreaterThanOrEqual(200);
|
|
269
334
|
expect(del.status).toBeLessThan(300);
|
|
270
335
|
});
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* POSITIVE CONTROL for the tunnel path.
|
|
339
|
+
*
|
|
340
|
+
* Without this, the tunnel run passes identically on two very different
|
|
341
|
+
* hosts: one whose SSRF guard is intact and was cleared by a legitimate
|
|
342
|
+
* public destination, and one that has NO GUARD AT ALL and would have
|
|
343
|
+
* accepted the loopback URL just as happily. The green would be reporting on
|
|
344
|
+
* the operator's tunnel rather than on the host's behaviour, and the
|
|
345
|
+
* variable would be doing no work.
|
|
346
|
+
*
|
|
347
|
+
* So: with the tunnel wired, re-register the LOOPBACK url and require that
|
|
348
|
+
* the host still refuses it. That is what makes the sibling test's pass
|
|
349
|
+
* attributable to the guard being cleared rather than absent.
|
|
350
|
+
*
|
|
351
|
+
* A host that ACCEPTS loopback here is not necessarily non-conformant — it
|
|
352
|
+
* may be running with `OPENWOP_WEBHOOK_ALLOW_PRIVATE=true`. But in that
|
|
353
|
+
* configuration the tunnel is demonstrating nothing, and saying so is the
|
|
354
|
+
* control's whole job.
|
|
355
|
+
*/
|
|
356
|
+
it('control: with a tunnel wired, the host still refuses the loopback receiver', async () => {
|
|
357
|
+
if (!(await isWebhookSupported())) {
|
|
358
|
+
return softSkip('inapplicable', '[webhook-signed-delivery] host does not advertise webhook support; skipping');
|
|
359
|
+
}
|
|
360
|
+
if (!process.env.OPENWOP_WEBHOOK_RECEIVER_URL?.trim()) {
|
|
361
|
+
// No tunnel wired ⇒ the sibling test already registers loopback directly
|
|
362
|
+
// and this control has nothing to add.
|
|
363
|
+
return softSkip('inapplicable', 'control applies only when OPENWOP_WEBHOOK_RECEIVER_URL is set');
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const receiver = await startReceiver();
|
|
367
|
+
activeServer = receiver.server;
|
|
368
|
+
|
|
369
|
+
const ownedTenant = await discoverOwnedTenant(driver);
|
|
370
|
+
const reg = await driver.post('/v1/webhooks', {
|
|
371
|
+
url: receiver.url, // deliberately the raw loopback URL, NOT the tunnel
|
|
372
|
+
events: ['run.completed'],
|
|
373
|
+
...(ownedTenant ? { tenantId: ownedTenant } : {}),
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
if (reg.status >= 200 && reg.status < 300) {
|
|
377
|
+
// Clean up the subscription we just created before failing, so a failed
|
|
378
|
+
// control does not leave a live loopback subscriber behind.
|
|
379
|
+
const created = reg.json as { webhookId?: string };
|
|
380
|
+
if (created?.webhookId) {
|
|
381
|
+
await driver.delete(`/v1/webhooks/${encodeURIComponent(created.webhookId)}`);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
expect(reg.status, driver.describe(
|
|
386
|
+
'webhooks.md §"SSRF protection"',
|
|
387
|
+
'the server MUST reject loopback subscription URLs at registration time. ' +
|
|
388
|
+
'It was accepted here, so this run cannot attribute the tunnelled test\'s pass to ' +
|
|
389
|
+
'a working guard: a host with no guard produces the same result. Either the guard is ' +
|
|
390
|
+
'absent (a finding) or OPENWOP_WEBHOOK_ALLOW_PRIVATE is set (in which case drop the ' +
|
|
391
|
+
'tunnel — it is not doing anything).',
|
|
392
|
+
)).toBe(400);
|
|
393
|
+
});
|
|
271
394
|
});
|