fix(core/api): gate PII reads + enumeration endpoints#83
Merged
Conversation
Closes the read-side audit findings. Most of these don't let an
attacker change state, but they leak PII (emails, phone numbers,
external identity pairings, login history) and authorization signals
(group memberships, owner_ids) to unauthenticated callers.
Self / admin / internal-only reads (Any of: sentinel:all, bearer's
entity/user matches the target, RequestUserIsAdmin):
- GET /core/entity/:entityID (GetEntityByID)
- GET /core/entity/:entityID/groups (GetEntityGroups)
- GET /core/entity/:entityID/memberships (GetEntityMemberships)
- GET /core/entity/:entityID/logins (GetEntityLogins)
- GET /users/:id (GetUserByID)
- GET /users/:id/groups (GetUserGroups)
Admin / internal-only reads:
- GET /applications/client/:clientID (GetApplicationByClientID) —
leaks owner_id + metadata
Internal-only reads (sentinel:all):
- GET /core/entity/external/:provider (ListExternalAuthsByProvider)
- GET /core/entity/external/:provider/:externalID
(GetEntityByExternalAuth) — discord-id → entity reverse lookup
- GET /core/applications/client/:clientID/groups (was unauth — used
by oauth's BuildTokenClaims, which now carries sentinel:all)
- POST /core/saml/sp/resolve (ResolveSAMLServiceProvider) — used by
the saml service, which carries sentinel:all
Internal services (oauth/discord/saml) carry sentinel:all on their
SA bearers, so they keep working through the new gates. External
callers attempting to enumerate or harvest PII now get 401/403.
Last in the stack of "harden core API gates" PRs. After this lands,
core has gates on every endpoint that was previously ungated from
the post-s2s-auth audit.
This was referenced Jun 17, 2026
This was referenced Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on top of #82 — base is `bk1031/harden-user-entity-gates`. Final in the harden-core-api-gates stack.
Audit holes covered
These don't let an attacker change state, but they leak PII and authorization signals to unauthenticated callers.
MEDIUM:
LOW:
Gate model
Self / admin / internal:
```go
Require(c, Any(
RequestTokenHasScope(c, "sentinel:all"),
RequestTokenHasEntityID(c, entityID), // or RequestTokenHasUserID for /users/*
RequestUserIsAdmin(c),
))
```
Internal-only (sentinel:all): the discord-id reverse lookup, external-auth enumeration, internal route variants. The respective non-core services now carry sentinel:all via PR #79.
After this lands
Every endpoint flagged in the post-s2s-auth audit has a gate. `CheckUsername` is left open (intentional — signup form needs it) and `POST /core/applications/verify` stays open (its own constant-time client_id/secret check is the auth). Everything else either requires a bearer or rejects.
Test plan