Skip to content

Fix sign check by verifying timestamp #111

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SilianZ
Copy link
Member

@SilianZ SilianZ commented Jul 23, 2025

Summary

  • validate cluster signatures using check_sign
  • reject signatures older than 5 minutes

Testing

  • python -m py_compile $(git ls-files '*.py')

https://chatgpt.com/codex/tasks/task_e_6880ab1b8430832b90e5351ceeeecd77

@SilianZ SilianZ requested a review from Copilot July 23, 2025 11:36
Copy link

@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 enhances security by adding timestamp validation to cluster signature verification. The change ensures that signatures are rejected if they are older than 5 minutes, preventing replay attacks.

  • Replaces check_sign_without_time with check_sign to include timestamp validation
  • Adds automatic rejection of signatures older than 5 minutes

@@ -261,7 +261,7 @@ async def access_log_middleware(request: fastapi.Request, call_next):

def get_cluster_from_sign(hash: str, s: str, e: str) -> Optional[str]:
for cluster in clusters.clusters:
if check_sign_without_time(hash, cluster._token._secret, s, e):
if check_sign(hash, cluster._token._secret, s, e):
Copy link
Preview

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

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

The timestamp validation logic in check_sign uses time.time() - 300 < int(e, 36) which could allow future timestamps to be valid. Consider using abs(time.time() - int(e, 36)) < 300 to reject both old and future timestamps, or add an explicit check that int(e, 36) <= time.time() to prevent acceptance of future-dated signatures.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant