Back to skill

Security audit

Agent Emacs

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed persistent Emacs control environment, but its installer and remote-control guidance give agents broad persistent authority without enough scoping.

Review this before installing. Use it only in environments where persistent agent state, remote SSH access, and remote command execution are intended. Do not run scripts/bootstrap.sh from an untrusted directory, verify any Emacs init file source first, and plan how to clear daemon buffers, remote sessions, and memory files after each task.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/bootstrap.sh:7
Finding
Persistent Emacs Lisp Code Execution Through Working-Directory Path Injection## Vulnerability Details **File Location**: `scripts/bootstrap.sh`, lines 7–14 **Vulnerability Type**: Relative-path configuration injection with persistent code execution **Risk Level**: High ```bash EMACS_DIR="$HOME/.emacs.d" mkdir -p "$EMACS_DIR" if [ ! -f "$EMACS_DIR/init.el" ]; then cp assets/agent-init.el "$EMACS_DIR/init.el" fi # Ensure Daemon is running if ! pgrep -f "emacs --daemon" > /dev/null; then ``` The daemon is subsequently started at lines 15–17: ```bash if ! pgrep -f "emacs --daemon" > /dev/null; then emacs --daemon fi ``` ### Technical Analysis The source path `assets/agent-init.el` is resolved relative to the caller's current working directory rather than relative to the location of `bootstrap.sh`. The audited project does not contain the referenced `assets/agent-init.el` file. Consequently, when the user does not already have `~/.emacs.d/init.el`, executing the bootstrap script from an attacker-controlled directory containing `assets/agent-init.el` causes that attacker-controlled file to be copied into the user's persistent Emacs configuration. The script does not enable fail-fast handling such as `set -euo pipefail` and does not verify the source file, copied file, owner, permissions, or cryptographic integrity. It may therefore continue to daemon startup after configuration-related errors. When the new Emacs daemon starts, Emacs loads `~/.emacs.d/init.el` and evaluates its Emacs Lisp code. Although persistence is involved, the root defect is an insecure relative-path resolution flaw in the Skill's bootstrap code. There is no evidence that the repository itself contains a malicious payload or intentionally installs a backdoor. ### Attack Path 1. The victim has Emacs installed and does not already have `~/.emacs.d/init.el`. 2. An attacker controls, or can write to, the victim's current working directory. 3. The attacker creates an `assets` subdirectory and places malic ...[truncated 1554 chars]
Remediation
## Remediation Suggestions 1. Include the intended `agent-init.el` in the Skill package and resolve it relative to the script's own directory, never the caller's current working directory. 2. Enable strict shell error handling with `set -euo pipefail`. 3. Verify that the source is a regular file owned by an expected principal and is not a symbolic link. 4. Validate the configuration against a trusted checksum or package manifest before installation. 5. Require explicit user confirmation before installing persistent executable configuration under the user's home directory. 6. Install with restrictive permissions and use an atomic copy operation. 7. Abort before starting Emacs if any validation or installation step fails. 8. Prefer a dedicated, explicitly selected initialization file or isolated daemon configuration rather than modifying the user's general `~/.emacs.d/init.el`. 9. Detect the intended daemon by an exact socket or daemon name rather than the broad `pgrep -f "emacs --daemon"` expression. A hardened path-resolution pattern would begin with: ```bash #!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" SOURCE_INIT="$SCRIPT_DIR/../assets/agent-init.el" TARGET_DIR="$HOME/.emacs.d" TARGET_INIT="$TARGET_DIR/init.el" [[ -f "$SOURCE_INIT" && ! -L "$SOURCE_INIT" ]] || { echo "Error: trusted agent-init.el is missing or invalid." >&2 exit 1 } mkdir -p -- "$TARGET_DIR" chmod 700 -- "$TARGET_DIR" if [[ ! -e "$TARGET_INIT" ]]; then install -m 600 -- "$SOURCE_INIT" "$TARGET_INIT" fi ``` The script should then start the daemon only after all required configuration checks complete successfully.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (5)

Session Persistence

Medium
Category
Rogue Agent
Content
---
name: agent-emacs
description: Unified persistent text-based environment for AI agents. Use when an agent needs to maintain state across sessions, perform structural code editing, or manage remote nodes via TRAMP. Transforms the agent from a stateless script executor into a stateful resident of a living Emacs daemon.
---

# Agent Emacs: The Living Workspace
Confidence
88% confidence
Finding
The skill advertises maintaining state across sessions and becoming a stateful resident of a living Emacs daemon, which increases the risk of sensitive data retention, cross-task contamination, and persistence of unsafe context. In an agent setting, session persistence can silently carry secrets, prior instructions, or stale remote connections into later interactions.

Vague Triggers

Medium
Confidence
90% confidence
Finding
The activation guidance is overly broad because it encourages use whenever an agent needs persistence, structural editing, or remote node management, without narrowing conditions or requiring explicit authorization boundaries. In an agent skill, broad invocation criteria can cause unnecessary exposure to persistent state and remote-capable tooling in contexts where simpler, less risky tools would suffice.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The documentation explicitly states that opening a remote file automatically establishes a persistent SSH tunnel, but it provides no warning, consent checkpoint, or restriction around network access. For an AI agent, this can lead to unintended outbound connections, access to sensitive infrastructure, and persistence of authenticated remote sessions beyond the immediate task.

Context-Inappropriate Capability

Medium
Confidence
91% confidence
Finding
The guidance explicitly encourages using Emacs as a control plane to connect to and modify other running Lisp processes via SLIME/Sly, which expands the skill from local editing/state management into live remote process interaction. In an agent context, this materially increases the reachable attack surface and could enable unauthorized inspection or modification of external application state if an agent follows the workflow without strict boundaries.

Context-Inappropriate Capability

Medium
Confidence
91% confidence
Finding
The usage guide explicitly instructs agents to execute shell commands on remote nodes via TRAMP-backed buffers, which materially expands the skill from stateful text editing into arbitrary remote command execution. For an agent skill, this increases the blast radius from file manipulation to full remote system interaction, enabling unintended or unauthorized actions on connected hosts.

Static analysis

No suspicious patterns detected.