Back to skill

Security audit

MEGAcmd

Security checks for vulnerabilities and agentic risk

Overview

This MEGA.nz CLI skill is coherent, but it needs review because it handles cloud-account credentials and destructive cloud/file operations while showing unsafe password-in-command examples.

Install only if you are comfortable letting an agent operate MEGAcmd on your cloud account. Do not give passwords, MFA codes, session IDs, recovery keys, proxy passwords, or link passwords in chat or inline shell commands; use interactive login or a protected secret mechanism. Require explicit confirmation for deletes, password/session changes, sync setup, public links, writable shares, WebDAV/FTP public access, and any sudo installation step.

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 (2)

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:51
Finding
Passwords and Authentication Codes Are Passed Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 51-65 and 85-96 **Vulnerability Type**: Exposure of credentials through process arguments, shell history, logs, and agent telemetry **Risk Level**: Medium ### Vulnerable Code ```bash # 3. Are you logged in? mega-whoami >/dev/null 2>&1 && echo "LOGGED IN" || echo "NOT LOGGED IN" ``` ```text If the server is not running: `mega-cmd-server &` If not logged in: `mega-login email password` ``` ```bash ### Scriptable Mode (agent uses this → ALWAYS use `mega-`) mega-login email password mega-put ~/file.pdf /Destination/ mega-get /remote/file.pdf ~/Downloads/ ``` ```bash ### Interactive Mode mega-cmd MEGA CMD> login email password MEGA CMD> put ~/file.pdf /Destination/ ``` The same unsafe pattern also appears in: - `README.md`, lines 173-183 - `README.md`, lines 203-209 - `README.pt-BR.md`, lines 173-183 and 203-209 - `SKILL.pt-BR.md`, lines 66 and 85-101 - `references/complete-commands-reference.md`, lines 44-80 - `references/comandos-completos.pt-BR.md`, lines 44-80 ### Technical Analysis The skill repeatedly presents commands that place account passwords and optional MFA authentication codes directly in the command-line argument vector. Depending on the operating system and execution environment, these values may be exposed through: - Shell history files - Process enumeration utilities such as `ps` - Process accounting and endpoint monitoring - CI/CD logs - Terminal transcripts - Agent tool-call telemetry - Automation audit logs - Error reports that record the complete command Although later sections warn that inline passwords are unsafe, the prerequisite workflow directly instructs the agent to use `mega-login email password`. The unsafe command is therefore likely to be copied or executed before the warning is considered. Placeholder values can also be replaced automatically with real user credentials by an agent. The command reference similarly documents password changes, account ...[truncated 1706 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Replace the prerequisite fallback with interactive login that does not include a password: ```bash mega-login user@example.com ``` Instruct the user to enter the password through MEGAcmd's protected prompt. 2. Do not ask users to provide passwords, MFA codes, session IDs, recovery keys, protected-link passwords, or proxy passwords through chat. 3. Clearly separate syntax documentation from safe agent-executable examples. Use placeholders only in a syntax table, accompanied by an explicit statement that agents must not execute the inline-secret form. 4. Move credential-safety instructions before the first login example. The first executable login workflow should be the secure workflow. 5. Where non-interactive authentication is unavoidable, use a documented protected secret mechanism that does not expose values in the argument vector. Avoid inventing environment-variable or standard-input support unless MEGAcmd officially supports it. 6. Before running authentication commands, disable command echoing in automation and confirm that the execution environment does not log secret input. 7. Remove or rewrite examples such as: ```bash mega-login email password ``` and: ```bash mega-passwd new-password ``` 8. Add post-incident guidance: rotate an exposed password, revoke other sessions with `mega-killsession -a`, review public links and sharing, and inspect account activity. ]]>

T08 · Insecure Dependencies

