Skip to content

fix: address CodeQL security findings - #3

Merged
suguanYang merged 32 commits into
stagingfrom
fix/wangbinqi/codeql-findings
May 7, 2026
Merged

fix: address CodeQL security findings#3
suguanYang merged 32 commits into
stagingfrom
fix/wangbinqi/codeql-findings

Conversation

@suguanYang

@suguanYang suguanYang commented May 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add HMAC-based API key lookup hashing and a migration that disables legacy weak-hashed API keys
  • harden URL file-type detection and SNS subscription confirmation against SSRF with validation, no redirect following, and IP pinning
  • sanitize database health errors and remove the unnecessary database-info health API
  • avoid printing local/bootstrap credentials to stdout
  • add contract coverage for invalid URL redirects, SNS confirmation validation, database health sanitization, and API key hashing paths

Validation

  • /home/suguan/.local/bin/uv run --all-packages --group lint ruff check apps packages
  • /home/suguan/.local/bin/uv run --all-packages --group typecheck pyright --project pyproject.toml apps/api/app apps/api/main.py apps/worker/app apps/worker/worker.py packages/shared-python/shared
  • /home/suguan/.local/bin/uv run --project apps/api --group dev pytest apps/api/tests/contract/test_database_health_contract.py -q (4 passed)
  • /home/suguan/.local/bin/uv run --project apps/api --group dev pytest apps/api/tests/contract/test_api_key_contract.py apps/api/tests/contract/test_guest_registration_contract.py apps/api/tests/contract/test_job_creation_contract.py apps/api/tests/contract/test_s3_event_contract.py apps/api/tests/contract/test_database_health_contract.py -q (30 passed before removing the database-info endpoint/tests; affected health contract rerun now passes with 4 passed)
  • /home/suguan/.local/bin/uv run --project apps/api --group dev pytest apps/api/tests/contract/test_job_read_contract.py apps/api/tests/contract/test_webhook_contract.py apps/api/tests/contract/test_api_key_contract.py -q (15 passed)
  • CodeQL 2.25.2 python-security-extended.qls: security_extended_findings=0 on commit 3fd7868

Notes

  • The API-key migration intentionally deactivates existing API keys because old unsalted SHA-256 lookup hashes cannot be safely converted to the new keyed HMAC hashes without plaintext keys. Existing users should regenerate keys after this migration.

@suguanYang
suguanYang force-pushed the fix/wangbinqi/codeql-findings branch from 7cca790 to 3fd7868 Compare May 1, 2026 07:24
@suguanYang
suguanYang force-pushed the fix/wangbinqi/codeql-findings branch 2 times, most recently from 8507545 to 781ee64 Compare May 6, 2026 01:53
@suguanYang
suguanYang force-pushed the fix/wangbinqi/codeql-findings branch from 781ee64 to e9d3a39 Compare May 6, 2026 02:25
@github-advanced-security

Copy link
Copy Markdown
Contributor

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Comment thread packages/shared-python/shared/utils/api_keys.py Fixed
@suguanYang
suguanYang force-pushed the fix/wangbinqi/codeql-findings branch from f6a9f4f to 5cd99c6 Compare May 6, 2026 04:49
Comment thread apps/api/app/services/auth/api_key_service.py Fixed
@suguanYang
suguanYang force-pushed the fix/wangbinqi/codeql-findings branch 2 times, most recently from 7f65518 to 989444e Compare May 6, 2026 12:01
@suguanYang
suguanYang force-pushed the fix/wangbinqi/codeql-findings branch from 989444e to 928bb84 Compare May 6, 2026 12:48
Comment thread packages/shared-python/shared/models/database/job.py Fixed
Comment thread packages/shared-python/shared/models/database/job.py Fixed
Comment thread apps/worker/tests/contract/test_url_upload_contract.py Fixed
@suguanYang
suguanYang merged commit 7d6a94c into staging May 7, 2026
9 checks passed
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.

2 participants