Skip to content

Seal the in-game verification relay and keep secrets out of URLs - #96

Merged
valzargaming merged 6 commits into
mainfrom
claude/project-thread-98pyx5
Nov 13, 2026
Merged

valzargaming merged 6 commits into
mainfrom
claude/project-thread-98pyx5

Conversation

@valzargaming

Copy link
Copy Markdown
Member

Fixes the two findings from the security review of in-game Discord verification (#93).

  • Relay (desktop bot to primary bot): the request and the answer are now encrypted end to end with AES-256-GCM, using a key derived (HKDF) from INGAME_VERIFY_TOKEN. OpenSSL is already required by the portable profile. Someone watching the plain-HTTP link can no longer read a live code and race to redeem it.
    • Each message carries its direction and a timestamp, and is refused after 60 seconds.
    • An answer names the nonce of the request it answers, so answers can't be swapped.
    • The HMAC header signature is gone.
  • Game webhook: discord_verify is now POST <WEBHOOK_ADDRESS>/discord_verify. The key goes in the X-Webhook-Key header and ckey/code go in a JSON body.
    • A key in the query string, or the old GET form, is refused.
    • The router (HttpHandler::__isWhitelisted) accepts the header key on /webhook/ paths.
    • The game side lands in a matching Civ13 PR.
  • Tests: tests/local/ingame-verification.php grows from 39 to 66 checks.
    • Seal round trip, wrong secret, wrong direction, stale message, flipped byte, malformed input, unsealed relay, swapped answer, POST only.
    • Header key required, query key refused, old GET refused, body validated.
    • A Monolog spy and a source scan confirm no code, key or secret reaches the logs.
  • Docs: docs/ingame-verification.md is updated.

Verification:

  • php tests/local/ingame-verification.php passes 66 checks, including under the CI disable_functions run.
  • Every other tests/local/*.php passes. The exceptions are lifecycle-wire, replica-worker, server-compatibility and verification-tls, which fail the same way on unmodified main when run without CI arguments.

Not verified live: a real desktop-to-primary relay over the network.


Generated by Claude Code

/approveme without a ckey gives a private single-use code. The game's
Verify Discord verb sends ckey + code as the discord_verify webhook; the
primary bot redeems it (bans, age and alt review still apply), and a
desktop bot with the read-only verifier relays it to the primary bot's
HMAC-signed /verified/ingame endpoint (INGAME_VERIFY_TOKEN).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WTP2R6s5HsPDzf2CSzzGM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WTP2R6s5HsPDzf2CSzzGM
start and bot.php warn instead of refusing when the default-branch check
fails. update keeps any local composer.lock (stashing it only when the
update changes composer.lock itself). New control.php repair: stash local
edits, keep local commits on a backup branch, and fast-forward a clean
main, for the launcher's Repair and update button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WTP2R6s5HsPDzf2CSzzGM
The desktop bot's relay to the primary bot is now encrypted end to end with
AES-256-GCM under a key derived from INGAME_VERIFY_TOKEN, so a watcher on the
plain-HTTP link can no longer read and race a live code. Answers are sealed and
bound to their request. The game's discord_verify request is a POST with the
webhook key in the X-Webhook-Key header and ckey/code in a JSON body; a key in
the query string is refused. Tests cover rejection paths and secrets in logs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WTP2R6s5HsPDzf2CSzzGM
Copilot AI balanced review requested due to automatic review settings November 13, 2026 13:56
@valzargaming
valzargaming merged commit cf5e040 into main Nov 13, 2026
13 of 16 checks passed

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

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.

3 participants