Skip to content

fix: Insecure and simplistic authentication system exposing user data#52

Merged
JiyaBatra merged 3 commits intoJiyaBatra:mainfrom
Aditya8369:49
Mar 14, 2026
Merged

fix: Insecure and simplistic authentication system exposing user data#52
JiyaBatra merged 3 commits intoJiyaBatra:mainfrom
Aditya8369:49

Conversation

@Aditya8369
Copy link
Copy Markdown
Contributor

Implemented a full client-side hardening pass for the authentication flow and page security headers.

What I changed

  1. Hardened credential handling in auth.js
  • Replaced plaintext password storage with PBKDF2 hashing (Web Crypto API) + per-user salt + iterations:
    • auth.js
    • auth.js
  • Stored user record now contains hash metadata instead of raw password.
  • Added legacy migration path for old plaintext users on next successful login:
    • auth.js
  1. Added input validation and sanitization in auth.js
  • Username sanitization and format checks:
    • auth.js
  • Email normalization + validation:
    • auth.js, auth.js
  • Password strength policy enforcement:
    • auth.js
  • Sign-up and sign-in handlers now validate before processing:
    • auth.js
    • auth.js
  1. Switched auth session state to sessionStorage with expiry
  • Added short-lived auth session object in sessionStorage:
    • auth.js
    • auth.js
    • auth.js
    • auth.js
  • Added enforced expiry window (2 hours):
    • auth.js
  • Updated page protection and navbar user display:
    • auth.js
    • auth.js
  • Logout now clears only session auth token:
    • auth.js
  • Old localStorage auth flags are cleaned up:
    • auth.js
  1. Updated sign-in/sign-up redirect checks to session-based auth
  • signin.html
  • signup.html
  1. Added CSP meta tags to protected/auth pages
  • signin.html
  • signup.html
  • index.html
  • about.html
  • contact.html
  • contribute.html
  • projects.html
  • index.html

Important security note

  • CSRF protection is fundamentally a server concern (cookie-bound sessions + CSRF token validation). In a static, client-only auth model, CSRF cannot be meaningfully enforced the same way.
  • This update is a safer stopgap, not production-grade authentication.
  • For real security, move auth to server-side (or Firebase/Auth provider), keep secrets off the client, and use HttpOnly secure cookies with backend session/token validation.

Validation

  • JavaScript/HTML checks show no new auth-related errors in changed auth files.
  • Existing non-auth warnings (e.g., playsinline compatibility and some form-label lint warnings) remain unchanged.

closes #49

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 13, 2026

@Aditya8369 is attempting to deploy a commit to the jiya's projects Team on Vercel.

A member of the Team first needs to authorize it.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 13, 2026

Deploy Preview for addminiproject failed.

Name Link
🔨 Latest commit 0693743
🔍 Latest deploy log https://app.netlify.com/projects/addminiproject/deploys/69b3fa4cb7953000089286fe

@JiyaBatra JiyaBatra added JWOC-Level-3 Advanced issues that involve complex implementation or significant feature development. JWOC-Bug Bug fixes assigned under JWOC contribution guidelines. Hard The issue is hard jwoc This project is under jwoc labels Mar 14, 2026
@JiyaBatra JiyaBatra merged commit 634e353 into JiyaBatra:main Mar 14, 2026
2 of 7 checks passed
@Aditya8369 Aditya8369 deleted the 49 branch March 26, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hard The issue is hard jwoc This project is under jwoc JWOC-Bug Bug fixes assigned under JWOC contribution guidelines. JWOC-Level-3 Advanced issues that involve complex implementation or significant feature development.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Insecure and simplistic authentication system exposing user data

2 participants