Skip to content

Add activity moderation and strengthen chat prompt-injection defenses #1234

Open

Description

@coderabbitai

Summary

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.

Requested by @AashishTalreja.

PR: #1228
Review comment: #1228 (comment)

Activity

  1. added
    good first issue
    2026-11
    on Nov 9, 2026
  2. AashishTalreja commented on Nov 11, 2026

    @AashishTalreja

    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.

  3. aadityachhipa80-oss commented on Nov 20, 2026

    @aadityachhipa80-oss

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    2026-11good first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions