You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add activity moderation and strengthen chat prompt-injection defenses #1234
Add moderation for host-created activity content and strengthen defenses against prompt injection in the homepage AI chat. Host-written titles and tags can reach the model as activity context. Misleading content can appear in chat replies even when the assistant treats it as an activity name rather than a site-wide claim.
PR #1228 removes descriptions from chat context, filters some instruction-like listings, and limits clickable reply links. These mitigations do not establish that all host-written content is safe. The author reports 5 hits in 66 trials after the changes, all involving malicious titles repeated as course names. The earlier evaluation used a different set of 42 trials, so the rates are not a direct like-for-like comparison.
Areas affected
learn/src/worker.py: activity creation and editing, catalog preparation, and chat prompt construction.
learn/public/index.html: chat reply presentation and link handling.
learn/scripts/chat_injection_eval.py and learn/tests/test_api_chat.py: adversarial evaluation and regression coverage.
Proposed acceptance criteria
Define and implement a moderator review workflow for host-written activity content, including misleading or malicious titles and tags.
Use only moderator-approved versions of activity fields in chat context. Changes to those fields require renewed approval before the changed content enters the prompt.
Ensure cached catalog data cannot expose an unapproved revision after a moderation decision or edit.
Add tests for authorization, approval, rejected or pending content, edits after approval, and cache behavior.
Expand the adversarial evaluation to cover paraphrased instructions, misleading site-wide claims, phishing, obfuscated links, and ordinary activity titles. Record the model, trial counts, results, and remaining risks.
since this was filed, #1228 sandboxes the model (as requested): it never sees host-written text, only our own instructions, the team-written facts and activity counts. The server inserts the live list after generation. The real-model eval is at 0/66 attacks succeeding (learn/scripts/chat_injection_eval.py, @cf/meta/llama-3.1-8b-instruct-fast, 3 trials × 2 questions × 11 attacks).
What's left is moderating what the inserted list shows. I have a small, chat-only version ready to open once #1228 merges:
off unless CHAT_REQUIRE_APPROVAL is set
admins approve activities via /api/admin/chat-approvals
any edit hides the activity again until it is re-approved
/activity and activity creation are unchanged
Happy to adjust if you'd rather moderate activities site-wide instead.
I'd like to contribute to issue #1234, specifically focusing on Python backend regression tests and adversarial evaluation coverage.
I would prefer a small, independent contribution rather than duplicating the moderation implementation you already have planned.
Would additional tests for approval authorization, edits requiring re-approval, and cache behavior be useful? Please let me know which areas are still uncovered so I can work on a focused PR.
Activity
AashishTalreja commentedon Nov 11, 2026
since this was filed, #1228 sandboxes the model (as requested): it never sees host-written text, only our own instructions, the team-written facts and activity counts. The server inserts the live list after generation. The real-model eval is at 0/66 attacks succeeding (learn/scripts/chat_injection_eval.py, @cf/meta/llama-3.1-8b-instruct-fast, 3 trials × 2 questions × 11 attacks).
What's left is moderating what the inserted list shows. I have a small, chat-only version ready to open once #1228 merges:
off unless CHAT_REQUIRE_APPROVAL is set
admins approve activities via /api/admin/chat-approvals
any edit hides the activity again until it is re-approved
/activity and activity creation are unchanged
Happy to adjust if you'd rather moderate activities site-wide instead.
aadityachhipa80-oss commentedon Nov 20, 2026
Hi @AashishTalreja ,
I'd like to contribute to issue #1234, specifically focusing on Python backend regression tests and adversarial evaluation coverage.
I would prefer a small, independent contribution rather than duplicating the moderation implementation you already have planned.
Would additional tests for approval authorization, edits requiring re-approval, and cache behavior be useful? Please let me know which areas are still uncovered so I can work on a focused PR.