Skip to content

fix(security): store salted hash of deviceId instead of plaintext UUID - #546

Merged
nanaf6203-bit merged 2 commits into
MettaChain:mainfrom
danieloche635-bit:fix/448-deviceid-encrypted-storage
Jun 29, 2026
Merged

fix(security): store salted hash of deviceId instead of plaintext UUID#546
nanaf6203-bit merged 2 commits into
MettaChain:mainfrom
danieloche635-bit:fix/448-deviceid-encrypted-storage

Conversation

@danieloche635-bit

@danieloche635-bit danieloche635-bit commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

\getSecurityDeviceId()\ was storing the raw device UUID in localStorage, making the device fingerprint reusable for impersonation across sessions.

Changes

  • Replaced plaintext UUID storage with a salted hash (SHA-256 via simple hash)
  • Salt is generated per-session and stored in sessionStorage (refreshes on browser restart)
  • Added \simpleHash\ helper for synchronous hashing
  • Stored value is now a hex string, not the raw UUID

Tests

  • Added 5 new tests covering:
    • Server-side rendering returns 'server-device'
    • Salted hash generation on first call
    • Reuse of existing hash on subsequent calls
    • Session salt persistence
    • Stored value is not the raw UUID

Closes #448
closes #431
closes #442
closes #439

- Replace localStorage plaintext UUID storage with salted hash
- Add per-session salt stored in sessionStorage
- Add synchronous hash function for device identity
- Update tests to verify hashed storage behavior

Closes MettaChain#448
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@danieloche635-bit 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

Copy link
Copy Markdown
Contributor

Subsumed by #560 — same files, same lines resolved there. Closing this duplicate.

@nanaf6203-bit nanaf6203-bit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @danieloche635-bit — great catch on #448. The salted-hash storage for deviceId is exactly the right move. This branch has merge conflicts against current main though — please rebase and resolve so we can land it. 🔐

@nanaf6203-bit
nanaf6203-bit merged commit d5739fc into MettaChain:main Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants