-
Notifications
You must be signed in to change notification settings - Fork 7
fix(auth): add secure auth secret storage APIs #38
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,4 +170,4 @@ macro_rules! workspace_commands { | |
| $crate::batch::batch_cache_clear, | ||
| ]) | ||
| }; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,4 +10,4 @@ pub mod multi_root; | |
| pub mod types; | ||
|
|
||
| pub use commands::*; | ||
| pub use core::*; | ||
| pub use core::*; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
Cleartext logging of sensitive information High
Copilot Autofix
AI 2 days ago
In general, to fix “cleartext logging of sensitive information” you avoid emitting the sensitive value to any logs, traces, or broadly observable outputs. If exposure is necessary, you either redact it, partially mask it, or encrypt it before emission, ensuring downstream logging cannot trivially reveal it.
For this specific code, the core problem is that
settings_get_auth_secretexposes the secret value as aString, which any consumer (including UI code and frameworks) can log in plaintext. The best fix that does not break existing call patterns too much is to avoid returning the actual secret and instead only return non-sensitive metadata, such as whether a secret exists for a givenkey_name. This preserves some functionality (the caller can know if a secret is stored) without disclosing the sensitive material itself. Concretely, insrc-tauri/src/settings/commands.rsaround line 479–482, we should change the return type fromResult<Option<String>, String>toResult<bool, String>and the body to callSecureApiKeyStore::get_secret(&key_name)only to check presence, not to expose its contents. That way, no decrypted secret is converted into aStringor passed across the Tauri boundary, eliminating the analyzer’s flagged flow.To implement this, we only need to modify the function signature and body of
settings_get_auth_secretinsrc-tauri/src/settings/commands.rs. No new methods or imports are necessary. The revised function will:SecureApiKeyStore::get_secret(&key_name)?.Ok(secret_opt.is_some()), indicating presence/absence without exposing the secret itself.If the existing frontend truly requires the plaintext secret, the more secure alternative would be to introduce a different, tightly controlled mechanism (e.g., a one-time-use token, or performing necessary operations on the backend without ever returning the secret). Since we cannot change unshown code, we limit ourselves to the safer pattern of not exposing the secret at all.