Skip to content

πŸ”’ [security fix] generic error messages to prevent data leakage#18

Draft
GreyC wants to merge 1 commit intomainfrom
fix-security-data-leakage-logging-246991289367186616
Draft

πŸ”’ [security fix] generic error messages to prevent data leakage#18
GreyC wants to merge 1 commit intomainfrom
fix-security-data-leakage-logging-246991289367186616

Conversation

@GreyC
Copy link
Owner

@GreyC GreyC commented Mar 13, 2026

🎯 What

Fixed a security vulnerability where raw error logging could leak sensitive internal information (e.g., file paths, API response details, or stack traces) to the console.

⚠️ Risk

Raw error messages can contain sensitive data about the system's internal state, configuration, or external dependencies, providing potentially useful information to an attacker or exposing user data.

πŸ›‘οΈ Solution

  • Introduced a centralized logError function in packages/cli/src/logger.ts.
  • Replaced all raw console.error(..., error.message) calls with generic user-friendly messages.
  • Added a global -d, --debug flag and support for the DEBUG environment variable to allow opt-in access to detailed error logs for troubleshooting.
  • Updated packages/cli/src/index.ts and packages/cli/src/auth.ts to use the new logging utility consistently.

PR created automatically by Jules for task 246991289367186616 started by @GreyC

This commit addresses a potential data leakage vulnerability where raw error messages
were being logged to standard output. A new centralized `logError` utility has been
introduced, and a global `--debug` flag (and `DEBUG` environment variable) now controls
the display of detailed error information and stack traces.

- Created `packages/cli/src/logger.ts` for secure error logging.
- Modified `packages/cli/src/index.ts` to use generic error messages and support `--debug`.
- Updated `packages/cli/src/auth.ts` to use the new logger.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 enhances the security posture of the CLI by implementing a controlled error logging mechanism. It addresses a potential vulnerability where raw error messages could inadvertently expose sensitive internal information. The changes ensure that by default, only generic, user-friendly error messages are displayed, while providing an explicit debug option for developers to access detailed error information when needed.

Highlights

  • Centralized Error Logging: Introduced a new logError utility function in packages/cli/src/logger.ts to centralize error handling and prevent sensitive data leakage.
  • Generic Error Messages: Replaced direct console.error calls with the new logError function, ensuring that user-facing error messages are generic and do not expose internal details.
  • Opt-in Debugging: Added a global -d, --debug flag and support for the DEBUG environment variable, allowing developers to opt-in to detailed error logs for troubleshooting purposes.
Changelog
  • packages/cli/src/auth.ts
    • Imported the new logError utility.
    • Replaced existing console.error calls with logError for secure error reporting.
  • packages/cli/src/index.ts
    • Imported the new logError utility.
    • Added a global --debug option to the CLI program.
    • Updated all command actions to capture the debug flag.
    • Replaced numerous console.error calls with logError, passing the error object and the debug flag.
  • packages/cli/src/logger.ts
    • Added a new file containing the logError function.
    • Implemented logic within logError to display generic messages by default and detailed error information (message and stack) only when debug mode is active.
Activity
  • PR created automatically by Jules for task 246991289367186616 started by @GreyC.
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

@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 introduces a centralized logError function to provide generic error messages by default, which is a great security improvement to prevent leaking sensitive information. Detailed error information is now only displayed when the --debug flag or DEBUG environment variable is enabled. The changes are well-implemented across the CLI commands in index.ts and auth.ts. I have one suggestion to improve the robustness of the new logError function to handle different types of errors and avoid redundant output in debug mode.

Comment on lines +6 to +13
if (isDebug && error) {
if (error.message) {
console.error(`Debug info: ${error.message}`);
}
if (error.stack) {
console.error(error.stack);
}
}

Choose a reason for hiding this comment

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

medium

The current implementation for logging debug information can be improved. It may not log anything for non-Error objects (like strings), and it produces redundant output for Error objects since error.stack usually includes error.message.

To make the debug logging more robust and concise, I suggest prioritizing error.stack, then falling back to error.message, and finally logging the raw error object if neither is available. This ensures all error types are handled and avoids duplicate information.

  if (isDebug && error) {
    if (error.stack) {
      console.error(error.stack);
    } else if (error.message) {
      console.error(`Debug info: ${error.message}`);
    } else {
      console.error('Debug info:', error);
    }
  }

Copy link
Owner Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi! I see you mentioned me on the logError implementation. I've designed this function to hide detailed error information (like internal messages and stack traces) from the standard output by default.

Detailed info is only logged if the user explicitly opts in via the -d/--debug flag or the DEBUG environment variable. This ensures that sensitive data isn't accidentally leaked during normal operation, fulfilling the security requirement while maintaining a path for troubleshooting.

If you'd like me to redirect these debug logs to a local log file instead of stderr, please let me know and I'll be happy to make that change!

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.

1 participant