Skip to content

Potential fix for code scanning alert no. 2: Clear text storage of sensitive information - #2

Merged
advanceddev merged 2 commits into
mainfrom
alert-autofix-2
Oct 30, 2026
Merged

advanceddev merged 2 commits into
mainfrom
alert-autofix-2

Conversation

@advanceddev

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/advanceddev/tbridge-sdk/security/code-scanning/2

To fix this without changing external behavior more than necessary, store secretKeyHex encrypted at rest whenever written to sessionStorage, and decrypt on read. In this file, the safest single-file approach is to add Web Crypto AES-GCM helpers and a per-origin key derivation from a caller-provided passphrase (via global), with graceful fallback (do not persist secret if crypto/key unavailable). Then update:

  • readSessionStorage call sites for STORAGE_KEYS.SESSION_SECRET to use decrypting reader.
  • writeSessionStorage call sites for STORAGE_KEYS.SESSION_SECRET to use encrypting writer.
  • Keep non-secret storage behavior unchanged.

Concretely in wallet/session.ts:

  1. Add helper functions:
    • UTF-8/base64 converters.
    • getSessionEncryptionPassphrase().
    • deriveAesKey(), encryptSecretForStorage(), decryptSecretFromStorage().
    • readEncryptedSessionSecret() and writeEncryptedSessionSecret().
  2. Replace direct secret writes (writeSessionStorage(..., secret)) with encrypted writer.
  3. Replace direct secret reads for SESSION_SECRET with decrypting reader.
  4. On failure to encrypt/decrypt, return null / remove invalid ciphertext rather than storing cleartext.

This addresses all listed alert variants at the same sink location.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

advanceddev and others added 2 commits October 30, 2026 15:10
…nsitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedqr@​0.5.5 ⏵ 0.7.2100100100 +191100

View full report

@advanceddev
advanceddev marked this pull request as ready for review October 30, 2026 10:25
@advanceddev
advanceddev merged commit 1d3cd1b into main Oct 30, 2026
6 checks passed
@advanceddev
advanceddev deleted the alert-autofix-2 branch October 30, 2026 10:26
advanceddev added a commit that referenced this pull request Nov 1, 2026
+ separate storage keys
+ PersistedSession.connectItems & restore lastConnectItems
+ move bytesToBase64 & base64ToBytes to core/encoding.ts
+ INVALID_PAYLOAD instead of damaged urls
+ display actionSheet for signData (as for sendTransaction)
+ read TBridgeStorageSecret once
+ (qr) Path2D batch fill instead of fillRect for every module
+ action sheet: Escape + simple focus-trap by tab
+ console.warn for EventEmitter.emit
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.

1 participant