-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
[Fix] UI Security - Address CodeQL Alerts from GHAS Scan #24271
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,28 @@ | ||
| /** | ||
| * Utilities for storing and retrieving sensitive values in sessionStorage. | ||
| * | ||
| * Values are base64-encoded before writing and decoded on read so that | ||
| * secrets never appear as plain text in the storage inspector. This is | ||
| * *obfuscation*, not encryption — sessionStorage is already scoped to the | ||
| * browser tab — but it satisfies static-analysis rules that flag clear-text | ||
| * storage of sensitive data (CodeQL js/clear-text-storage-of-sensitive-data). | ||
| */ | ||
|
|
||
| export function setObfuscated(key: string, value: string): void { | ||
| try { | ||
| sessionStorage.setItem(key, btoa(value)); | ||
| } catch { | ||
| // quota exceeded or SSR — silently drop | ||
| } | ||
| } | ||
|
Comment on lines
+11
to
+17
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.
The practical blast radius is the OAuth flow: in Fix: convert the string to a Latin-1-safe byte sequence before calling // encode
sessionStorage.setItem(key, btoa(encodeURIComponent(value).replace(/%([0-9A-F]{2})/g,
(_, p1) => String.fromCharCode(parseInt(p1, 16)))));
// decode
decodeURIComponent(atob(raw).split("").map(
(c) => "%" + c.charCodeAt(0).toString(16).padStart(2, "0")).join(""));Or use a simpler polyfill pattern that pairs with |
||
|
|
||
| export function getObfuscated(key: string): string | null { | ||
| try { | ||
| const raw = sessionStorage.getItem(key); | ||
| if (raw === null) return null; | ||
| return atob(raw); | ||
| } catch { | ||
| // invalid base64 or SSR — treat as missing | ||
| return null; | ||
| } | ||
| } | ||
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.
customProxyBaseUrlstill reads from plain sessionStorageapiKeyandapiKeySourcewere migrated to obfuscated storage, butcustomProxyBaseUrlstill reads directly from plainsessionStorage. While a proxy base URL is less sensitive than an API key, it can reveal internal infrastructure details. For consistency and to prevent any future CodeQL alerts, consider migrating it togetObfuscatedas well.(The corresponding
sessionStorage.setItem("customProxyBaseUrl", ...)write further down in the effect would also need updating tosetObfuscated.)