Skip to content

fix(users): secure GET /users and GET /users/:id against PII enumeration [Issue #64] - #76

Merged
chonilius merged 1 commit into
MergeFi:mainfrom
gramseostudio-dev:main
Aug 17, 2026
Merged

fix(users): secure GET /users and GET /users/:id against PII enumeration [Issue #64]#76
chonilius merged 1 commit into
MergeFi:mainfrom
gramseostudio-dev:main

Conversation

@gramseostudio-dev

Copy link
Copy Markdown
Contributor

Closes #64

Description

This PR secures the GET /users and GET /users/:id endpoints to prevent PII enumeration, following a rigorous SDD (Specification-Driven Development) workflow.

Changes

  • Security: Added JwtAuthGuard and @ApiBearerAuth() to GET /users and GET /users/:id to strictly require valid authentication.
  • Data Protection: Created PublicUserDto and toPublicUser mapper to strip sensitive fields (such as email and stellarAddress) before reaching the HTTP response.
  • Refactoring: Refactored UsersService to use the new toPublicUser mapper for public listings/lookups, while introducing findOneRaw to maintain backward compatibility with internal operations (like role assignments and github upserts).
  • Testing & Infrastructure: Implemented and executed E2E integration tests in test/users.e2e-spec.ts, backed by a real PostgreSQL instance via Docker (docker compose up db -d), to assert that unauthenticated requests are properly rejected.

Verification Steps

  • Database Setup: Spun up local PostgreSQL database via Docker (docker compose up db -d).
  • E2E Testing: Run npm run test:e2e to verify that unauthenticated requests to user endpoints return unauthorized/forbidden responses as expected.
  • Compilation: Run npm run build to confirm zero type or compilation errors across the NestJS backend graph.
  • API Inspection: Manual validation ensuring sensitive fields like email are completely absent from public-facing responses.

@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown

@gramseostudio-dev is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

@chonilius
chonilius merged commit 3fc1edc into MergeFi:main Aug 17, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GET /users and GET /users/:id are fully unauthenticated, exposing every user's email and other PII with no field-level restriction

2 participants