Conversation
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



related dekstop app APIS: phcode-dev/phoenix-desktop#635
KernalModeTrust
Overview
KernalModeTrust is a security mechanism in Phoenix that provides a trust base for core components before any extensions
are loaded. It establishes a secure communication channel between core modules and the Tauri shell, preventing
unauthorized access to sensitive information by extensions or other potentially malicious code.
Purpose
The primary purposes of KernalModeTrust are:
extensions.
extensions.
Implementation Details
Trust Ring Initialization
The trust ring is initialized at boot time before any extensions are loaded:
window.KernalModeTrustobject.initTrustRing()function.The trust ring has several important security characteristics:
encrypted with this key. This means extensions can still call sensitive APIs but will receive only encrypted garbage
responses without access to the trust key.
Security Model
KernalModeTrust implements a strict security model:
window.KernalModeTrustis deleted to prevent extensions fromaccessing it.
critical security requirement. If not dismantled, the old trust keys will still be in place when the page reloads,
but the application will lose access to them (as they were only stored in memory). As a result, the Tauri shell will
not trust any sensitive API calls from the reloaded page, as these calls will rely on the old keys that the new page
instance cannot access. This security measure intentionally prevents any page reload from maintaining trust without
explicitly dismantling the old trust ring first, ensuring that malicious code cannot bypass security by simply
reloading the window.
Cryptographic Implementation
KernalModeTrust uses strong cryptography:
Security Considerations
Extension Isolation: Extensions should never have access to KernalModeTrust to prevent potential security
breaches.
One-time Trust: The trust ring can only be set once per Tauri window, preventing malicious code from replacing
it.
Complete Dismantling: When dismantling the keyring, it's recommended to reload the page immediately to prevent
any potential exploitation of the system.
Test Environment Handling: Special handling exists for test environments to ensure tests can run properly without
compromising security.
Conclusion
KernalModeTrust is a critical security component in Phoenix that establishes a trust boundary between core components
and extensions. By providing secure communication channels and API key management, it helps maintain the overall
security posture of the application.