Back to skill

Security audit

Moodle Student Sync

Security checks for vulnerabilities and agentic risk

Overview

This Moodle skill appears purpose-built rather than malicious, but it handles private student records and a Moodle token with under-disclosed and insufficiently constrained safeguards.

Install only if you trust this skill with your Moodle account data. Use a least-privilege Moodle token, set MOODLE_URL only to your real HTTPS Moodle site, avoid shared or synced output directories, restrict permissions on generated files, and delete snapshots or digests when no longer needed.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/moodle_client.py:55
Finding

Moodle access token may be exposed through insecure URL configuration and query-string authentication

Content
View full analysis
None: self.base_url = self.base_url.rstrip("/") if not self.base_url: raise ValueError("base_url must not be empty") if not self.token: raise ValueError("token must not be empty") @classmethod def from_env( cls, rate_limit_seconds: float = 15.0, timeout_seconds: float = 30.0, ) -> "MoodleClient": base_url = os.environ.get("MOODLE_URL", "").strip() token = os.environ.get("MOODLE_TOKEN", "").strip() if not base_url: raise ValueError("MOODLE_URL is required") if not token: raise ValueError("MOODLE_TOKEN is required") return cls( base_url=base_url, token=token, rate_limit_seconds=rate_limit_seconds, timeout_seconds=timeout_seconds, ) @property def endpoint(self) -> str: return f"{self.base_url}/webservice/rest/server.php" def call(self, function: str, params: dict[str, Any] | None = None) -> Any: if not function: raise ValueError("function is required") request_params: dict[str, Any] = { "wstoken": self.token, "wsfunction": function, "moodlewsrestformat": "json", } request_params.update(flatten_params(params)) response = self.session.get( self.endpoint, params=request_params, timeout=self.timeout_seconds, ) ``` ### Technical Analysis The client accepts any nonempty `MOODLE_URL`; it does not parse the URL, require HTTPS, reject embedded credentials, or constrain the destination to a trusted Moodle host. The Moodle access token is then placed in the `wstoken` query parameter of an HTTP GET request. Consequently, the complete request URL contains the secret token. Query strings are commonly recorded by reve ...[truncated 2354 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/moodle_sync.py:78
Finding

Sensitive student records are written without explicitly restrictive file permissions

Content
View full analysis
None: if output_path: with open(output_path, "w", encoding="utf-8") as file: file.write(payload) print(f"Wrote output to {output_path}", file=sys.stderr) return ``` ### Technical Analysis The CLI can write synchronized Moodle data to an operator-selected file using the default permissions resulting from Python's `open()` and the process umask. The code does not explicitly create the file with owner-only permissions and does not verify or tighten permissions on an existing file. Depending on the host's umask and the permissions of an existing destination, the resulting file may be readable by the user's group or by other local users. The affected output can contain grades, user identifiers, notifications, course enrollment details, calendar events, and course-content metadata. Opening an existing path with mode `"w"` truncates it but preserves its existing permission bits. Therefore, even a restrictive current umask does not protect output written over an already broadly readable file. ### Attack Path 1. The victim runs a command with `--output`, for example: ```bash python scripts/moodle_sync.py sync --include-contents --output snapshot.json ``` 2. The process operates under a permissive umask, or `snapshot.json` already exists with group-readable or world-readable permissions. 3. `_write_output()` writes the complete Moodle payload without applying owner-only permissions. 4. Another local user, a process running under a shared group, or a service that scans the destination directory reads the generated file. 5. The reader obtains the student's Moodle records contained in the selected report. This attack requires local filesystem access or access th ...[truncated 825 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (10)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description promises substantial Moodle-related functionality, but the supplied code chunk does not implement or demonstrate any of it. It is effectively just an empty package initializer with a descriptive docstring. Because the actual code shown lacks the declared primary behavior, this is a material description-to-behavior mismatch based on the supplied chunk.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
89% confidence
Finding

The declared description is broader than the supplied code. This chunk is a digest formatter: it parses calendar events, flags grades below a threshold, includes recent notifications, and emits a markdown daily digest. It does not connect to Moodle, sync data, fetch courses/files/announcements, or implement comprehensive assignment tracking or study planning. While the daily digest portion aligns partially with the description, the overall declared purpose materially overstates the behavior of this code chunk.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The declared description suggests a comprehensive Moodle skill that can sync data and summarize multiple resource types such as courses, deadlines, grades, files, and announcements. The supplied code chunk only operates on input data already present in sync_data; it performs no network access, authentication, or synchronization. Its functionality is limited to analyzing calendar events and grade overview entries to produce a study plan. While study planning and assignment/grade awareness are consistent with part of the description, the primary declared capability of syncing Moodle data and broader summarization is not represented in this code. Therefore this chunk materially underimplements the declared purpose and is a mismatch.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The README encourages syncing Moodle student data, grades, deadlines, files, and announcements into local snapshots and digests but does not warn that this information may include sensitive educational records or that local output files may persist on disk. In a student-data context, missing guidance on secure handling, storage, and sharing increases the likelihood of accidental disclosure even if the skill is not overtly malicious.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill declares access to environment variables and clearly instructs running Python scripts that perform network operations, but it does not declare an explicit tool scope such as permissions or allowed-tools. That creates a least-privilege and user-consent gap: an agent may invoke a networked, credential-using skill without clear policy boundaries, increasing the chance of unintended data access or exfiltration.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The invocation guidance says to use the skill for broad academic-help requests, even when the user does not explicitly mention Moodle API. That can cause over-triggering of a networked skill that accesses private educational records, leading to unnecessary token use and disclosure of sensitive student data in contexts where a generic, non-network answer would have been sufficient.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill documentation instructs the use of MOODLE_TOKEN and transmission of student data to a remote Moodle instance but provides no user-facing privacy or consent warning. Because grades, deadlines, course membership, files, and notifications are sensitive educational data, silent network access can violate user expectations and increase the impact of accidental disclosure or misuse of tokens.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

This code performs outbound HTTP requests to a Moodle server and includes the Moodle authentication token plus request parameters in the transmitted query string. While the module docstring states it is a Moodle REST client, there is no user-facing warning, log, or comment disclosing that credentialed network calls will be made and user/course data may be sent to an external service.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The CLI writes full Moodle-derived payloads, including grades, deadlines, notifications, and potentially course contents, to any user-supplied path without any sensitivity warning, path restrictions, or safer defaults. In this skill context, the exported data is educationally sensitive and may include personally identifiable student information, so accidental writes to shared locations, synced folders, or world-readable paths can expose private academic data.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The client reads MOODLE_TOKEN from environment variables to authenticate API requests. Although environment-based configuration is common, this file does not explicitly warn that it accesses sensitive credentials from the runtime environment.

Content

No source excerpt is available for this finding.