Back to skill

Security audit

Porteden Email

Security checks for vulnerabilities and agentic risk

Overview

This email-management skill is broadly purpose-aligned, but it needs review because its PowerShell wrapper can turn user-supplied mail arguments into arbitrary local command execution.

Review this carefully before installing. Use only with mailboxes you are comfortable authorizing to Porteden, verify the Porteden CLI source and version yourself, avoid passing untrusted text into the PowerShell wrapper, and prefer a fixed wrapper that invokes the CLI with an argument array instead of Invoke-Expression.

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

Error
Location
scripts/porteden.ps1:92
Finding

Arbitrary PowerShell Command Injection Through Invoke-Expression

Content
View full analysis

Vulnerability Details

File Location: scripts/porteden.ps1, lines 92-106
Vulnerability Type: PowerShell command injection
Risk Level: High

Vulnerable Code

powershell
# 添加剩余参数
if ($RemainingArgs.Count -gt 0 -and $Command.ToLower() -notin @("accounts", "attachments")) {
    $argsList += $RemainingArgs
}

try {
    Write-Host "🔄 正在执行邮件操作..."
    $fullCommand = "porteden $($argsList -join ' ')"
    Invoke-Expression $fullCommand
    if ($LASTEXITCODE -ne 0) {
        throw "操作失败,退出码:$LASTEXITCODE"
    }
} catch {

The same unsafe argument list is also populated from caller-controlled string parameters and unrestricted remaining arguments elsewhere in scripts/porteden.ps1, including lines 27-29 and 49-87.

Technical Analysis

The script accepts arbitrary values through RemainingArgs and several string parameters, concatenates those values into a single PowerShell command string, and executes the resulting string with Invoke-Expression.

Invoke-Expression parses its input as PowerShell source code rather than passing each value as an opaque process argument. Consequently, an attacker can supply PowerShell metacharacters such as semicolons, pipelines, subexpressions, or embedded quotation marks to terminate the intended porteden command and introduce additional commands.

The manual quoting used for selected parameters does not provide reliable protection. For example, values are wrapped with escaped double quotes when added to $argsList, but embedded quotes or PowerShell expressions are not escaped according to a robust command-line encoding scheme. RemainingArgs receives no validation or escaping at all.

Attack Path

  1. An attacker gains influence over arguments supplied to porteden.ps1, such as through an agent request, automated workflow, or other caller.
  2. The attacker places PowerShell syntax in a parameter accepted through RemainingArgs or in one of the ...[truncated 1391 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove Invoke-Expression and never construct a PowerShell source-code string from caller-controlled values.

  2. Invoke the executable directly and use PowerShell's argument-array handling:

    powershell
    & porteden @argsList
    $exitCode = $LASTEXITCODE
    
  3. Store argument values in $argsList without manually adding quotation-mark characters. Direct invocation passes array elements as arguments and avoids reparsing them as PowerShell code.

  4. Eliminate unrestricted ValueFromRemainingArguments handling where possible. Define explicit parameters for every supported operation.

  5. If passthrough arguments are necessary, validate each one against command-specific allowlists of supported flags and expected value formats.

  6. Validate numeric ranges, email addresses, dates, profile names, message identifiers, and output paths before invocation.

  7. Resolve the expected executable using a trusted absolute path or verify the command source returned by Get-Command to reduce executable-path spoofing risks.

  8. Add security tests containing semicolons, pipelines, embedded quotes, subexpressions, and newline characters, confirming that they are passed only as literal arguments or rejected.

T08 · Insecure Dependencies

Warning
Location
SKILL.md:21
Finding

Mutable and Unverified Third-Party CLI Installation

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 21-30
Vulnerability Type: Unpinned and unverified third-party dependency
Risk Level: Medium

Vulnerable Code

powershell
brew install porteden/tap/porteden
powershell
go install github.com/porteden/cli@latest

The installation guidance is also repeated in scripts/porteden.ps1, lines 35-38:

powershell
Write-Host "安装指引:"
Write-Host "1. brew install porteden/tap/porteden (推荐)"
Write-Host "2. 或 go install github.com/porteden/cli@latest"

Technical Analysis

The documented installation process obtains a security-sensitive email CLI from a custom Homebrew tap or installs the mutable Go module version @latest. Neither method pins a reviewed version or commit, and no checksum, signature, provenance attestation, or trusted release identity is provided.

The effective code installed by these commands can therefore change after this skill has been reviewed. A compromised upstream account, repository, Homebrew tap, release pipeline, or future malicious version could cause users to install code different from the version originally expected.

This concern is particularly significant because the dependency is intended to receive mailbox authorization and process email content, recipients, message bodies, and attachments. The project itself does not demonstrate that the referenced upstream is malicious; the vulnerability is the absence of version and integrity controls around a highly privileged dependency.

Attack Path

  1. An attacker compromises the upstream repository, custom Homebrew tap, maintainer account, package publication process, or mutable latest release.
  2. The attacker publishes a modified Porteden CLI or installation definition.
  3. A user follows the skill instructions and runs either the custom-tap installation or go install ...@latest.
  4. The package manager downloads and builds or installs the attacke ...[truncated 1094 chars]
Remediation
View remediation

Remediation Suggestions

  1. Pin the Go installation to a specific reviewed semantic version or immutable commit rather than @latest.
  2. Pin the Homebrew formula or bottle to a reviewed version wherever supported.
  3. Publish expected cryptographic checksums for release artifacts and require verification before installation.
  4. Prefer signed releases and verify the signature against a documented, trusted maintainer key.
  5. Record dependency provenance, reviewed source revision, and release date in the skill documentation.
  6. Use reproducible builds or supply-chain attestations such as SLSA provenance when available.
  7. Establish an update-review process so dependency upgrades are audited before the pinned version is changed.
  8. Document the mailbox permissions required by the CLI and instruct users to grant only the minimum necessary scope.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (8)

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The documentation states that no email content is uploaded to third-party servers and that all operations occur locally, but the skill is explicitly a wrapper around a CLI that interacts with external email providers such as Gmail, Outlook, and Exchange. This can mislead users about where sensitive email content is processed or transmitted, causing them to grant access or use the tool under false privacy assumptions.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The package description is written entirely in Chinese, which constitutes a natural-language locale constraint in the skill metadata without offering any user language choice or opt-in. This can violate language/locale policy when the skill is expected to be usable in broader contexts.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The script forwards ValueFromRemainingArguments directly to the underlying porteden CLI and then executes the assembled command via Invoke-Expression. This defeats the wrapper’s intended parameter restrictions and can expose undocumented or dangerous CLI capabilities, while also creating a command-injection path if crafted arguments contain PowerShell metacharacters.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The send operation transmits email content immediately once required parameters are present, with no preview, confirmation, or friction before outbound delivery. In an agent setting, this raises the risk of accidental exfiltration, misdelivery, or unintended actions triggered by ambiguous prompts or prompt injection elsewhere in the workflow.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
81% confidence
Finding

With no manifest available, there is no declared purpose that justifies bundling login, logout, account switching, and attachment download alongside ordinary mail listing/search/sending. These are broader capabilities that affect authentication state and local file output, not merely message retrieval or composition.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

Line L042 presents Asia/Shanghai as the timezone configuration example without indicating that users may choose a different locale or that this skill is region-specific. Under the stated policy, forcing a locale-specific default in natural-language instructions can be a language/locale policy issue unless the user is given a choice or the constraint is clearly justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

User-facing comments and runtime messages are written in Chinese throughout the script, including errors and status output. For a general-purpose skill, this imposes a specific language on users without opt-in or a documented region/language constraint.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
75% confidence
Finding

The attachments command supports a download action with an output path, which can write files to the local filesystem. The script does not provide a specific warning, confirmation, or user-facing notice that files will be created at the supplied location beyond a generic 'executing mail operation' message.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.