8000 fix(auth): use subtle for constant time key comparison, fix lower case key issue by JannikSt · Pull Request #526 · PrimeIntellect-ai/protocol · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(auth): use subtle for constant time key comparison, fix lower case key issue #526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 22, 2025

Conversation

JannikSt
Copy link
Member

No description provided.

@JannikSt JannikSt requested a review from Copilot June 22, 2025 07:31
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces a case-insensitive lowercase comparison with a constant-time key check, refines how the Authorization header is parsed, and adds tests for multiple bearer-scheme edge cases.

  • Use subtle::ConstantTimeEq for secure API key comparison
  • Parse and validate the "Bearer " scheme more precisely
  • Add comprehensive tests for valid, invalid, missing, and malformed headers

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/shared/src/security/api_key_middleware.rs Import subtle, implement constant-time comparison, refine parsing, and add tests
crates/shared/Cargo.toml Add subtle = "2.6.1" dependency
Comments suppressed due to low confidence (1)

crates/shared/src/security/api_key_middleware.rs:60

  • [nitpick] The nested if blocks lead to deep indentation. You could early-return on invalid conditions to flatten the logic, improving readability and reducing nesting.
                if auth_str.len() > 7 {

@JannikSt JannikSt merged commit dd84f2f into develop Jun 22, 2025
1 check passed
@JannikSt JannikSt deleted the fix/api-key-middleware-constant-time branch June 25, 2025 12:31
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
0