Schedule icon
Request icon
If icon
SlackIncomingWebhook icon
Fail icon
Log icon

GraphQL production introspection exposure and schema leakage sentinel

Audit production GraphQL endpoints for unauthorized schema introspection, detect type exposure, and alert security teams on schema leakage.

Categories
Infrastructure

Protect production GraphQL APIs against unauthorized schema discovery and reconnaissance by automatically auditing GraphQL introspection queries. While GraphQL schema introspection (__schema and __type) is essential during development, leaving it enabled in production exposes internal data structures, backend entity relationships, deprecated fields, and administrative queries to potential attackers. This sentinel workflow periodically probes your production GraphQL endpoints with native introspection queries, evaluates whether the server leaks type definitions, alerts security teams via Slack with discovered type counts, and halts execution when exposure policies are violated.

How it works

  1. A Schedule trigger periodically invokes the security sentinel on a 6-hour interval (shipped disabled by default).
  2. Task probe_introspection uses io.kestra.plugin.graphql.Request to dispatch an introspection query (query IntrospectionSecurityAudit { __schema { queryType { name } types { name kind } } }) to inputs.graphql_endpoint_url. With failOnGraphQLErrors: false and allowFailed: true, the task succeeds even when secure servers return HTTP 400 or GraphQL error objects (such as "GraphQL introspection is not allowed").
  3. Task evaluate_exposure (io.kestra.plugin.core.flow.If) inspects the response body:
    • If outputs.probe_introspection.body.__schema.types is populated, the endpoint is actively leaking its schema (EXPOSURE_DETECTED). The workflow posts a critical alert to Slack detailing the exposed endpoint and leaked type names, and conditionally triggers fail_security_gate (io.kestra.plugin.core.execution.Fail).
    • If introspection is blocked or disabled, task log_introspection_locked records a clean SECURE status.
  4. Task log_audit_summary records compliance metrics for audit logs.
  5. Top-level errors handler catches network unreachable or TLS handshake failures.

What you get

  • Continuous verification that production GraphQL gateways enforce introspection lockdown policies.
  • Immediate detection of accidental introspection re-enabling caused by misconfigured environment variables or staging promotions.
  • Actionable Slack notifications containing discovered type counts and sample entity names.
  • Automated deployment gate integration to block CI/CD pipelines before insecure API configurations reach customers.

Who it's for

  • Application Security (AppSec) and SecOps engineers enforcing API hardening standards.
  • Platform and Backend Engineers maintaining public-facing GraphQL APIs across Apollo, Hasura, Yoga, or Mercurius.
  • DevOps teams needing automated pre-release security verification gates.

Why orchestrate this with Kestra

Manual penetration testing or periodic scripts often fail to catch temporary misconfigurations introduced during fast release cycles. Kestra provides declarative, observable orchestration with native GraphQL request handling, built-in retry and timeout management, secret handling, and instant Slack notifications. Rather than maintaining custom security scanners, your API security audits live as version-controlled code directly alongside your existing infrastructure pipelines.

Prerequisites

  • Network access from the Kestra worker to the target GraphQL endpoint.
  • A valid authentication token or API key if the GraphQL endpoint requires credentials before evaluating queries.

Secrets

  • GRAPHQL_AUTH_TOKEN: Bearer token or API key used in the Authorization header to authenticate against the GraphQL endpoint.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL used to receive security alerts and probe failure notifications.

Quick start

  1. Store your Slack webhook and GraphQL credentials under Kestra Secrets (SLACK_WEBHOOK_URL and GRAPHQL_AUTH_TOKEN).
  2. Set graphql_endpoint_url to your production GraphQL URL (e.g., https://api.yourdomain.com/graphql).
  3. Trigger a manual execution from the Kestra UI to verify that your endpoint correctly blocks introspection and reports SECURE.
  4. Enable the scheduled_security_audit trigger to enforce recurring automated protection.

How to extend

  • Extend the introspection query to check for specific sensitive types (e.g. User, Admin, Payment) and escalate severity accordingly.
  • Integrate with PagerDuty or Opsgenie plugins (io.kestra.plugin.pagerduty.notifications.PagerDutyAlert) for P1 security incident paging.
  • Attach this flow as a post-deployment verification hook in your CD pipeline to block releases if introspection is detected.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.