Skip to content

Potential fix for code scanning alert no. 3: Storage of sensitive information in build artifact#70

Merged
Dargon789 merged 1 commit intodevelopfrom
alert-autofix-3
Feb 3, 2026
Merged

Potential fix for code scanning alert no. 3: Storage of sensitive information in build artifact#70
Dargon789 merged 1 commit intodevelopfrom
alert-autofix-3

Conversation

@Dargon789
Copy link
Copy Markdown
Owner

@Dargon789 Dargon789 commented Feb 3, 2026

Potential fix for https://github.com/Dargon789/Rabby/security/code-scanning/3

In general, the fix is to avoid injecting secrets or potentially sensitive environment variables into client-side build artifacts. Only non-sensitive, intentionally public values should be defined with webpack.DefinePlugin. Sensitive values must be kept server-side or obtained at runtime via a secure channel that does not bake them into static assets.

For this specific file, the minimal, non‑breaking change is to stop including process.env.SAFE_API_KEY (and, for consistency and security, also process.env.ETHERSCAN_KEY) in the DefinePlugin configuration. If these keys are truly needed at runtime, they should be obtained by some other mechanism outside of this snippet (for example, via a backend API or a runtime configuration file not committed to the bundle). Since we are constrained to the shown snippet and cannot introduce a new secure runtime mechanism here, the best we can do in this context is to remove the definitions that expose the keys.

Concretely, in build/webpack.common.config.js around lines 277–283, we will update the new webpack.DefinePlugin({...}) call to remove the process.env.ETHERSCAN_KEY and process.env.SAFE_API_KEY entries, leaving the non-sensitive fields (version, release, RABBY_BUILD_GIT_HASH) intact. No new imports or methods are needed; this is a straightforward configuration change within that plugin instantiation.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Summary by Sourcery

Bug Fixes:

  • Stop defining ETHERSCAN_KEY and SAFE_API_KEY in webpack.DefinePlugin to prevent sensitive keys from being embedded in build artifacts.

…ormation in build artifact

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Dargon789 <64915515+Dargon789@users.noreply.github.com>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Feb 3, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes sensitive environment variables from the webpack DefinePlugin configuration so they are no longer injected into client-side build artifacts, while preserving non-sensitive build metadata definitions.

Flow diagram for webpack DefinePlugin environment mappings

flowchart TD
  A[Start build] --> B[Load webpack.common.config.js]
  B --> C[Instantiate DefinePlugin]

  subgraph DefinePlugin_Before_PR
    C --> D1[Map process.env.version from VERSION]
    C --> D2[Map process.env.release from VERSION]
    C --> D3[Map process.env.RABBY_BUILD_GIT_HASH from BUILD_GIT_HASH]
    C --> D4[Map process.env.ETHERSCAN_KEY from ETHERSCAN_KEY]
    C --> D5[Map process.env.SAFE_API_KEY from SAFE_API_KEY]
  end

  subgraph DefinePlugin_After_PR
    C --> E1[Map process.env.version from VERSION]
    C --> E2[Map process.env.release from VERSION]
    C --> E3[Map process.env.RABBY_BUILD_GIT_HASH from BUILD_GIT_HASH]
  end

  E1 --> F[Emit client bundle]
  E2 --> F
  E3 --> F
  F --> G[End build]
Loading

File-Level Changes

Change Details Files
Stop injecting sensitive API keys into the frontend bundle via webpack.DefinePlugin.
  • Update the webpack.common.config.js configuration to remove process.env.ETHERSCAN_KEY from the DefinePlugin mapping.
  • Update the webpack.common.config.js configuration to remove process.env.SAFE_API_KEY from the DefinePlugin mapping while keeping non-sensitive fields (version, release, RABBY_BUILD_GIT_HASH) intact.
build/webpack.common.config.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@snyk-io
Copy link
Copy Markdown

snyk-io bot commented Feb 3, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @Dargon789, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request implements a crucial security enhancement by preventing the accidental exposure of sensitive API keys within client-side build artifacts. By modifying the Webpack configuration, it ensures that ETHERSCAN_KEY and SAFE_API_KEY are no longer bundled, thereby mitigating a potential code scanning alert and strengthening the application's overall security posture.

Highlights

  • Security Vulnerability Fix: Addresses code scanning alert [Snyk] Security upgrade @trezor/connect-webextension from 9.2.2 to 9.3.0 #3 by preventing the storage of sensitive information (API keys) in client-side build artifacts.
  • Webpack Configuration Update: Removes process.env.ETHERSCAN_KEY and process.env.SAFE_API_KEY from the webpack.DefinePlugin configuration in build/webpack.common.config.js.
  • Enhanced Security Posture: Improves the application's security by ensuring sensitive API keys are not exposed in static assets, aligning with best practices for handling secrets.
Changelog
  • build/webpack.common.config.js
    • Removed process.env.ETHERSCAN_KEY from the webpack.DefinePlugin configuration.
    • Removed process.env.SAFE_API_KEY from the webpack.DefinePlugin configuration.
Activity
  • The pull request was created to address a security code scanning alert.
  • The proposed changes were generated with the assistance of Copilot Autofix.
  • No further human activity (comments, reviews, approvals) has been recorded yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly addresses a critical security vulnerability by removing sensitive API keys (ETHERSCAN_KEY and SAFE_API_KEY) from the webpack build configuration. This change prevents these keys from being embedded in the client-side bundle, which is the proper way to resolve the "Storage of sensitive information in build artifact" security alert. The fix is precise and effectively mitigates the risk. The change is approved as it stands.

@Dargon789 Dargon789 marked this pull request as ready for review February 3, 2026 13:56
Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Now that ETHERSCAN_KEY and SAFE_API_KEY are no longer injected at build time, consider auditing any frontend references to these env vars and adding explicit handling or fallbacks for the undefined case to avoid runtime errors or confusing behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Now that ETHERSCAN_KEY and SAFE_API_KEY are no longer injected at build time, consider auditing any frontend references to these env vars and adding explicit handling or fallbacks for the undefined case to avoid runtime errors or confusing behavior.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Dargon789 Dargon789 merged commit 371b866 into develop Feb 3, 2026
18 of 20 checks passed
@Dargon789 Dargon789 deleted the alert-autofix-3 branch February 3, 2026 14:00
@Dargon789 Dargon789 linked an issue Feb 3, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

# Sequence diagram for Safe walletSendCalls batch transaction flow

1 participant