Skip to content

[codex] Harden dashboard and Discord security boundaries#324

Merged
michaelmwu merged 5 commits into
mainfrom
michaelmwu/audit-discord-dashboard-security
Jun 3, 2026
Merged

[codex] Harden dashboard and Discord security boundaries#324
michaelmwu merged 5 commits into
mainfrom
michaelmwu/audit-discord-dashboard-security

Conversation

@michaelmwu

Copy link
Copy Markdown
Member

Summary

  • make CRM Discord followup responses explicitly ephemeral to reduce accidental public disclosure
  • split external webhook authentication onto WEBHOOK_SHARED_SECRET, with API_SHARED_SECRET fallback for compatibility
  • keep internal protected routes on API_SHARED_SECRET and document the new webhook secret

Notes

  • Per request, DISCORD_LINK_REQUIRE_OIDC_IDENTITY_CHECKS=false still allows direct Discord-backed dashboard link consumption. This PR does not force those links through SSO.

Validation

  • ./scripts/test.sh: 1653 passed, 20 skipped, 10 warnings
  • focused smoke: Discord dashboard login, dashboard Playwright interactivity, webhook/internal secret isolation
  • commit hooks: ruff, ruff format, mypy

Copilot AI review requested due to automatic review settings June 2, 2026 17:47
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@michaelmwu, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 4 minutes and 3 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1c2f8636-475d-4933-a7ad-37729cfe7369

📥 Commits

Reviewing files that changed from the base of the PR and between 64541c3 and 83e91ac.

📒 Files selected for processing (8)
  • .env.example
  • apps/api/src/five08/backend/api.py
  • apps/discord_bot/src/five08/discord_bot/cogs/crm.py
  • docs/configuration.md
  • packages/shared/src/five08/settings.py
  • scripts/dev-up.sh
  • tests/unit/test_backend_api.py
  • tests/unit/test_crm.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch michaelmwu/audit-discord-dashboard-security

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 and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

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 hardens security boundaries between internal dashboard/protected API routes and externally callable webhook endpoints, and reduces accidental Discord data disclosure by making CRM command followups explicitly ephemeral.

Changes:

  • Make many Discord CRM followup responses explicitly ephemeral=True (and update unit tests accordingly).
  • Split webhook authentication to prefer WEBHOOK_SHARED_SECRET, falling back to API_SHARED_SECRET only when the webhook secret is unset, plus add unit tests to assert the isolation.
  • Document the new WEBHOOK_SHARED_SECRET configuration in docs and .env.example.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
apps/api/src/five08/backend/api.py Introduces separate webhook auth (_is_webhook_authorized) and refactors secret validation helper.
packages/shared/src/five08/settings.py Adds webhook_shared_secret to shared settings.
docs/configuration.md Documents WEBHOOK_SHARED_SECRET and fallback behavior.
.env.example Adds WEBHOOK_SHARED_SECRET example and comments.
apps/discord_bot/src/five08/discord_bot/cogs/crm.py Makes CRM-related Discord followup messages ephemeral across multiple commands/flows.
tests/unit/test_backend_api.py Adds tests asserting webhook/internal secret isolation.
tests/unit/test_crm.py Updates assertions to expect ephemeral followup sends.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +419 to 428
"""Validate an X-API-Secret header against one configured secret."""
if not configured_secret:
logger.error("Rejecting request: %s is not configured", setting_name)
return False

provided_secret = request.headers.get("X-API-Secret", "")
if secrets.compare_digest(provided_secret, settings.api_shared_secret):
if secrets.compare_digest(provided_secret, configured_secret):
return True
logger.warning("Rejecting request: invalid X-API-Secret")
logger.warning("Rejecting request: invalid X-API-Secret for %s", setting_name)
return False
Comment on lines +440 to +453
def _is_webhook_authorized(request: Request) -> bool:
"""Validate the external webhook secret, with legacy API secret fallback."""
if settings.webhook_shared_secret:
return _is_authorized_with_secret(
request,
configured_secret=settings.webhook_shared_secret,
setting_name="WEBHOOK_SHARED_SECRET",
)

return _is_authorized_with_secret(
request,
configured_secret=settings.api_shared_secret,
setting_name="API_SHARED_SECRET",
)
Comment thread .env.example Outdated
Comment on lines +69 to +73
# Required: ingest requests are rejected when unset
API_SHARED_SECRET=
# Optional: separate secret for external /webhooks/* callers. When unset,
# webhook routes fall back to API_SHARED_SECRET for compatibility.
WEBHOOK_SHARED_SECRET=

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a558d77c2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

)

await interaction.followup.send(embed=embed)
await interaction.followup.send(embed=embed, ephemeral=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Defer the resume confirmation ephemerally

For the duplicate-resume confirmation button, this first followup still becomes the deferred original response because confirm_upload() deferred earlier with interaction.response.defer() rather than defer(ephemeral=True). Discord preserves the defer response's visibility and ignores ephemeral=True on that first followup, so accepting the upload can still publish the success embed with the contact name, file name, and CRM link to the channel instead of only to the clicking user.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@michaelmwu
michaelmwu merged commit b03caf8 into main Jun 3, 2026
7 checks passed
@michaelmwu
michaelmwu deleted the michaelmwu/audit-discord-dashboard-security branch June 3, 2026 01:27
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