graphql

package
v0.1.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

func Run

func Run(ctx context.Context, c *client.Client, o Options) Result

Run probes the endpoint and every named relation.

It issues only queries, never mutations, so it is safe by default and needs no consent flag: a GraphQL query is the same read the REST pass already made.

type State

type State int

State is what could be established about the endpoint itself.

const (
	// Unreachable means the request failed at the transport.
	Unreachable State = iota
	// Disabled means the endpoint answered and pg_graphql is not installed.
	Disabled
	// Enabled means it answered a query.
	Enabled
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL