Skip to content

fix(seer-rpc): Enforce seer rpc signature #93253

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 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/sentry/api/endpoints/seer_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,12 @@ def compare_signature(url: str, body: bytes, signature: str) -> bool:
)

if not signature.startswith("rpc0:"):
logger.error("Seer RPC signature validation failed: invalid signature prefix")
return False

if not body:
logger.error("Seer RPC signature validation failed: no body")
# TODO: For stability and backward compatibility, we are allowing all signatures
# while we deploy the fix to both services. But we are logging an error if it fails.
return True
return False

try:
# We aren't using the version bits currently.
Expand All @@ -85,17 +84,14 @@ def compare_signature(url: str, body: bytes, signature: str) -> bool:
computed = hmac.new(key.encode(), signature_input, hashlib.sha256).hexdigest()
is_valid = hmac.compare_digest(computed.encode(), signature_data.encode())
if is_valid:
logger.info("Seer RPC signature validated")
return True
except Exception:
logger.exception("Seer RPC signature validation failed")
Comment on lines 88 to 89
Copy link
Member

Choose a reason for hiding this comment

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

can we throw the exception message in the log if that would be useful?

Copy link
Member Author

Choose a reason for hiding this comment

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

logger.exception should log the latest exception to sentry without explicitly passing the exception (and precommit complains if you do lol)

return True
return False

logger.error("Seer RPC signature validation failed")

# TODO: For stability and backward compatibility, we are allowing all signatures
# while we deploy the fix to both services. But we are logging an error if it fails.
return True
return False


@AuthenticationSiloLimit(SiloMode.CONTROL, SiloMode.REGION)
Expand Down
Loading