-
Notifications
You must be signed in to change notification settings - Fork 1.6k
security: implement credential masking via XOR to protect sensitive user data in RAM. #2941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||
| /** | ||||||
| * Copyright (C) dev12124 (dev brazilian, João Guilherme da Silva Freitas Lima), | ||||||
| * License: MIT license. | ||||||
| */ | ||||||
|
|
||||||
| /** | ||||||
| * Mask key used to obfuscate sensitive Acode credentials. | ||||||
| * In JavaScript, plain text variables (e.g., let key = "secret password") | ||||||
| * reside in the RAM unprotected, making them vulnerable to access or modification | ||||||
| * by malicious installed plugins. | ||||||
| */ | ||||||
| const MASK_KEY = 0x5A; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
How this was verified: Plugin scripts share the page that writes the masked cache, and the stored numbers are reversed with the fixed key present in the client code. Knowledge Base Used: Plugins and platform services |
||||||
|
|
||||||
| // Applies a XOR mask to secure sensitive strings | ||||||
| export function maskCredential(secretString) { | ||||||
| if (!secretString) return []; | ||||||
|
|
||||||
| // Transforms the string into a masked array of bytes (numbers) | ||||||
| return Array.from(secretString).map(char => char.charCodeAt(0) ^ MASK_KEY); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| // Removes the XOR mask to restore the original string | ||||||
| export function unmaskCredential(maskedArray) { | ||||||
| if (!Array.isArray(maskedArray)) return " "; | ||||||
|
|
||||||
| // Removes the mask | ||||||
| return maskedArray | ||||||
| .map(byte => String.fromCharCode(byte ^ MASK_KEY)) | ||||||
| .join(""); | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/loginrequest that fails, such as while offline, returns that cache without decrypting it. Callers receive arrays instead of strings, so the sidebar can display numbers for the email or throw while generating an avatar from the name.