Skip to content

Use hmac.compare_digest in check_telegram_authorization #203

Description

@YaronZaki
  • Difficulty: good-first-issue · Effort: XS · Impact: Telegram bot auth

  • Problem Statement
    quantara/web_app/telegram/utils.py:

    if hash_value != check_hash:
        return False

    String equality != short-circuits on first byte mismatch. A timing
    attacker who can observe the auth endpoint signing latency can in
    principle recover a valid hash byte-by-byte.

  • Expected Outcome
    Replace with hmac.compare_digest(hash_value, check_hash).

  • Acceptance Criteria

    • Existing tests pass.
    • Micro-benchmark: 100k iterations of full-vs-prefix mismatch shows all within 0.001ms.
  • Implementation Notes
    One-line. Both arguments must be str for compare_digest; cast if needed.

  • Files / Modules Affected

    • quantara/web_app/telegram/utils.py
    • quantara/web_app/tests/test_telegram.py
  • Dependencies: standalone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26priority/P1Imported from PRODUCTION_ISSUES.mdsecuritytimingImported from PRODUCTION_ISSUES.md

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions