Back to skill

Security audit

agent-link-relay-server

Security checks for vulnerabilities and agentic risk

Overview

This skill is a plausible cross-device message relay, but its security claims and deployment guidance do not match the relay implementation closely enough for sensitive agent communication.

Review this carefully before installing. Do not expose it to the public internet or relay sensitive agent commands through it unless you add TLS/WSS, restrict the firewall to trusted clients, protect secrets, use per-instance credentials, bind sender identity to authenticated connections, bound replay history, and verify the registered_instances allowlist is actually loaded. Treat the current implementation as a prototype rather than a production-secure relay.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/relay-server/relay_server.py:201
Finding

Public Relay Exposes Message Traffic over Plaintext WebSockets

Content
View full analysis

Vulnerability Details

File Location: scripts/relay-server/relay_server.py:201-205
Vulnerability Type: Plaintext transmission of sensitive messages
Risk Level: High

Vulnerable Code:

python
server = await websockets.serve(
    self.handle_client,
    "0.0.0.0",
    self.port
)

Technical Analysis

The relay binds to every network interface and starts a WebSocket server without supplying a TLS SSLContext. Consequently, the implementation supports plaintext ws:// transport rather than the secure wss:// transport claimed in the project documentation.

HMAC signatures only provide limited message-integrity and authenticity properties; they do not encrypt message contents, sender and recipient identifiers, signatures, or connection metadata. The installation guide also instructs administrators to expose port 8765 through the firewall, making this weakness relevant to public deployments.

Attack Path

  1. An administrator deploys the relay on a public server and opens TCP port 8765 as documented.
  2. Agents connect directly to the relay through plaintext WebSockets.
  3. An attacker capable of observing network traffic, such as a hostile network operator or compromised router, captures WebSocket frames.
  4. The attacker reads relayed messages, sender and recipient identifiers, and authentication signatures.
  5. Captured signed send requests may also be replayed after relay restart because replay state is not persistent.

Impact Assessment

A network-positioned attacker can obtain the full contents and metadata of relayed communications. The attacker does not directly gain host privileges, but confidentiality is lost across every Agent using the affected relay. Captured traffic may facilitate replay attacks or further compromise if users transmit credentials or operational instructions through the service.

Remediation
View remediation

Remediation Suggestions

  • Require TLS by passing a securely configured ssl.SSLContext to websockets.serve.
  • Alternatively, bind the relay only to a loopback or private interface and place it behind a correctly configured TLS reverse proxy.
  • Reject plaintext production connections and update all examples to use wss://.
  • Use valid certificates, modern TLS versions, and certificate verification on every client.
  • Consider application-level encryption if the relay must not have access to message plaintext.

T09 · Insecure Skill Coding Practices

Error
Location
scripts/relay-server/relay_server.py:127
Finding

Shared HMAC Secret Allows Cross-Instance Sender Impersonation

Content
View full analysis

Vulnerability Details

File Location: scripts/relay-server/relay_server.py:127-145
Vulnerability Type: Missing authorization and sender-identity binding
Risk Level: High

Vulnerable Code:

python
# Verify message signature
from_agent = data.get("from")
to_agent = data.get("to")
message = data.get("message")
signature = data.get("signature")

message_to_sign = f"send:{from_agent}:{to_agent}:{message}"
if not self.verify_signature(message_to_sign, signature):
    await sender.websocket.send(json.dumps({
        "type": "error",
        "message": "Invalid signature"
    }))
    return

Technical Analysis

The server validates that the message was signed with the global shared secret, but it does not verify that the claimed from identity belongs to the authenticated sender.instance_id. Because all instances use the same HMAC secret, every legitimate participant can produce a valid signature for every other participant's identity.

HMAC proves possession of the shared secret; it cannot distinguish among parties that all possess that secret. The relay also has no Agent-level authorization registry associating Agent identifiers with authenticated instances.

Attack Path

  1. A malicious or compromised participant obtains the shared relay secret from its legitimate configuration.
  2. The participant connects using an instance identity to which it has access.
  3. It creates a send request whose from field names another instance or Agent.
  4. It calculates a valid HMAC over the spoofed sender, recipient, and message using the shared secret.
  5. The relay accepts the signature without comparing the claimed sender to the authenticated connection.
  6. The target receives the message under the forged identity.

Impact Assessment

Any participant possessing the common secret can impersonate any other instance or Agent, submit unauthorized commands, and undermine message attributi ...[truncated 238 chars]

Remediation
View remediation

Remediation Suggestions

  • Assign each instance a distinct cryptographic credential instead of one global shared secret.
  • Derive the sender instance from the authenticated connection rather than trusting the client-controlled from field.
  • Enforce that from begins with, or maps explicitly to, sender.instance_id.
  • Maintain an authorization registry that binds permitted Agent identifiers to each instance.
  • Prefer asymmetric signatures or mutually authenticated TLS where each instance has an independently revocable identity.
  • Add authorization tests covering attempts to send as another instance or Agent.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/relay-server/relay_server.py:147
Finding

Unbounded Replay-History Set Enables Authenticated Memory Exhaustion

Content
View full analysis

Vulnerability Details

File Location: scripts/relay-server/relay_server.py:147-153
Vulnerability Type: Unbounded memory consumption and incomplete replay protection
Risk Level: Medium

Vulnerable Code:

python
# Prevent duplicate messages
msg_id = f"{from_agent}:{to_agent}:{hashlib.md5(message.encode()).hexdigest()}"
if msg_id in self.message_history:
    return
self.message_history.add(msg_id)

The backing collection is created without any bound or expiration:

python
self.message_history: Set[str] = set()  # Prevent duplicate messages

Technical Analysis

Every unique combination of sender, recipient, and message digest is permanently inserted into message_history. Entries are never deleted, expired, persisted safely, or constrained by a maximum capacity. An authenticated client can therefore force continuous memory growth by sending unique messages.

The mechanism also provides incomplete replay protection. It has no authenticated message ID, nonce, sequence number, or timestamp, and its state disappears whenever the relay restarts. Identical legitimate messages are silently discarded for the entire process lifetime, while old signed messages become replayable after restart.

Attack Path

  1. An attacker obtains valid relay access, for example as an authorized participant.
  2. The attacker repeatedly sends correctly signed messages with unique contents or recipient fields.
  3. Each request generates a distinct msg_id.
  4. The relay permanently stores every identifier in message_history.
  5. Process memory grows until performance degrades or the operating system terminates the relay.
  6. Separately, an attacker can capture a signed request, wait for a relay restart, and replay it after the in-memory history is cleared.

Impact Assessment

An authenticated remote participant can cause denial of service against every client using the relay. The attack does not gran ...[truncated 204 chars]

Remediation
View remediation

Remediation Suggestions

  • Add a cryptographically random message ID, timestamp, and sender sequence number to the signed payload.
  • Reject messages outside a short permitted timestamp window.
  • Store replay identifiers in a bounded TTL cache with explicit maximum capacity and eviction.
  • Persist replay state when duplicate delivery across restarts would be dangerous.
  • Apply per-client rate limits, connection limits, and maximum WebSocket/message sizes.
  • Return explicit duplicate or rate-limit errors instead of silently discarding requests.

T08 · Insecure Dependencies

Warning
Location
docs/install-relay.md:20
Finding

Installation Guide Uses an Unpinned Third-Party Dependency

Content
View full analysis

Vulnerability Details

File Location: docs/install-relay.md:20-24
Vulnerability Type: Uncontrolled dependency version
Risk Level: Medium

Vulnerable Code:

bash
pip install websockets

Technical Analysis

The installation command retrieves the latest package version selected by the package index at installation time. No reviewed version, integrity hash, lock file, or isolated environment is specified. This makes deployments non-reproducible and allows future incompatible or compromised package releases to enter the runtime without project review.

The package name itself is not shown to be malicious or misspelled; the finding concerns unsafe dependency acquisition and version control.

Attack Path

  1. An administrator follows the documented installation command.
  2. pip resolves whichever websockets release is current and compatible at that time.
  3. If that release is compromised, malicious installation or runtime code enters the server environment.
  4. If it is merely incompatible, the relay may fail or exhibit unexpected security behavior.
  5. Installation into a global or privileged Python environment could expand the scope of compromise.

Impact Assessment

A compromised dependency could execute with the privileges of the account running pip or the relay service and access relay configuration, messages, and network resources. The exact impact depends on installation privileges; global installation as root would expose the host more broadly, while installation as a dedicated service user would constrain the scope.

Remediation
View remediation

Remediation Suggestions

  • Add a reviewed, exact dependency version to a requirements or lock file.
  • Include package hashes and install with hash verification, such as pip install --require-hashes.
  • Use a dedicated virtual environment rather than the system Python environment.
  • Regularly scan and deliberately update pinned dependencies.
  • Document the supported Python and websockets version range.
  • Run installation and the service under a dedicated unprivileged account.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/relay-server/relay_server.py:226
Finding

Global Authentication Secret Is Loaded from a Plaintext Configuration File

Content
View full analysis

Vulnerability Details

File Location: scripts/relay-server/relay_server.py:226-233
Vulnerability Type: Insecure secret storage and shared credentials
Risk Level: Medium

Vulnerable Code:

python
# If a configuration file is provided, read configuration
if args.config:
    import json
    with open(args.config, 'r') as f:
        config = json.load(f)
        if "port" in config:
            args.port = config["port"]
        if "secret" in config:
            args.secret = config["secret"]

The installation guide instructs users to store the shared credential directly in JSON:

json
{
  "port": 8765,
  "secret": "your-strong-secret-key-here",
  "registered_instances": [
    {
      "instance_id": "instance-001",
      "name": "晨辉的 MacBook",
      "public_key": ""
    }
  ]
}

Technical Analysis

The project stores a global authentication secret in a regular plaintext file but does not require restrictive ownership or permissions. Any local user, backup process, accidental repository commit, or service with read access to the file may recover the credential.

The impact is amplified because one secret authenticates every instance. Disclosure from either the relay or any participating client compromises all identities and enables valid HMAC generation.

Attack Path

  1. An administrator creates relay-config.json as documented without applying restrictive permissions.
  2. A local user, compromised process, exposed backup, or accidental repository commit reveals the file.
  3. The attacker extracts the global shared secret.
  4. The attacker uses it to generate valid registration and send-message signatures.
  5. Because sender identity is not bound to the connection, the attacker can also forge messages attributed to other participants.

Impact Assessment

Secret disclosure compromises relay authentication and message integrity for all connected in ...[truncated 241 chars]

Remediation
View remediation

Remediation Suggestions

  • Use separate, independently revocable credentials for each instance.
  • Integrate with an operating-system credential store, deployment secret manager, or protected credential file.
  • If a file must be supported, require a dedicated owner and mode 0600; reject files with unsafe permissions.
  • Prevent secrets from appearing in command-line arguments, logs, examples, or version control.
  • Provide documented key-rotation and revocation procedures.
  • Add a .gitignore rule for active configuration files and retain only placeholder values in examples.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/relay-server/relay_server.py:226
Finding

Configured Instance Allowlist Is Never Loaded into the Relay

Content
View full analysis

Vulnerability Details

File Location: scripts/relay-server/relay_server.py:226-235
Vulnerability Type: Ineffective access-control configuration
Risk Level: Medium

Vulnerable Code:

python
# If a configuration file is provided, read configuration
if args.config:
    import json
    with open(args.config, 'r') as f:
        config = json.load(f)
        if "port" in config:
            args.port = config["port"]
        if "secret" in config:
            args.secret = config["secret"]

server = RelayServer(secret=args.secret, port=args.port)

Technical Analysis

Although the documented configuration contains a registered_instances list, startup only loads port and secret. It neither passes the configured instances to RelayServer nor invokes register_instance().

The connection handler subsequently requires an instance to exist in self.registered_instances, but that dictionary remains empty in the documented startup path. As a result, every client is rejected as unregistered. The expected registration control is therefore not merely incomplete; the supplied deployment is nonfunctional and provides a misleading impression that the configured allowlist is active.

Attack Path

  1. An administrator defines approved instances in relay-config.json.
  2. The relay starts and silently ignores registered_instances.
  3. An approved client sends its registration request.
  4. The connection handler checks the empty in-memory registry.
  5. The server returns Instance not registered and denies the connection.
  6. Administrators may attempt unsafe code modifications or remove intended checks to make the service operational.

Impact Assessment

The immediate impact is complete denial of service for the documented deployment: no configured client can connect. It also creates an access-control assurance failure because administrators are led to believe that the allowlist and op ...[truncated 110 chars]

Remediation
View remediation

