Repository navigation
fix(parse-server-mongo): master key for local calls; check every call - #110
Merged
Merged
Conversation
parse-server-mongo sample coverage
Threshold: PR may not drop coverage by more than 1.0pp. Override per-repo via the |
… on calls that do not work
flow.sh record-traffic sent the master key on 46 of its calls, and
parse-server refused every one with a 403. The default masterKeyIps,
`0.0.0.0/0,::0`, admits no client parse-server 8 sees: each arrives as
an IPv4-mapped IPv6 address (`::ffff:127.0.0.1` behind keploy), and
parse-server 8 reads `::0` as the single address `::`. flow.sh threw the
statuses away, so keploy lanes on this sample recorded and replayed 46
refusals and passed (keploy/enterprise pipeline 10621).
The fix: masterKeyIps defaults to `0.0.0.0/0,::/0` in docker-compose.yml
and index.js, the "any IPv6" both parse-server 8 and 9 read.
So it cannot silently come back:
- record-traffic checks every call: any 2xx, or the one code an error
probe names with --expect; the GraphQL calls must answer a result with
`data` and no `errors` (GraphQL reports failures in a 200). Without a
session token it notes the four session calls it cannot send. It
sends every call, then exits 1 listing each problem with the start of
the answer and curl's own error.
- bootstrap exits 1 unless the login gives a session for the user with
PARSE_FIXED_USER_ID. A failed signup is accepted only as a re-run's
(400, code 137: the fixed objectId is taken); it used to take any 4xx
as "already exists" and exit 0 with no token, after which
record-traffic skipped its session calls.
Calls the check found broken: GraphQL was never mounted (a ParseServer
used as middleware serves REST only), so index.js mounts a
ParseGraphQLServer at <mount>/graphql; a hook is deleted with a PUT of
{"__op":"Delete"}, as parse-server has no DELETE route for it.
For replay, now that the calls do something: the role's objectId is
pinned (PARSE_FIXED_ROLE_ID), files keep their names (preserveFileName),
header.Etag is noise (a hash of a body with noised fields), and
record-traffic deletes the role, so another bootstrap and record-traffic
run on the same database.
README, usage and comments say what the script does; the `list-routes`
subcommand that never existed is no longer advertised, `--help` exits 0,
and the health-timeout message goes to stderr.
Signed-off-by: slayerjain <shubhamkjain@outlook.com>
slayerjain
force-pushed
the
chore/parse-server-master-key-ips
branch
from
October 13, 2026 03:55
2c0f74e to
37b495a
Compare
The sample's default masterKeyIps was 0.0.0.0/0,::/0, and compose publishes the port on every host interface, so any host that could reach the port had the master key, a published default. The default is now parse-server's own, 127.0.0.1,::1, and compose adds the compose network's subnet, the address a client on the docker host arrives from through the published port. flow.sh and the keploy lanes call from there, so their master-key calls still go through. Any other host gets a 403. With a restricted list, one master-key GraphQL call from a refused address ended the app: the GraphQL mount runs parse-server's async header middleware on the sample's express 4 app, the middleware refuses by rejecting, and express 4 drops the rejection, so node exits on it. The sample now runs express 5.1.0, parse-server 8.2.3's own, which hands the rejection to parse-server's error handler: a 403, and the app stays up. The workflow's build job now runs check-parse-master-key-ips.sh: from localhost the master key gets 200; from the host's own non-loopback address a REST call and a GraphQL call with it get 403; the app still answers /health and its container still runs. flow.sh bounds each call with --max-time (PARSE_CURL_MAX_TIME, default 60 s; each health-wait try 5 s), so a call whose answer never comes is listed as one that did not work instead of hanging the flow. The README names both keploy lanes that use the sample, and its allowlist and express rows match the code. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
The master-key allowlist admits the compose network's subnet, so that the docker host's own calls get through: docker relays them from the network's gateway. But compose published the port on every host interface, and docker relays the IPv6 binding ([::]) for every client, also from the gateway. So any host that reached the docker host over IPv6, link-local included, had the master key, a published default. The port is now published on the host's loopback only, 127.0.0.1 and [::1], so no other host can reach the app at all, whatever docker relays. The allowlist stays loopback plus the compose subnet. check-parse-master-key-ips.sh now checks, besides 200 for the host's own call through loopback: the port is published on loopback only; compose's default list and index.js's fallback are what they should be; the host's IPv4 address and its IPv6 link-local and global addresses (each first shown to take connections, on a listener of the script's own) refuse the connection or answer 403 to master-key calls to /serverInfo, /graphql and /schemas. The refused-call crash check now runs against the app restarted with the list 127.0.0.1,::1, so that the host's own calls are the refused ones: 403, and the app keeps serving. express 5 hands a listen error to the app.listen callback instead of throwing it, so the app said it listened and stayed up serving nothing: it now exits 1, with a row that takes the port first. flow.sh's health wait is now a wall-clock bound: each try is cut at the deadline, so a server that takes connections and never answers ends the wait on time, with a row (check-parse-flow-health-wait.sh) run in CI. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
Publishing the port on [::1] as well as 127.0.0.1 broke `docker compose
up` on a docker host with IPv6 off: docker cannot bind [::1] there
("failed to bind host port [::1]:6100/tcp: cannot assign requested
address"), while the sample's earlier all-interfaces publish worked.
127.0.0.1 alone binds on every host and is still loopback only, so no
other host can reach the app.
- docker-compose.yml publishes 127.0.0.1:PORT:PORT only.
- flow.sh calls the app at 127.0.0.1, not localhost, since nothing
listens on [::1]; the README says the same.
- check-parse-master-key-ips.sh: the port must be published on 127.0.0.1
only, the [::1] master-key call is gone, and each address another host
reaches this host at (IPv4, IPv6 link-local and global) must refuse
the connection: a 403 there now fails, since any answer means the app
is published beyond 127.0.0.1. Its in-container serverURL uses the
container port.
Signed-off-by: slayerjain <shubhamkjain@outlook.com>
slayerjain
marked this pull request as ready for review
November 21, 2026 23:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge order
PARSE_SAMPLE_PIN, on enterprisemain), so merging this PR does not change what every enterprise PR's lane runs.main.Problem
flow.sh record-trafficmade 51 calls (53 with bootstrap's signup and login), and 46 of them sent the master key. Onmainparse-server refuses all 46 with a 403:keploy/enterprise pipeline 10621 logged that line 92 times in
parse-server-linux, 46 in record and 46 in replay.flow.shthrew every status away, so the lane recorded 46 refusals, replayed 46 refusals, and passed. Classes, users, roles, files, schemas, hooks, aggregate and GraphQL were never recorded.Root cause
app.listen(port)binds Node's dual-stack::socket, so an IPv4 client arrives as an IPv4-mapped address:::ffff:127.0.0.1behind keploy in the lane, and::ffff:<bridge gateway>through docker's port mapping. parse-server decides the family withnet.isIPv4(ip), false for those, so0.0.0.0/0never applies.::0is one address in parse-server 8.getBlockListinlib/middlewares.jstreats only'::/0'and'::'as "any IPv6" (8.2.3, and 8.6.105, the newest 8.x).'::0'goes into anet.BlockListas the single address::. parse-server's own option help says['0.0.0.0/0', '::0']allows any address; that holds from 9.5.0, not for the 8.2.3 this sample pins.The sample's default, in both
docker-compose.ymlandindex.js, was0.0.0.0/0,::0: meant to admit everyone, it refused everyone.Change
The master key: the docker host only, by construction
docker-compose.ymlpublishes the app's port on the host's127.0.0.1only. No other host can reach the app at all, over IPv4 or IPv6. Not on[::1]as well: docker cannot bind[::1]on a host with IPv6 off, sodocker compose upwould fail there (failed to bind host port [::1]:6100/tcp: cannot assign requested address), while127.0.0.1binds on every host. So call the app at127.0.0.1, notlocalhost: nothing listens on[::1].flow.shnow does.[::]) on this IPv4-only network. So an allowlist cannot tell the docker host from another host once the port is published wider than127.0.0.1.127.0.0.1,::1, inindex.js, anddocker-compose.ymladds the compose network's subnet (${PARSE_NETWORK_SUBNET}, default172.30.0.0/24): the docker host's own calls through the127.0.0.1-published port arrive from the gateway. flow.sh and the keploy lanes call from the docker host, so their master-key calls go through.0.0.0.0/0,::/0: the master key is a published default, and it gives full access, hooks included (a hook can make the server call any URL).::ffff:127.0.0.1against127.0.0.1), so no/0entry is needed for the dual-stack socket. The README's env table says all this.express 5.1.0, so a refused master-key GraphQL call is a 403, not a crash
index.jsmounts parse-server's GraphQL on the sample's own express app (below). That runs parse-server's async header middleware there, which refuses a master key from an unlisted address by rejecting.package.jsonnow pins express 5.1.0;app.use(mountPath, parseServer.app)works unchanged.EADDRINUSE,EACCES) to theapp.listencallback instead of throwing it, soindex.jsnow exits 1 on one; it would otherwise say it listens and stay up serving nothing.check-parse-master-key-ips.shafter the coverage run:index.js's fallback list is127.0.0.1,::1, and compose's default list is loopback plus the network's subnet;127.0.0.1only, and the master key through127.0.0.1gets 200;/serverInfo,/graphqland/schemasare refused at the connection: the port is closed there, and any answer, a 403 included, fails the check;127.0.0.1,::1, the docker host's own master-key REST and GraphQL calls are the refused ones: 403 and 403, and the app still answers/healthand its container still runs.So a refused or broken call cannot pass silently again
flow.sh record-trafficnow checks every call.firerecords each status. It must be any 2xx, or, for the three calls that probe an error path, the one code they name with--expect:DELETE /sessions/no-such-session-id404,POST /functions/no-such-fn400,POST /jobs/no-such-job400.fire --graphql) must also answer a GraphQL result, a JSON object with adataobject and noerrors: GraphQL reports a failed query or mutation in a 200.GET /users/me, the sessionPUT /users/{id},GET /sessions/me,POST /logout).record-trafficexits 1 and lists each problem, with the first 200 printable bytes of the answer and curl's own error.--max-time(PARSE_CURL_MAX_TIME, default 60 s), so a call whose answer never comes is listed with curl's(28)instead of hanging the flow.bootstrap's health wait is a wall-clock bound: each try waits at most 5 s and is cut at the deadline.check-parse-flow-health-wait.sh, run in the build job, checks thatbootstrap 2against a server that never answers exits 1 within 4.5 s.flow.sh bootstrapexits 1 when parse-server does not come up, when the signup fails for any reason but a re-run's (400, code 137: the fixedobjectIdis taken), and when the login gives no session for the user withPARSE_FIXED_USER_ID. It used to take any 4xx signup as "already exists" and exit 0 with no token.build-coveragejob (run-and-measure-parse-server.shruns underset -e).Calls that never worked, found by the check once the master key got through
POST /parse/graphqlcalls returned 404: aParseServerused as express middleware serves REST only.index.jsnow mounts aParseGraphQLServerat<mount>/graphql, before the REST app. The GraphQL schema loads on the first GraphQL request, not at boot, so the boot-phase_SCHEMAsequence this sample exists for is unchanged.DELETE /hooks/functions/covFnreturned 404: parse-server has no such route. A hook is deleted withPUT /hooks/functions/{name}and{"__op":"Delete"}, whichflow.shnow sends.What a replay needs, now that the calls do something
POST /rolespins itsobjectIdtoPARSE_FIXED_ROLE_ID,keploy-role-id, as the class objects already do. A random id changed theLocationandEtagheaders on every replay.preserveFileName: true: parse-server prefixes an uploaded file's name with 32 random hex characters otherwise.header.Etagis added tokeploy.yml.template's noise. It is a hash of the body, so it changes whenever a noised field does. The body is still compared field by field.record-trafficdeletes the role with the other objects with fixed ids, so anotherbootstrapandrecord-trafficrun against the same database. It is one more call:record-trafficsends 52 andbootstrap2, 54 in all.README: names both keploy lanes that use the sample (keploy/enterprise's
parse-server-linux.shand keploy/integrations'parse-server-mongo-linux.sh), and its allowlist, express and port rows match the code: the app is published on127.0.0.1only, so call it there, from the docker host.Verification
This head, amd64, docker compose on a test host, default settings:
bootstrap, fresh databaserecord-trafficdocker port127.0.0.1:<port>only[::1]/serverInfo,/graphqland/schemasat the docker host's IPv4 address and at its IPv6 link-local address/healthdisable_ipv6=1on all interfaces, no::1on lo)docker compose upexit 0; published on127.0.0.1:6100only; the master key through127.0.0.1: 200. With[::1]published as well,compose upfails:failed to bind host port [::1]:6100/tcp: cannot assign requested addresscheck-parse-master-key-ips.sh127.0.0.1only; 200 through127.0.0.1; the host's IPv4 and IPv6 link-local addresses take connections on the script's own listener and refuse all 6 master-key calls at the connection; with its port taken the app exits 1; with127.0.0.1,::1, the host's own REST and GraphQL calls get 403 and 403, then health 200, runningmain0.0.0.0and[::]; at the host's IPv6 link-local address/serverInfo,/graphqland/schemasanswer 200 to the master key, and at its IPv4 address 403 (an answer, so a failure too)[::]published as well as127.0.0.1127.0.0.1, and the same three 200s over IPv6[::1]published as well as127.0.0.1127.0.0.1HTTP 000(curl: (52) Empty reply from server), then health(7) Failed to connect, container not runningindex.js's fallback, or compose's default list, set to0.0.0.0/0,::/0check-parse-flow-health-wait.shbootstrap 2exits 1 after 3.0 s,bootstrap 6after 6.0 sbootstrap 2took 12.0 s--max-timeleft at 5 sbootstrap 2took 6.2 s-ge 0), or with no deadline checkrecord-trafficagainst a port that accepts and never answers,PARSE_CURL_MAX_TIME=1curl: (28)The flow checks (one stack, run in this order; arm64):
bootstrap, fresh databaserecord-trafficbootstrapagainrecord-trafficagainbootstrapwith a wrong passwordlogin gave no session for keploy-user-id: {"code":101,"error":"Invalid username/password."}bootstrapfor another fixedobjectIdwith the same usernamesignup failed: HTTP 400: {"code":202,…}bootstrapagainst a dead portrecord-trafficagain withoutbootstrapcode 209(its session was logged out)record-trafficagainst a closed portHTTP 000, want 2xx: (curl: (7) Failed to connect …)record-trafficwith no token fileHTTP 200, but the answer is not a GraphQL result with data and no errors: {"errors":[…--graphqltaken offshellcheck 0.11.0:
check-parse-master-key-ips.shandcheck-parse-flow-health-wait.shclean;flow.shhas the same findings asmain(2 × SC2016, 1 × SC2034).Not changed