Mock Server evaluates #(...) in pathParams / requestUrlBase (bypass of GHSA-m82q-jgc3-9gc9)
Description
Hi,
I run independent, pre-registered verification of software (Trenyx, trenyx.io). This is a static-only read of karatelabs/karate at commit 9771f948, read on 2026-09-23, over the mock server, HTTP server, and OAuth client. It was run by a model under a pre-registered plan. Nothing was executed. This is layer one of a three-layer process: the code read against your own claims. The later layers, planted defects against your suite and a receipt in your name, were not run here.
What held: request-derived taint checked at every recursion (StepExecutor.java:3369-3371); the CSRF halt before API/template dispatch and the traversal halt on static files (ServerRequestHandler.java:134-136,345-346).
3 findings; two lower-severity items (a claims note tied to #1, and session-file permissions) are in the full record.
- What: a missing taint mark on the mock's
pathParamsbinding lets client path data reachkarate.exec, a third, undisclosed route into the sink of GHSA-2c85-rfcc-g74j and GHSA-m82q-jgc3-9gc9, both LOW per the maintainers; HIGH per us.
Where: pathMatches() sets pathParams with no markRequestDerived call (MockHandler.java:189-196), unlike most request bindings (:220-273; requestUrlBase, :262, is unmarked too). The guard at StepExecutor.java:3369-3371 is bypassed; the value reaches eval (:3454) and ungated karate.exec (KarateJs.java:816-835,1293). Why it matters: it needs a scenario echoing a path param through a paren-wrapped object, one of the migration guide's two rewrites (docs/MIGRATION_GUIDE.md:458), shipped in fixtures (MockE2eTest.java:111,217); karate mock binds every interface, no host option (MockServer.java:358; MockCommand.java:62-103). Fix: wrap pathParams and requestUrlBase in markRequestDerived; add a host option defaulting to loopback.
- What: a client-controlled session cookie resolves to a filesystem path with no traversal check, in the opt-in session store.
Where: getSessionIdFromCookie splits the raw Cookie header unvalidated (ServerRequestHandler.java:195-208) into FileSessionStore, which resolves the path with no PathSecurity call (:112-113); the static route calls it first (ServerRequestHandler.java:345-346). Why it matters: a read lands the file's data in the attacker's session; a write can overwrite, not create, a .json file outside the root. Fix: accept only ids in the UUID form the store issues; PathSecurity.isSafe alone passes absolute paths.
- What: TLS is unverified by default on the test client; the OAuth callback never checks the
stateit sends, on a listener bound to every interface.
Where: with ssl untouched, the client builds a trust-all context with NoopHostnameVerifier (ApacheHttpClient.java:348-356; docs/MOCKS.md:519-520 implies otherwise). state is generated and sent (AuthorizationCodeAuthHandler.java:157-158,307-309) but only logged, never compared (LocalCallbackServer.java:54-61); start() binds the wildcard (:35). Why it matters: every test HTTPS call risks MITM; only PKCE stops an injected code. Fix: use JVM default trust and hostname verification when ssl is unset (that branch ignores sslTrustAll), compare state before completing the future, and bind loopback.
Private first: no public mention before a fix or 60 days, whichever comes first; if you need more time, say so and we will work it out. I'm glad to re-check the fix you name, once, within that window. The pre-registration hash and the full record publish only after that, and the write-up says so if you fixed it.
SK Trenyx
----
Severity
Low. The Karate Mock Server and server mode are developer test tooling, documented for trusted networks only and never for untrusted clients. Exploiting finding 1 also requires a mock feature written in a specific shape (echoing a path parameter or requestUrlBase inside a JS expression). The attacker doesn't control that and can't discover it. This is an incomplete-fix variant of GHSA-2c85-rfcc-g74j and GHSA-m82q-jgc3-9gc9, both published as Low, and the same weighting applies.
Fixed in 2.1.3: pathParams, requestUrlBase and requestMethod are treated as request data (finding 1), and FileSessionStore rejects session ids outside the form it issues (finding 2). Finding 3 is by design: the test HTTP client trusts all certificates by default so tests can reach targets with self-signed certificates, and the OAuth callback is a short-lived local listener for test sign-in, backed by PKCE.
Tracked in #3064.