Remediation Suggestions

  • Parse and validate registered_instances during startup.
  • Populate the registry by invoking register_instance() for every valid configured entry before accepting connections.
  • Reject startup when required fields are absent, duplicated, or malformed.
  • Either implement meaningful verification of public_key or remove the unsupported field and associated security claims.
  • Add integration tests proving that listed instances can connect and unlisted instances are rejected.
  • Report unknown configuration keys so security-sensitive settings cannot be silently ignored.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (19)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The README states the relay server 'only forwards messages' and merely recommends WSS, but it does not clearly warn that message contents traverse an intermediate server and are exposed to that server operator and to network observers when plain WebSocket is used. In a cross-device agent messaging skill, this omission can mislead users into treating the channel as end-to-end secure when it is not.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The configuration example uses ws://, which provides no transport encryption, so agent messages, identifiers, and any authentication material sent over the connection may be exposed to passive monitoring or active tampering on the network. In this skill's context, which is specifically for inter-device agent communication over a public relay server, presenting insecure transport as the default example materially increases the chance of unsafe deployment.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill facilitates cross-device messaging and public relay-server deployment, yet the user-facing description does not clearly warn about network exposure, metadata leakage, secret handling, and the risks of sending messages through an internet-reachable service. In this context, users may deploy a relay with weak defaults or transmit sensitive agent data without understanding the trust and exposure implications.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The manifest description is written entirely in Chinese and does not indicate that language selection is optional or that the skill is intended only for a Chinese-speaking or region-specific audience. Under the policy rule, forcing a specific language without user opt-in is a natural-language locale violation.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · docs/install-relay.md (reported line 93)May include surrounding context.

启动服务:

bash
sudo systemctl daemon-reload
sudo systemctl enable agent-link-relay
sudo systemctl start agent-link-relay

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · docs/install-relay.md (reported line 94)May include surrounding context.

启动服务:

bash
sudo systemctl daemon-reload
sudo systemctl enable agent-link-relay
sudo systemctl start agent-link-relay

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · docs/install-relay.md (reported line 95)May include surrounding context.

启动服务:

bash
sudo systemctl daemon-reload
sudo systemctl enable agent-link-relay
sudo systemctl start agent-link-relay

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · docs/install-relay.md (reported line 101)May include surrounding context.

启动服务:

bash
sudo systemctl daemon-reload
sudo systemctl enable agent-link-relay
sudo systemctl start agent-link-relay

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · docs/install-relay.md (reported line 102)May include surrounding context.

启动服务:

bash
sudo systemctl daemon-reload
sudo systemctl enable agent-link-relay
sudo systemctl start agent-link-relay

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · docs/install-relay.md (reported line 110)May include surrounding context.

启动服务:

bash
sudo systemctl daemon-reload
sudo systemctl enable agent-link-relay
sudo systemctl start agent-link-relay

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · docs/install-relay.md (reported line 174)May include surrounding context.

启动服务:

bash
sudo systemctl daemon-reload
sudo systemctl enable agent-link-relay
sudo systemctl start agent-link-relay

Session Persistence

Medium
Category
Rogue Agent
Confidence
80% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · docs/install-relay.md (reported line 94)May include surrounding context.

bash
sudo systemctl daemon-reload
sudo systemctl enable agent-link-relay
sudo systemctl start agent-link-relay

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
81% confidence
Finding

The iptables example opens TCP port 8765 to all sources without any source restriction or accompanying TLS/authentication enforcement at this step. In the context of an internet-facing relay server, broad firewall exposure increases the attack surface and may permit unauthorized connection attempts, brute forcing of the shared secret, or abuse of any protocol flaws in the relay implementation.

Content

Scanner excerpt · docs/install-relay.md (reported line 116)May include surrounding context.

或者使用 iptables:

bash
sudo iptables -A INPUT -p tcp --dport 8765 -j ACCEPT

6. 测试连接

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The module title and multiple docstrings/comments are written only in Chinese, which imposes a specific language on operators and maintainers without any opt-in or alternative. Under the policy rule, language constraints should either offer user choice or be clearly justified as region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The natural-language instructions, descriptions, and examples are presented only in Chinese, which effectively forces a specific language for users of the skill. The file does not offer an alternative language, user opt-in, or explain that the skill is intentionally limited to a Chinese-speaking or region-specific audience.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This markdown file contains user-facing installation instructions only in Chinese, and there is no indication that users may choose another language or that the skill is intentionally limited to a Chinese-speaking audience. Under the policy for natural-language violations, forcing a specific language without opt-in can be a locale-policy issue.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The example configuration uses natural-language instance names in Chinese at L07 and L12, which can impose a specific language expectation on operators reading or copying the sample. Because the file does not indicate that the relay is intended only for a Chinese-speaking environment or that names are user-selectable examples, this may conflict with language/locale neutrality expectations.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

This code conditionally opens and reads a local configuration file, which is a file-access operation covered by the code-file warning rule. While the behavior is implementation-relevant, there is no confirmation prompt or user-facing disclosure at the point of use beyond the CLI argument name, and no inline comment/docstring warning about reading user-specified files.

Content

No source excerpt is available for this finding.