Skip to content

feat(suite-desktop): turn on ASAR integrity check#16951

Merged
Lemonexe merged 1 commit into
developfrom
feat/ASAR-verification
Feb 12, 2025
Merged

feat(suite-desktop): turn on ASAR integrity check#16951
Lemonexe merged 1 commit into
developfrom
feat/ASAR-verification

Conversation

@Lemonexe
Copy link
Copy Markdown
Contributor

Description

Turn on ASAR integrity check on Windows & macOS.

ℹ️ Duplicate of private PR.
See the private PR for extended description.

Related Issue

See the private PR

@Lemonexe Lemonexe added the no-project This label is used to specify that PR doesn't need to be added to a project label Feb 12, 2025
@Lemonexe Lemonexe marked this pull request as ready for review February 12, 2025 11:19
@Lemonexe Lemonexe requested a review from komret as a code owner February 12, 2025 11:19
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 12, 2025

Walkthrough

This pull request updates the Electron builder configuration by adding a new section that introduces additional security-related settings. A new object is added to the configuration which includes two Boolean properties: one that enables embedded ASAR integrity validation and another that restricts loading the application only from ASAR archives. These settings are appended to the existing module exports in the configuration file, with no modifications made to any current configurations. The changes are strictly additive and pertain specifically to how packaged Electron applications are handled, ensuring that integrity checks and loading constraints are enforced.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1ea07e and 251834f.

📒 Files selected for processing (1)
  • packages/suite-desktop/electron-builder-config.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=other, trezor-user-env-unix)
  • GitHub Check: run-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: build-web
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: Analyze with CodeQL (javascript)
🔇 Additional comments (1)
packages/suite-desktop/electron-builder-config.js (1)

165-169: LGTM! Security enhancement for ASAR integrity.

The addition of electronFuses configuration enhances application security by enabling ASAR integrity validation and restricting app loading to ASAR archives. This is a good security practice.

Let's verify the latest documentation about these security features:

✅ Verification successful

🌐 Web query:

What are Electron Fuses and what security benefits do they provide for ASAR integrity validation?

💡 Result:

Electron Fuses are configuration settings embedded within Electron-based applications that enable or disable specific features at the binary level. These "magic bits" act as security switches, allowing developers to harden their apps against tampering and unauthorized code execution[4][5][10].

Security Benefits for ASAR Integrity Validation

ASAR (Archive Shell ARchive) files package an Electron app's source code. ASAR integrity validation ensures these files remain unmodified during runtime. Key security benefits provided by Electron Fuses include:

  1. Tamper Detection

    • Enables runtime validation of ASAR file hashes stored in the app binary[4][9].
    • Triggers app termination if hash mismatches occur (e.g., due to malicious edits or corruption)[4][5].
  2. Code Isolation

    • The OnlyLoadAppFromAsar fuse restricts code loading strictly to app.asar, blocking alternative paths like app directories that attackers could exploit[5][6].
  3. Bypass Prevention

    • Combining EnableEmbeddedAsarIntegrityValidation with OnlyLoadAppFromAsar prevents directory-based attacks where malicious files mimic ASAR structures[3][9].
  4. Platform-Specific Protections

    • Validates macOS apps via Info.plist entries and Windows apps via resource entries, ensuring cross-platform consistency in integrity checks[4][5].

Implementation Requirements

  • Requires Electron ≥16.0.0 (macOS) or ≥30.0.0 (Windows)[4].
  • Build tools like Electron Forge/Packager auto-generate hashes during packaging[4][6].
  • Example fuse configuration:
    flipFuses(appPath, {
      [FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
      [FuseV1Options.OnlyLoadAppFromAsar]: true
    });  
    This ensures both validation and strict ASAR loading[5][6].

By enforcing cryptographic checks and restricting code sources, Electron Fuses mitigate risks like supply chain attacks and unauthorized code injection[9][10].

Citations:


Action: Security Configuration Reviewed

The new electronFuses settings correctly match Electron’s recommendations for enforcing ASAR integrity and restricting app loading to ASAR archives. The configuration in packages/suite-desktop/electron-builder-config.js (lines 165-169) aligns with the documented security benefits such as tamper detection, code isolation, and bypass prevention.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Lemonexe
Copy link
Copy Markdown
Contributor Author

merging despite failing test, see slack convo

@Lemonexe Lemonexe merged commit 7282d84 into develop Feb 12, 2025
@Lemonexe Lemonexe deleted the feat/ASAR-verification branch February 12, 2025 13:34
@bosomt
Copy link
Copy Markdown
Contributor

bosomt commented Feb 13, 2025

QA NOK

latest dev build on Win works as expected
latest dev build on macARM wont start see attached text info from Apple

Screenshot 2025-02-13 at 08 04 04

https://pastebin.com/FJy7Z35q

@bosomt bosomt added the QA NOK Issue doesn't pass the QA and some changes are needed. label Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-project This label is used to specify that PR doesn't need to be added to a project QA NOK Issue doesn't pass the QA and some changes are needed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants