Skip to content

πŸ›‘οΈ Sentinel: [HIGH] Use cryptographically secure random number generator in New-GTPassword - #94

Closed
MARCO-K wants to merge 1 commit into
mainfrom
sentinel-crypto-random-password-470596087676312878
Closed

MARCO-K wants to merge 1 commit into
mainfrom
sentinel-crypto-random-password-470596087676312878

Conversation

@MARCO-K

@MARCO-K MARCO-K commented Sep 27, 2026

Copy link
Copy Markdown
Owner

🚨 Severity: HIGH
πŸ’‘ Vulnerability: New-GTPassword used Get-Random which is not cryptographically secure to generate random characters for passwords.
🎯 Impact: Attackers could potentially predict the output of Get-Random and compromise generated passwords.
πŸ”§ Fix: Replaced Get-Random with [System.Security.Cryptography.RandomNumberGenerator]::Create() and securely generated random bytes to shuffle and select characters. Used bitwise AND to avoid integer overflow from Int32.MinValue.
βœ… Verification: Verify that passwords generated by New-GTPassword use strong randomness and meet complexity requirements.


PR created automatically by Jules for task 470596087676312878 started by @MARCO-K

…tor in New-GTPassword

Co-authored-by: MARCO-K <17045768+MARCO-K@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
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.

Copilot AI lite review requested due to automatic review settings September 27, 2026 19:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟑 Changes recommended

The new selection/shuffle logic still introduces avoidable randomness bias (modulo + sort-by-random) and RNG disposal is not exception-safe, which undermines the security goal of the change.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

This PR hardens New-GTPassword by replacing Get-Random with System.Security.Cryptography.RandomNumberGenerator to ensure generated passwords use cryptographically strong randomness, aligning with GraphTools’ security-focused incident response tooling.

Changes:

  • Replaced Get-Random-based character selection with a CSPRNG-driven selection helper.
  • Updated password shuffling to use CSPRNG-derived randomness instead of Get-Random.
  • Added a Sentinel learning note documenting the original weakness and the safer pattern.
File Description
internal/​functions/​New-GTPassword.ps1 Switches password generation from Get-Random to a cryptographic RNG and updates selection/shuffle logic.
.jules/​sentinel.md Documents the vulnerability and recommended prevention pattern for future changes.

πŸ’‘ Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +35 to +37
# Initialize cryptographic random number generator
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()

@MARCO-K

MARCO-K commented Sep 28, 2026

Copy link
Copy Markdown
Owner Author

Closed in favor of #93.

@MARCO-K MARCO-K closed this Sep 28, 2026
@MARCO-K
MARCO-K deleted the sentinel-crypto-random-password-470596087676312878 branch September 28, 2026 06:46
@google-labs-jules

Copy link
Copy Markdown
Contributor

Closed in favor of #93.

Understood. Acknowledging that this work is closed in favor of #93 and stopping work on this PR.

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.

2 participants