moodle-security-audit

moodle-security-audit is a cursor rule for Cursor from SaadRahman01/claude-moodle-dev. It costs 0 tokens per session (2,632 once invoked), scanned A, original, MIT.

Security review rules for Moodle plugins. Moodle is a learning-management system, and the rules cover its login, permissions, request checks, database access, file handling, and output safety.

In plain words
What is it for?
Reviewing or hardening Moodle plugin code, checking pull requests, investigating vulnerabilities, and preparing a plugin for the Moodle plugin directory.
Why use it?
They help find common security mistakes such as missing permissions, cross-site request forgery protection, SQL injection, cross-site scripting, and unauthorized record access.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is require('../../config.php'); // bootstrap.

Good fit Reviewing or hardening Moodle plugin code, checking pull requests, investigating vulnerabilities, and preparing a plugin for the Moodle plugin directory.

Compare 6 cursor rules from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev
agentmods
npx agentmods add rules/saadrahman01/claude-moodle-dev/moodle-security-audit

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for moodle-security-audit

README.md
[![agentmods](https://agentmods.dev/badge/rules/saadrahman01/claude-moodle-dev/moodle-security-audit/github.svg)](https://agentmods.dev/rules/saadrahman01/claude-moodle-dev/moodle-security-audit)
Your own site
<a href="https://agentmods.dev/rules/saadrahman01/claude-moodle-dev/moodle-security-audit"><img src="https://agentmods.dev/badge/rules/saadrahman01/claude-moodle-dev/moodle-security-audit/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for moodle-security-audit

Your own site · 80×15
<a href="https://agentmods.dev/rules/saadrahman01/claude-moodle-dev/moodle-security-audit"><img src="https://agentmods.dev/badge/rules/saadrahman01/claude-moodle-dev/moodle-security-audit.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,632 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.02632
Opus 5.5 $0.00000 $0.01053
Sonnet 5.5 $0.00000 $0.00526
Haiku 4.5 $0.00000 $0.00263

Measured 3mo ago against content hash 1799d506fe34, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

moodle-security-audit scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

$curl = new \curl(); // Moodle's curl wrapper
adapters/cursor/.cursor/rules/moodle-security-audit.mdc · 289 lines

How it starts

The opening of the file, as written. The whole thing — 289 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Moodle Security Audit

Overview

Moodle has framework-level protections (capability system, sesskey, $DB placeholders, output escaping) — but only if used. Most Moodle plugin CVEs come from skipping these. This skill enforces the checklist.

When to Use

  • Reviewing a PR for security
  • Auditing existing plugin code
  • Responding to a vulnerability report
  • Pre-submission review for moodle.org plugin directory

Skip when: writing new feature code (use moodle-plugin-development — it covers the basics).

Audit checklist (every entry script)

require('../../config.php');                            // bootstrap
require_login();                                        // 1. session + cookies
$context = context_course::instance($courseid);         // 2. context
$PAGE->set_context($context);
require_capability('local/example:view', $context);     // 3. capability
require_sesskey();                                      // 4. CSRF (POST only)

$id   = required_param('id', PARAM_INT);                // 5. typed input
$name = optional_param('name', '', PARAM_TEXT);

Order matters. require_login before context_*::instance because login resolves $USER.

1. Authentication — require_login()

Variant Use
require_login() Logged-in user, any context
require_login($course) Logged-in + enrolled in course
require_login($course, true, $cm) Logged-in + activity-level access
require_admin() Site admin only
require_login(null, false) Skips guest auto-login (rare)

Bug: Forgetting require_login() on AJAX endpoints. AJAX still needs it — session might be valid but unauthorized.

2. Authorization — capabilities

require_capability('local/example:edit', $context);
// or for soft check:
if (!has_capability('local/example:edit', $context)) {
    redirect(...);
}

Bug — IDOR (Insecure Direct Object Reference):

// BAD — checks site-level cap, but $item belongs to a course user can't access
$item = $DB->get_record('local_example_items', ['id' => $id], '*', MUST_EXIST);
require_capability('local/example:view', context_system::instance());

// GOOD — derive context from the object
$item = $DB->get_record('local_example_items', ['id' => $id], '*', MUST_EXIST);
$context = context_course::instance($item->courseid);
require_capability('local/example:view', $context);

Read the full file on GitHub · 289 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 289 lines · 0 tokens per session scan A 1799d506fe34

Subscribe to this mod's changes

moodle-security-audit is a cursor rule published in the GitHub repository SaadRahman01/claude-moodle-dev (43 stars, last pushed 5mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,632 tokens. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

moodle-security-audit compared with cursor rules from other repositories

moodle-security-audit next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
moodle-security-auditSaadRahman01/claude-moodle-devCursor rule435mo agoMITA0Cursor
add-landing-templateclassroomio/classroomioCursor rule1.8ktodayAGPL-3.0A0Cursor
webrtcAcKeskin/contextureCursor rule27d agoMITA1,211Cursor
agentsonesimplecode/agent-engineering-standardsCursor rule42mo agoMITA102Cursor
ponytailDietrichGebert/ponytailCursor rule201k8d agoMITA604Cursor
angular-20angular/angularCursor rule102k4d agoMITA0Cursor
dev-standardapache/supersetCursor rule76ktodayApache-2.0A1,147Cursor