Skip to content

fix(auth): prevent user/account enumeration (#274) - #394

Open
Penielka wants to merge 2 commits into
UnityChainxx:mainfrom
Penielka:fix/penielka-issue-274
Open

fix(auth): prevent user/account enumeration (#274)#394
Penielka wants to merge 2 commits into
UnityChainxx:mainfrom
Penielka:fix/penielka-issue-274

Conversation

@Penielka

@Penielka Penielka commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Closes #274

Summary

Normalizes public auth responses so attackers can no longer infer whether an account exists or its status (OWASP A01 — Broken Access Control / user enumeration).

Changes

auth.service.ts — register

  • When the email is already registered, the endpoint now returns a generic, account-existence-neutral success message without issuing a token instead of throwing a distinctive 409 Conflict "User with this email already exists".
  • Postgres unique violations (23505) — previously mapped to the same revealing conflict — now return the same neutral response.
  • Internal failures return a generic 400 without leaking internal error details.

auth.service.ts — login

  • All failure paths (unknown email, deactivated account, wrong password) now return the same generic 401 "Invalid email or password". The distinct "Account has been deactivated" message, which revealed that an account existed and was inactive, is gone.

New DTOgeneric-auth-message.dto.ts: neutral, token-less response body used by the registration endpoint.

Testsauth.service.spec.ts updated/expanded (7 passing):

  • duplicate email → neutral message, no token, no user created
  • unique violation → neutral message, no token
  • unknown email, deactivated account, wrong password → identical generic 401 message

Verification

Penielka and others added 2 commits August 29, 2026 19:49
Normalize public auth responses so attackers cannot infer whether an
account exists or its status (OWASP A01). Registration now returns a
generic, token-less success message when the email is already taken
(including Postgres unique violations) instead of a distinctive 409
conflict, and every login failure path (unknown email, deactivated
account, wrong password) surfaces the same generic 401 message.

Closes UnityChainxx#274

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@Penielka Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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

Labels

None yet

Projects

None yet

1 participant