Skip to content

fix: reject non-ASCII webhook signatures without raising - #269

Draft
Kayvan-Zahiri wants to merge 1 commit into
Flagsmith:mainfrom
Kayvan-Zahiri:codex/reject-non-ascii-webhook-signatures
Draft

Kayvan-Zahiri wants to merge 1 commit into
Flagsmith:mainfrom
Kayvan-Zahiri:codex/reject-non-ascii-webhook-signatures

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Problem

verify_signature() promises a boolean but hmac.compare_digest() only accepts ASCII strings. A malformed non-ASCII received signature (for example "é") raises TypeError instead of returning False. A webhook consumer that branches on the boolean can therefore raise unexpectedly on this invalid input.

Change

Return False for non-ASCII signature strings. A valid SHA-256 hex digest is always ASCII, and valid/invalid ASCII comparisons continue to use the existing constant-time hmac.compare_digest() unchanged.

Add regressions for Latin-1, emoji, a digest-length malformed value and a lone surrogate, with both text and bytes request bodies.

Validation

  • Before: all 8 new cases fail with TypeError; 3 existing tests pass.
  • After: full pytest tests -q suite: 144 passed.
  • Full SDK/test Black and isort checks, Flake8, MyPy (18 source files), and git diff --check pass.

Python 3.12, local editable SDK with declared dependency constraints. Formatter/linter versions match the repository hook pins. No hosted Flagsmith API requests or webhook deployment were used. No public signature or valid-signature behavior change.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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