Skip to content

security: fix debug health endpoint information disclosure#1840

Open
Ridanshi wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
Ridanshi:fix/debug-health-info-leak
Open

security: fix debug health endpoint information disclosure#1840
Ridanshi wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
Ridanshi:fix/debug-health-info-leak

Conversation

@Ridanshi
Copy link
Copy Markdown
Contributor

@Ridanshi Ridanshi commented Jun 1, 2026

Closes #1816

Summary

  • The debug health endpoint previously returned secret-presence indicators ("set"/"missing" for NEXTAUTH_SECRET, SUPABASE_SERVICE_ROLE_KEY, GITHUB_SECRET, GITHUB_ID) and exposed githubId / githubLogin from the caller's session whenever ENABLE_DEBUG_ENDPOINT=true. A single env-var was the only access control.
  • Two additional gates are now enforced: DEBUG_SECRET must be configured in the environment, and callers must supply Authorization: Bearer <DEBUG_SECRET>. The endpoint fails closed if DEBUG_SECRET is absent even when the feature flag is true.
  • The response no longer contains the environment object or any account identifiers — only status, timestamp, database (healthy bool + error string), and session.authenticated (bool).

Root cause

ENABLE_DEBUG_ENDPOINT=true was treated as sufficient access control for a remotely reachable HTTP endpoint. The response then included enough metadata (secret presence, GitHub identity) to assist reconnaissance without revealing raw secret values.

Changes

  • src/app/api/debug/health/route.ts — three-gate access control; stripped environment block and account identifiers from response.
  • test/debug-health.test.ts — 16 regression tests covering each gate, both information-disclosure vectors, database error reporting, and the safe response shape.

Test plan

  • All 16 tests in test/debug-health.test.ts pass (npx vitest run test/debug-health.test.ts)
  • Endpoint returns 403 when ENABLE_DEBUG_ENDPOINT is unset or not exactly "true"
  • Endpoint returns 403 when DEBUG_SECRET is not configured (fail-closed)
  • Endpoint returns 401 when Authorization header is missing or incorrect
  • Endpoint returns 200 with correct Bearer token and shows only safe fields
  • Response never contains environment, githubId, githubLogin, or "set"/"missing" indicators

…-byte-coder#1816)

The endpoint previously required only ENABLE_DEBUG_ENDPOINT=true to
serve diagnostic data, making it accessible to any remote caller who
discovered the URL. With that single gate in place the response
included:

  - Secret-presence indicators (set/missing) for NEXTAUTH_SECRET,
    SUPABASE_SERVICE_ROLE_KEY, GITHUB_SECRET, and GITHUB_ID.
  - The authenticated user's githubId and githubLogin from their session.

These fields are enough to fingerprint deployment configuration and
identify account holders, assisting reconnaissance even though the
raw secret values were never returned.

Fix — three access-control gates enforced in sequence:
  1. ENABLE_DEBUG_ENDPOINT must be exactly true (unchanged).
  2. DEBUG_SECRET must be set in the environment (fail-closed: missing
     secret → 403 even if the flag is true).
  3. Authorization: Bearer <DEBUG_SECRET> must match (401 otherwise).

Response shape is now limited to non-sensitive operational data:
  - status, timestamp
  - database.healthy (bool) + database.error (string | null)
  - session.authenticated (bool only — no account identifiers)

The environment object and all secret-presence indicators are removed
entirely. githubId and githubLogin are never included.

Adds 16 regression tests covering every gate, both information-
disclosure vectors, and the safe response shape.
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

@Ridanshi is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:security GSSoC type bonus: security (+20 pts) type:testing GSSoC type bonus: tests (+10 pts) labels Jun 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:security GSSoC type bonus: security (+20 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Sensitive info leak: debug health endpoint exposes env and session details

1 participant