Skip to content

fix: security hardening — nonce validation + exam prompt guard#51

Merged
heznpc merged 1 commit intomainfrom
fix/security-nonce-exam-guard
Mar 17, 2026
Merged

fix: security hardening — nonce validation + exam prompt guard#51
heznpc merged 1 commit intomainfrom
fix/security-nonce-exam-guard

Conversation

@heznpc
Copy link
Owner

@heznpc heznpc commented Mar 17, 2026

Summary

  • H1 fix: All bridge response messages now include __nonce__, validated on receipt in translator.js — prevents page scripts from spoofing translation/chat responses
  • H2 fix: Request IDs changed from sequential integers to crypto.randomUUID() — unpredictable, cannot be guessed by attackers
  • M1 fix: Exam mode injects a CRITICAL system prompt constraint into Claude, instructing it to refuse providing exam answers (not just a UI warning)

Test plan

  • All 642 tests pass
  • Verify AI Tutor still works normally on lesson pages
  • Verify AI Tutor refuses to answer exam questions on quiz pages

🤖 Generated with Claude Code

… exam prompt guard

- Add __nonce__ to all bridge response messages (TRANSLATE/VERIFY/CHAT/STREAM)
- Validate nonce on all response handlers in translator.js (prevents spoofing)
- Replace sequential integer request IDs with crypto.randomUUID() (unpredictable)
- Add CRITICAL exam guard to Claude system prompt when isExamPage is true
- Pass isExamPage flag from sidebar-chat to chatStream

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@heznpc heznpc merged commit 8fac377 into main Mar 17, 2026
2 checks passed
@heznpc heznpc deleted the fix/security-nonce-exam-guard branch March 17, 2026 13:23
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.

1 participant