/

CVE-2026-56303

Severity:

HIGH RISK

(7.5)

API Key Metadata Exposure (CWE-200) in Capgo RPC

CVE-2026-56303

Deferred

Vulnerability type

Category:

Information Disclosure

CWE:

CWE-200

Impact:

Sensitive Metadata Exposure

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

An information disclosure flaw in Capgo allows unauthenticated callers to invoke a SECURITY DEFINER PostgreSQL function via a public RPC endpoint and retrieve sensitive API key metadata.

When a valid key value is supplied to the exposed function, attackers can learn user association, org scoping, mode, and expiration details, increasing the risk of targeted abuse and account mapping.

Affected context

This vulnerability appears in Capgo deployments where:

  • The find_apikey_by_value PostgreSQL function is marked SECURITY DEFINER
  • The function is exposed through /rest/v1/rpc/find_apikey_by_value
  • The anon role is allowed to execute the function without strong authentication

In such configurations, any party able to reach the REST endpoint and supply a valid API key value can obtain detailed metadata about that key.

Exploit preconditions

  • Attack surface: Public or semi-public HTTP interface at /rest/v1/rpc/find_apikey_by_value
  • Required access: Network access to the Capgo REST endpoint; a valid API key value (not necessarily belonging to the attacker)
  • Trigger point: Calling the RPC endpoint that wraps the find_apikey_by_value PostgreSQL function
  • Why exploitation is possible: The function runs as SECURITY DEFINER and is bound to the anon role, permitting metadata queries by unauthenticated users who know or can obtain a key value

Why this happens

The underlying issue is a mismatch between the privilege level of a database function and the trust level of the caller that can reach it.

Marking find_apikey_by_value as SECURITY DEFINER grants elevated database rights to the function, yet exposing it to the anon role via a REST RPC endpoint fails to constrain who can access the resulting sensitive data.

This aligns with CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, where internal metadata about API keys (user_id, mode, org scoping, expiration) is made available to parties lacking appropriate authorization guarantees.

Potential impact

  • Attackers may map API keys to specific users and organizations
  • Attackers could profile key usage modes and scopes to plan targeted attacks
  • Attackers can identify expiration timelines, aiding timing-based abuse
  • Attackers may combine metadata with other leaks to escalate or pivot into account compromise

General mitigation guidance

Effective mitigation focuses on reducing who can access sensitive metadata and limiting the privileges of helper functions:

  • Avoid exposing SECURITY DEFINER functions directly to unauthenticated or low-trust roles
  • Enforce strict authorization checks on RPC endpoints that reveal API key details
  • Return only minimal, non-sensitive fields to untrusted callers, or use separate, reduced-view functions
  • Apply least-privilege design to database functions, avoiding broad access patterns to security-critical tables
  • Treat API key metadata as sensitive and design interfaces that reveal such data only under verified ownership or admin context

How teams detect issues like this

Organizations can identify similar issues by:

  • Reviewing database functions marked SECURITY DEFINER and mapping where they are exposed via HTTP or RPC interfaces
  • Using static analysis or schema inspection to flag functions callable by anonymous or low-privilege roles that touch security-related tables
  • Conducting code reviews focused on API key handling paths, checking for endpoints that return metadata without explicit authorization checks
  • Applying policy controls that require security review for new RPC functions and database procedures involving authentication or authorization data

Sources

SourceLink
github.comgithub.com/Cap-go/capgo/security/advisories/GHSA-2xjq-h43m-592f
vulncheck.comvulncheck.com/advisories/capgo-unauthenticated-api-key-metadata-disclosure-via-security-definer-rpc-function

Frequently asked

questions

The described issue exposes metadata about existing API keys (such as user_id, mode, org scope, and expiration), not necessarily the full key material or passwords. However, this metadata can still be sensitive and useful for targeted attacks.

No. The function is executable by the anon role via the RPC endpoint, so unauthenticated attackers who can reach the service and know a valid key value can call it.

Restrict execution of privileged database functions to authenticated and authorized roles, and ensure RPC endpoints that expose key-related information enforce ownership or administrative checks before returning sensitive fields.

Apply least-privilege to database functions, avoid exposing SECURITY DEFINER routines through anonymous endpoints, design APIs to return only non-sensitive data to untrusted clients, and incorporate authorization-focused reviews and automated checks into the development and deployment pipeline.

Find out what's already
exploitable in your codebase.