Documentation
¶
Overview ¶
Package graphql probes the pg_graphql endpoint Supabase serves at /graphql/v1.
It is a second read path over the same tables, and no surveyed scanner looks at it. Hardening guidance concentrates on RLS and on the REST API; a project can be reviewed carefully, declared sound, and still answer the same queries over GraphQL because nobody checked that endpoint existed.
What it is NOT is a better enumerator, which is what it looked like before measuring. Two things were assumed and both were wrong:
- pg_graphql is NOT enabled by default. Both projects available answered "pg_graphql extension is not enabled." until it was switched on deliberately, so the check must treat disabled as the common case and say nothing when it is.
- Introspection is DISABLED. `{ __schema { types { name } } }` is refused with `Unknown field "__schema" on type Query`, so there is no free schema dump and no shortcut around the relation names the scan already has.
What it does give is a clean three-way answer per relation, which is exactly what a sound probe needs:
rows returned -> readable by this role
{"edges": []} -> the relation exists and RLS filtered it
Unknown field ... -> no such relation
and it gives it without knowing a single column name. Every pg_graphql type carries nodeId, whose value is base64 of ["schema", "table", primary key] -- evidence that names itself:
WyJwdWJsaWMiLCAiZmVlZGJhY2tfc3VibWlzc2lvbnMiLCAxMzFd -> ["public", "feedback_submissions", 131]
The finding worth raising is disagreement. Both paths run the same policies, so they should agree; where GraphQL returns rows for a relation REST refused, the REST-only verdict was wrong and the data is reachable anyway.
Index ¶
Constants ¶
const ControlRelationName = "unruly_control_relation_that_cannot_exist"
ControlRelationName is probed to prove the endpoint distinguishes a relation that exists from one that does not. Nothing may define it.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Relations are names to test, normally those the scan already found.
Relations []string
// RESTReadable names the relations the REST pass could already read. A
// relation in both is not new exposure; one readable here and not there is.
RESTReadable map[string]bool
// SampleRows bounds how many node ids are requested as evidence.
SampleRows int
Concurrency int
// Redact suppresses the decoded node ids, which contain primary keys.
Redact bool
}
Options configures the probe.
type RelationState ¶
type RelationState int
RelationState is what GraphQL says about one relation.
const ( // Absent means GraphQL has no field for it. Absent RelationState = iota // Filtered means the relation exists and returned no rows to this role. Filtered // Readable means rows came back. Readable )
type Result ¶
type Result struct {
State State
// Discriminating is false when a relation that cannot exist is answered as
// though it does, which makes every other answer meaningless.
Discriminating bool
ControlDetail string
// Relations maps name to what GraphQL said.
Relations map[string]RelationState
// Proof maps a readable relation to its decoded node ids.
Proof map[string][]string
Findings []finding.Finding
Requests int
}
Result is the outcome of the probe.