Skip to content

Commit a546a77

Browse files
committed
fix(messaging): allow only pull and acknowledge on the Hermes Pub/Sub route
The Google Chat preset for Hermes allowed POST to every Pub/Sub v1 path, and the comment justified that width with a claim about glob matching that does not hold. The L7 matcher is glob.match(pattern, ["/"], path), so `/` is the only delimiter and `*` already spans the `:verb` suffix inside a segment. The adapter issues exactly two Pub/Sub requests, `:pull` and `:acknowledge`, so restrict the route to those. The gateway injects a bearer carrying the pubsub scope here, and the previous rule also permitted publish and subscription administration from inside the sandbox. Presets cannot template the configured subscription, so the rules match the subscription path shape. Drop the stale `:modifyAckDeadline` mention; the adapter never issues it.
1 parent e55ca9b commit a546a77

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

  • src/lib/messaging/channels/googlechat/policy

src/lib/messaging/channels/googlechat/policy/hermes.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ network_policies:
1010
name: googlechat_hermes
1111
endpoints:
1212
# Inbound: pull Chat events from the Pub/Sub subscription over the REST
13-
# unary API (:pull, :acknowledge, :modifyAckDeadline). Not gRPC
13+
# unary API (:pull, :acknowledge). Not gRPC
1414
# StreamingPull — REST keeps the egress L7-inspectable so the
1515
# gateway-minted token is injected by the proxy (keyless). The
1616
# subscription lives under /v1/projects/{project}/subscriptions/{sub}.
@@ -19,11 +19,14 @@ network_policies:
1919
protocol: rest
2020
enforcement: enforce
2121
rules:
22-
# Pub/Sub REST pull uses Google custom-method verbs with a colon suffix:
23-
# `/v1/projects/{p}/subscriptions/{s}:pull` / `:acknowledge` /
24-
# `:modifyAckDeadline`. Match the whole /v1 tree so the `:verb` suffix
25-
# is covered (a `/v1/projects/**` glob can miss the trailing `:pull`).
26-
- allow: { method: POST, path: "/v1/**" }
22+
# Pub/Sub REST pull uses Google custom-method verbs with a colon
23+
# suffix: `/v1/projects/{p}/subscriptions/{s}:pull`. The L7 matcher is
24+
# `glob.match(pattern, ["/"], path)`, so `/` is the only delimiter and
25+
# `*` spans the `:verb` suffix within a segment. Allow just the two
26+
# operations the adapter issues; a broader `/v1/**` would also permit
27+
# publish and subscription administration on the injected bearer.
28+
- allow: { method: POST, path: "/v1/projects/*/subscriptions/*:pull" }
29+
- allow: { method: POST, path: "/v1/projects/*/subscriptions/*:acknowledge" }
2730
# Outbound reply: send/update/delete messages in Chat spaces. Same rule
2831
# shape as the OpenClaw preset — writes scoped to the Chat `spaces` tree,
2932
# reads across the Chat REST v1 tree.

0 commit comments

Comments
 (0)