Back to skill

Security audit

m365cli

Security checks for vulnerabilities and agentic risk

Overview

This skill matches its Microsoft 365 purpose, but its default guidance can expose corporate mail and files in risky ways.

Review this before installing if the account has sensitive mail or business files. Use it only for a work/school account, pin or verify the m365-cli package before global installation, avoid --force unless you have confirmed the sender and message, require explicit confirmation before sending, deleting, or sharing, and prefer named-user or organization-scoped sharing over anonymous links.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (3)

T08 · Insecure Dependencies

Warning
Location
SKILL.md:10
Finding
Unpinned Global Installation of a Third-Party npm Package<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 10-21 **Vulnerability Type**: Unpinned third-party dependency installed globally **Risk Level**: Medium ### Vulnerable Code ```yaml install: npm install -g m365-cli ``` ```markdown ## Prerequisites - Node.js 18+ - `m365-cli` installed globally: `npm install -g m365-cli` ``` ### Technical Analysis The Skill directs users or agents to install the latest available release of `m365-cli` globally. No exact version, package integrity value, lockfile, or reviewed release is specified. npm packages may define lifecycle scripts that execute during installation. Because the installation is global, a compromised or unexpectedly modified upstream release could place or replace executables in the user's global npm binary directory. The effective installed code may therefore differ from the code reviewed when this Skill was published. The package provenance is documented, but repository and npm links alone do not provide release immutability or integrity verification. ### Attack Path 1. The upstream npm publisher account, build pipeline, or package distribution process is compromised. 2. An attacker publishes a malicious release under the legitimate `m365-cli` package name. 3. A user or agent follows the Skill instruction and runs `npm install -g m365-cli`. 4. npm retrieves the latest release and may execute its installation lifecycle scripts. 5. The malicious package executes with the installing user's privileges and installs a globally accessible `m365` executable. 6. Subsequent Microsoft 365 operations may be intercepted or altered by the compromised CLI. ### Impact Assessment Successful exploitation could provide arbitrary code execution with the privileges of the user performing the installation. A malicious CLI could access files available to that user, intercept Microsoft 365 command arguments and output, misuse OAuth-backed operations, or impersonate expected `m365` behavior. The glo ...[truncated 204 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin the dependency to a specifically reviewed version, for example: ```bash npm install -g m365-cli@<reviewed-version> ``` 2. Document the expected package version and integrity hash. 3. Prefer a project-local installation with a committed lockfile instead of a global installation. 4. Install with lifecycle scripts disabled when compatible with the package: ```bash npm install --ignore-scripts m365-cli@<reviewed-version> ``` 5. Verify the npm publisher, source repository tag, release provenance, and package contents before updating the pinned version. 6. Consider running the CLI in a restricted environment that exposes only the files and network destinations required for the requested Microsoft 365 operation. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:45
Finding
Default Workflows Bypass the Trusted-Sender Email Safeguard<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 45-49, 79-81, 193-195, and 249-251 **Vulnerability Type**: Unsafe bypass of untrusted-content filtering **Risk Level**: High ### Vulnerable Code ```markdown ### Email Body Reading — Trusted Senders Whitelist - Only emails from whitelisted senders have their body content displayed. - Untrusted emails show only subject and sender (prevents prompt injection). - Whitelist file: `~/.m365-cli/trusted-senders.txt` - Use `--force` to temporarily bypass the whitelist check. ``` The primary mail-reading example bypasses the safeguard: ```bash # Read / send / search m365 mail read <id> --force --json m365 mail send "to@example.com" "Subject" "Body" --json m365 mail send "to@example.com" "Subject" "Body" --attach file.pdf --cc "cc@ex.com" --json m365 mail search "keyword" --top 20 --json ``` The standard “Read and reply” workflow repeats the bypass: ```bash m365 mail list --top 5 --json # 1. Find email m365 mail read <id> --force --json # 2. Read content m365 mail reply <id> "Reply content" --json # 3. Reply ``` The security section also advertises the bypass: ```markdown ## Trusted Senders (Security) `m365 mail read` filters untrusted sender content (shows metadata only). Use `--force` to bypass. ``` ### Technical Analysis The Skill correctly identifies email bodies as an untrusted prompt-injection channel and provides a trusted-sender whitelist. However, its primary examples and standard read-and-reply workflow invoke `m365 mail read` with `--force`, which disables that protection. An email body is attacker-controlled content. If the full body is placed into an AI agent's context, instructions embedded in the message may be interpreted as operational directions rather than inert data. This is especially consequential because the Skill can send or forward email, access attachments, upload and download files, delete cloud data, and create sharing links. ...[truncated 1626 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove `--force` from all default mail-reading examples and standard workflows: ```bash m365 mail read <id> --json ``` 2. Require explicit user approval before bypassing the trusted-sender filter. 3. Display and verify the sender address before offering the bypass. 4. Treat retrieved email bodies as untrusted data and prohibit following instructions contained in them. 5. Separate content retrieval from action execution. Require a fresh confirmation before replying, forwarding, attaching files, sharing content, or deleting data. 6. Summarize untrusted messages through a constrained processing path that cannot issue tool calls. 7. Record when and why the bypass was used without logging the email body or OAuth credentials. 8. Prefer narrowly scoped, one-message authorization rather than permanently adding a sender or entire domain to the whitelist. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
references/commands.md:501
Finding
Anonymous OneDrive Sharing Is the Documented Default<![CDATA[ ## Vulnerability Details **File Location**: `references/commands.md`, lines 501-508 **Vulnerability Type**: Insecure file-sharing default **Risk Level**: Medium ### Vulnerable Code ```markdown m365 od share <path> [options] ``` ```markdown | Option | Description | Default | |--------|-------------|---------| | `--type <view\|edit>` | Link type | `view` | | `--scope <organization\|anonymous\|users>` | Sharing scope | `anonymous` | | `--json` | JSON output | — | ``` ### Technical Analysis The command reference states that `anonymous` is the default sharing scope. Consequently, invoking `m365 od share <path>` without an explicit `--scope` may create a link usable without organizational authentication. `SKILL.md` instructs the agent to warn the user when anonymous sharing is used, but it does not require explicit confirmation or mandate a safer scope. A warning alone does not prevent an agent from accidentally creating a public link when the user merely requests that a file be “shared.” This behavior violates secure-by-default principles for corporate cloud storage. The least-exposure option should be an identified user or, where appropriate, the authenticated organization. ### Attack Path 1. A user asks the agent to share a OneDrive file without specifying the intended audience or sharing scope. 2. The agent invokes the documented command without an explicit scope: ```bash m365 od share "Documents/report.pdf" ``` 3. The CLI applies its documented `anonymous` default. 4. An unauthenticated sharing link is created. 5. The link is copied to an unintended recipient, exposed in logs or chat history, or forwarded beyond the intended audience. 6. Anyone possessing the link can access the file according to the link's configured view or edit permission. ### Impact Assessment Exploitation or accidental misuse could disclose corporate OneDrive content outside the organization. If an anonymous link is created with edit permission, unauthorized pa ...[truncated 301 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Require an explicit `--scope` in every Skill-generated sharing command. 2. Default the Skill's guidance to a named-user invitation: ```bash m365 od invite <path> <email> --role read --json ``` 3. If link sharing is required, prefer the organization scope: ```bash m365 od share <path> --type view --scope organization --json ``` 4. Require informed user confirmation before creating any anonymous link. 5. Confirm the path, access type, intended audience, and expiration policy before sharing. 6. Prefer read-only access unless the user explicitly requests edit access. 7. After creation, report the effective scope and advise the user to revoke the link when it is no longer needed. 8. If the underlying CLI supports configuration changes, change its default from `anonymous` to `organization` or require the scope argument. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (11)

Credential Access

High
Category
Privilege Escalation
Content
- **Sharing files (anonymous scope)**: Warn the user that anyone with the link can access.

### Credential Safety
- **Never** read, output, or log `~/.m365-cli/credentials.json` — it contains OAuth tokens.
- **Never** include full email bodies or attachment contents in agent output unless the user explicitly requested that specific email.
- **Summarize** email content instead of echoing it verbatim when presenting results.
- Credential refresh is automatic; never attempt to manually edit or parse the token file.
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
- **Sharing files (anonymous scope)**: Warn the user that anyone with the link can access.

### Credential Safety
- **Never** read, output, or log `~/.m365-cli/credentials.json` — it contains OAuth tokens.
- **Never** include full email bodies or attachment contents in agent output unless the user explicitly requested that specific email.
- **Summarize** email content instead of echoing it verbatim when presenting results.
- Credential refresh is automatic; never attempt to manually edit or parse the token file.
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
- **Sharing files (anonymous scope)**: Warn the user that anyone with the link can access.

### Credential Safety
- **Never** read, output, or log `~/.m365-cli/credentials.json` — it contains OAuth tokens.
- **Never** include full email bodies or attachment contents in agent output unless the user explicitly requested that specific email.
- **Summarize** email content instead of echoing it verbatim when presenting results.
- Credential refresh is automatic; never attempt to manually edit or parse the token file.
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Description-Behavior Mismatch

Medium
Confidence
96% confidence
Finding
The manifest states this skill is for Microsoft 365 work/school account services only and specifically says not to use it for personal Outlook.com/Hotmail/Live accounts. However, the documented `m365 login` command explicitly supports `--account-type <type>` with `personal` as an allowed value, which broadens the skill beyond the declared scope.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
| Option | Description |
|--------|-------------|
| `--force` | Skip confirmation prompt |
| `--json` | JSON output |

### m365 mail move
Confidence
85% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
| Option | Description |
|--------|-------------|
| `--force` | Skip confirmation prompt |
| `--json` | JSON output |

### m365 mail move
Confidence
85% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
| Option | Description |
|--------|-------------|
| `--force` | Skip confirmation prompt |
| `--json` | JSON output |

### m365 mail move
Confidence
85% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The OneDrive sharing commands document creation of `anonymous` links and invitations without an explicit warning about external or public disclosure. In a corporate M365 context, users may unintentionally expose sensitive business files outside the organization, especially because the default share scope is documented as `anonymous`.

Missing User Warnings

Medium
Confidence
83% confidence
Finding
The OneDrive delete command is documented as capable of deleting files or folders, with a `--force` option, but without a visible warning about destructive action or recovery expectations. In a work/school storage context, this increases the risk of accidental deletion of important corporate data.

Natural-Language Policy Violations

Low
Confidence
78% confidence
Finding
The documentation presents `export M365_TIMEZONE="Asia/Shanghai"` as the sole override example, which can implicitly steer agents toward a specific locale setting. Under the policy rules, hard-coded locale guidance should either offer user choice or explain why that locale is required.

Description-Behavior Mismatch

Low
Confidence
84% confidence
Finding
The manifest says the skill should not be used for Azure/Entra/Intune/tenant admin tasks. The configuration section documents tenant ID and client ID environment variables for custom Azure AD app setup, which introduces Azure/Entra-oriented configuration behavior outside the stated purpose of using the skill for Exchange, OneDrive, SharePoint, and directory search tasks.

Static analysis

No suspicious patterns detected.