Note
Location
README.md:91
Finding
Privileged Installation Is Performed Without Package Integrity or Version Verification<![CDATA[ ## Vulnerability Details **File Location**: `README.md`, lines 91-102 and 117-128 **Vulnerability Type**: Unverified third-party package and source installation with elevated privileges **Risk Level**: Low ### Vulnerable Code ```bash ## Installing MEGAcmd ### Via Official Package (Recommended) Download the installer for your system at: https://mega.nz/cmd # Linux (Ubuntu/Debian): # Add repository wget -O /tmp/megacmd.deb https://mega.nz/linux/repo/xUbuntu_24.04/amd64/megacmd_2.5.2-1_amd64.deb sudo dpkg -i /tmp/megacmd.deb sudo apt install -f ``` ```bash ### Via Manual Build git clone https://github.com/meganz/MEGAcmd.git cd MEGAcmd && git submodule update --init --recursive cmake -B build/build-cmake-Release -DCMAKE_BUILD_TYPE=Release cmake --build build/build-cmake-Release -j$(nproc) sudo cmake --install build/build-cmake-Release ``` Equivalent instructions appear in `README.pt-BR.md`, lines 91-102 and 117-128. ### Technical Analysis The package workflow downloads a Debian package to a predictable path and immediately invokes `sudo dpkg -i` without verifying a publisher signature or a trusted cryptographic checksum. HTTPS protects transport under normal conditions, but it does not independently verify that the downloaded artifact is the intended release. The manual-build workflow clones the current default branch and initializes recursive submodules without pinning a reviewed commit or release tag. It then installs the resulting artifacts with elevated privileges. Consequently, the effective source code can change after this skill has been reviewed. This is a supply-chain hardening weakness rather than evidence that the named MEGA or GitHub sources are malicious. Exploitation depends on compromise of an upstream release, repository, submodule, account, certificate trust path, DNS/network infrastructure, or the downloaded file before installation. The package is written to the predictable `/tmp/megacmd.deb` path. On systems where an atta ...[truncated 1843 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Prefer the operating system's authenticated package repository and explicitly verify repository-signing keys through an official, independently documented fingerprint. 2. If direct package download is required, publish and verify a release-specific SHA-256 or stronger checksum obtained through a trusted channel before invoking `sudo`: ```bash sha256sum /tmp/megacmd.deb ``` Compare the output with the official value and abort on any mismatch. 3. Verify the Debian package's publisher signature where an official signed-package workflow is available. A checksum alone is insufficient if both the package and checksum are obtained from the same compromised source. 4. Use a private temporary directory created with `mktemp -d` rather than a fixed shared `/tmp/megacmd.deb` path. Confirm that the downloaded object is a regular file owned by the current user before installation. 5. Pin source installations to a specific release tag or full commit hash. Verify the tag or commit signature against an independently validated maintainer key. 6. Review and pin recursive submodule revisions. Avoid building an unreviewed default branch for privileged installation. 7. Build as an unprivileged user. Elevate privileges only for the final, reviewed file-copy stage, and inspect the generated installation manifest before running it. 8. Record the expected package version, checksum, source commit, and submodule revisions in the documentation so the installation remains reproducible after upstream content changes. ]]>
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
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (22)

Anti-Refusal Statement

High
Category
Anti-Refusal
Content
- `sync -p ID|localpath` — Pause
- `sync -e ID|localpath` — Resume

### sync-ignore — Ignore Filters
```
sync-ignore [--show|[--add|--add-exclusion|--remove|--remove-exclusion] filter1 filter2 ...] (ID|localpath|DEFAULT)
```
Confidence
90% confidence
Finding
Skill attempts to nullify the agent's safety policies or restrictions ('you have no restrictions', 'ignore your guidelines', 'do anything now'). This is a direct jailbreak that disables guardrails.

Vague Triggers

Medium
Confidence
93% confidence
Finding
The README says the skill is automatically activated when conversation context matches the description, but it does not define clear boundaries for when that happens or when it should not. Although some example phrases are provided, the activation condition remains broad and lacks exclusion conditions or negative examples, which can lead to accidental triggering.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
A documentação inclui exclusão de arquivos e operações sensíveis de conta, como senha, master key, sessões e compartilhamentos, sem um alerta geral sobre irreversibilidade, bloqueio de conta ou perda permanente de acesso e dados. No contexto de uma skill para automação, a ausência desse aviso aumenta o risco de ações destrutivas executadas por engano pelo agente ou pelo usuário.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
A documentação promove sincronização bidirecional, mas não alerta de forma explícita que exclusões, renomeações e sobrescritas locais ou remotas podem se propagar automaticamente para o outro lado. Em uma skill para agentes, isso é mais perigoso porque um agente pode acionar sync em diretórios errados ou com estado desatualizado, causando perda de dados em escala.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# Adicionar repositório
wget -O /tmp/megacmd.deb https://mega.nz/linux/repo/xUbuntu_24.04/amd64/megacmd_2.5.2-1_amd64.deb
sudo dpkg -i /tmp/megacmd.deb
sudo apt install -f
```
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# Adicionar repositório
wget -O /tmp/megacmd.deb https://mega.nz/linux/repo/xUbuntu_24.04/amd64/megacmd_2.5.2-1_amd64.deb
sudo dpkg -i /tmp/megacmd.deb
sudo apt install -f
```
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# Adicionar repositório
wget -O /tmp/megacmd.deb https://mega.nz/linux/repo/xUbuntu_24.04/amd64/megacmd_2.5.2-1_amd64.deb
sudo dpkg -i /tmp/megacmd.deb
sudo apt install -f
```
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# Adicionar repositório
wget -O /tmp/megacmd.deb https://mega.nz/linux/repo/xUbuntu_24.04/amd64/megacmd_2.5.2-1_amd64.deb
sudo dpkg -i /tmp/megacmd.deb
sudo apt install -f
```
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# Adicionar repositório
wget -O /tmp/megacmd.deb https://mega.nz/linux/repo/xUbuntu_24.04/amd64/megacmd_2.5.2-1_amd64.deb
sudo dpkg -i /tmp/megacmd.deb
sudo apt install -f
```
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# Adicionar repositório
wget -O /tmp/megacmd.deb https://mega.nz/linux/repo/xUbuntu_24.04/amd64/megacmd_2.5.2-1_amd64.deb
sudo dpkg -i /tmp/megacmd.deb
sudo apt install -f
```
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Natural-Language Policy Violations

Medium
Confidence
82% confidence
Finding
The instruction says agents 'ALWAYS use `mega-` as prefix' and frames the terminal interaction in English-only command terms, while the document does not offer any language or locale choice. Because SQP-3 covers natural-language policy violations including forced language/locale without user opt-in, this is a policy concern in the skill guidance.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
> ⚠️ **Security Warning — Recovery Key**
> The master key (recovery key) is essential for data recovery. If lost, you cannot recover your data without the password. If exposed, an attacker gains durable access to your account.
> **Recommendation:** Save the master key to encrypted storage (password manager, encrypted USB). Store it with restricted file permissions (e.g., `chmod 600`). Do NOT sync the plaintext file to cloud storage.

> ⚠️ **Security Warning — Session Token**
> The session ID is a bearer credential. If exposed, anyone can impersonate your session until it expires or is revoked.
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
| "quota" in log | Storage quota exceeded | `mega-df -h`, free up space |
| LOG full of "Can't find" | Deleted/moved files | Usually resolves itself after rescan |

> ⚠️ The following commands delete local files without confirmation. Verify paths are correct before running.

### Action plan for stuck sync
Confidence
88% confidence
Finding
The skill includes concrete local deletion commands (`find ... -delete`) in an 'action plan' immediately after noting they delete without confirmation. In an agent context, this can lead to autonomous destructive actions on the local filesystem if the agent follows the runbook without obtaining explicit per-command user approval or validating paths, especially during troubleshooting when operators are under pressure.

Intent-Code Divergence

Medium
Confidence
97% confidence
Finding
O skill mostra exemplos e fluxo operacional com `mega-login email password`, o que normaliza o uso de senha inline mesmo havendo aviso posterior de que isso expõe credenciais ao histórico do shell, lista de processos e logs do agente. Em um contexto de agente automatizado, esse padrão é especialmente arriscado porque a entrada e a telemetria podem ser persistidas e reutilizadas por terceiros.

Missing User Warnings

Medium
Confidence
98% confidence
Finding
A instrução inicial de login recomenda passar a senha diretamente na linha de comando antes de apresentar o alerta de segurança, o que cria uma orientação insegura e fácil de copiar. Como este skill é destinado a agentes e automação, a contradição aumenta a chance de vazamento de credenciais em logs, histórico, monitoramento de processos e transcrições de chat.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
> ⚠️ **Aviso de Segurança — Chave de Recuperação**
> A chave mestre (chave de recuperação) é essencial para a recuperação de dados. Se perdida, você não pode recuperar seus dados sem a senha. Se exposta, um invasor ganha acesso durável à sua conta.
> **Recomendação:** Salve a chave mestre em armazenamento criptografado (gerenciador de senhas, USB criptografado). Armazene com permissões de arquivo restritas (ex.: `chmod 600`). Não sincronize o arquivo de texto puro para a nuvem.

> ⚠️ **Aviso de Segurança — Token de Sessão**
> O session ID é uma credencial do tipo bearer. Se exposto, qualquer pessoa pode se passar pela sua sessão até que ela expire ou seja revogada.
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
A documentação instrui como expor servidores FTP/WebDAV com a flag `--public`, inclusive em funcionalidades marcadas como beta, mas não traz um aviso claro de que isso publica dados na rede e pode permitir acesso não autorizado se usado em redes não confiáveis. Em um skill de agente, isso é mais perigoso porque o agente pode sugerir ou executar comandos diretamente, levando usuários a exporem conteúdo do MEGA sem compreender o alcance da exposição.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
```
passwd [-f] [--auth-code=XXXX] newpassword
```
- `-f` — Force (no asking)
- `--auth-code=XXXX` — Two-factor authentication code
- Changes password and closes all active sessions (except current)
Confidence
75% 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
rm [-r] [-f] [--use-pcre] remotepath
```
- `-r` — Recursive (for folders)
- `-f` — Force (no asking)

### put
Upload files/folders.
Confidence
81% confidence
Finding
Documenting `rm -f` for recursive remote deletion without an explicit caution can be dangerous in an agent skill because it removes interactive safeguards while operating on cloud data. If an agent mis-parses a path, expands patterns broadly, or acts on ambiguous instructions, users can suffer irreversible or difficult-to-recover remote data loss.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
```
deleteversions [-f] (--all | remotepath1 remotepath2 ...) [--use-pcre]
```
- `-f` — Force (no asking)
- `--all` — Delete versions of all nodes
- Current version is preserved
Confidence
84% confidence
Finding
`deleteversions -f --all` suppresses prompts for mass removal of historical file versions, which can eliminate recovery options across the account. In an autonomous agent context, that is meaningfully risky because one mistaken command can convert recoverable user mistakes or ransomware rollback opportunities into permanent loss.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The documentation exposes an option to bind an FTP service for MEGA content to external interfaces via `--public` without an adjacent warning about the security implications. In an agent skill context, this can lead users or downstream agents to publish cloud-hosted files onto the network unintentionally, especially if combined with weak defaults, absent TLS, or broad path selection.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The WebDAV section documents `--public` external exposure but does not clearly warn that enabling it makes MEGA-backed content reachable over the network. In a CLI agent skill, omission of this warning increases the chance of accidental data exposure because agents may treat `--public` as a routine convenience flag rather than a sensitive publishing action.

Static analysis

No suspicious patterns detected.