Skip to content

🛡️ Sentinel: [HIGH/ENHANCEMENT] Fix timing attacks and improve charset consistency#28

Open
richkmeli wants to merge 1 commit intomasterfrom
sentinel-security-fixes-6593343978773098799
Open

🛡️ Sentinel: [HIGH/ENHANCEMENT] Fix timing attacks and improve charset consistency#28
richkmeli wants to merge 1 commit intomasterfrom
sentinel-security-fixes-6593343978773098799

Conversation

@richkmeli
Copy link
Owner

🚨 Severity: HIGH (Timing Attacks) / MEDIUM (Charset Consistency)
💡 Vulnerability:

  1. Sensitive comparisons for password hashes and tokens used String.equalsIgnoreCase(), which is susceptible to timing attacks.
  2. Cryptographic operations relied on the platform's default charset, potentially leading to inconsistencies.
  3. RandomStringGenerator created a new SecureRandom instance on every call.
  4. Temporary test files were not properly ignored in .gitignore.

🎯 Impact:

  1. Timing attacks could allow an attacker to guess valid tokens or password hashes by measuring response times.
  2. Charset inconsistencies could break cryptographic verification across different environments.
  3. Inefficient random number generation.
  4. Sensitive session/encrypted data could be accidentally committed.

🔧 Fix:

  1. Implemented constant-time comparison using java.security.MessageDigest.isEqual().
  2. Explicitly specified StandardCharsets.UTF_8 for all byte conversions.
  3. Refactored RandomStringGenerator to use a static SecureRandom instance.
  4. Updated .gitignore to include all temporary test files.

✅ Verification:

  1. Ran mvn test and all tests passed (BUILD SUCCESS).
  2. Verified changes in PasswordManager.java, TokenManager.java, SHA256.java, RandomStringGenerator.java, and .gitignore.

PR created automatically by Jules for task 6593343978773098799 started by @richkmeli

…t consistency

- Implement constant-time comparison for password hashes and tokens to mitigate timing attacks.
- Explicitly use StandardCharsets.UTF_8 for cryptographic operations to ensure consistency across environments.
- Use a single static SecureRandom instance in RandomStringGenerator for improved performance and security.
- Update .gitignore to exclude temporary test artifacts.

Co-authored-by: richkmeli <7313162+richkmeli@users.noreply.github.com>
@google-labs-jules
Copy link

👋 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.

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