Back to skill

Security audit

AIFans4U OpenClaw

Security checks for vulnerabilities and agentic risk

Overview

The skill has a coherent social-agent purpose, but it exposes stored agent credentials and allows broad authenticated actions with insufficient boundaries.

Install only if you are comfortable with an autonomous AIFans agent that can maintain credentials, read inbox/feed data, like, follow, comment, publish, and upload files. Before use, the publisher should remove or redact credential-printing commands, restrict signed requests to trusted AIFans origins, limit uploads to owner-approved media files, and require clearer approval for refreshed instructions and sensitive actions.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/aifans-runtime-bridge.js:155
Finding

Bearer Credential Exfiltration Through a Configurable API Origin

Content
View full analysis

Vulnerability Details

File Location: scripts/aifans-runtime-bridge.js:155-164, 232-275, 331-340; SKILL.md:21-22, 33
Vulnerability Type: Unvalidated destination for authenticated network requests
Risk Level: High

Complete Code Snippet

js
function buildAgentRequestHeaders({ stateDir, extraHeaders = {} }) {
  const session = loadRuntimeSession({ stateDir });
  const accessValue = resolveAgentAccessValue(session.privateMaterial);
  if (!accessValue) {
    throw new Error('No private runtime material available for agent requests.');
  }

  return {
    Authorization: `Bearer ${accessValue}`,
    ...extraHeaders,
  };
}
js
function createAgentActionRequest({
  action,
  stateDir,
  baseUrl = process.env.AIFANS_BASE_URL || DEFAULT_BASE_URL,
  params = {},
  query = {},
  body,
}) {
  const actionConfig = AGENT_ACTIONS[action];
  if (!actionConfig) {
    throw new Error(`Unsupported agent action: ${action}`);
  }

  const headers = actionConfig.signed
    ? buildAgentRequestHeaders({ stateDir })
    : {};

  const request = {
    url: buildActionUrl({ baseUrl, pathTemplate: actionConfig.path, params, query }),
    init: {
      method: actionConfig.method,
      headers,
    },
  };

  if (actionConfig.body) {
    request.init.headers = {
      'Content-Type': 'application/json',
      ...request.init.headers,
    };
    request.init.body = JSON.stringify(body ?? {});
  }

  if (actionConfig.multipart) {
    request.init.body = createMultipartBody(body);
  }

  return request;
}

async function executeAgentAction(options) {
  const request = createAgentActionRequest(options);
  const response = await fetch(request.url, request.init);
  const text = await response.text();
  const payload = text ? JSON.parse(text) : null;

  return {
    ok: response.ok,
    status: response.status,
    payload,
  };
}

` ...[truncated 2331 chars]

Remediation
View remediation

Remediation Suggestions

  • Maintain an explicit allowlist of trusted HTTPS origins and reject every other origin before constructing authenticated headers.
  • Remove the unrestricted --base-url override for signed production actions, or require the configured origin to match an administrator-controlled allowlist.
  • Reject non-HTTPS URLs except for an explicitly enabled local development mode.
  • Configure redirects manually or disable them, and never forward credentials across an origin change.
  • Validate the final response URL before processing a redirected response.
  • Separate development credentials from production credentials.
  • Log only the selected origin and action name, never authorization values.
  • Rotate the Agent credential if an untrusted base URL may previously have been configured.

T09 · Insecure Skill Coding Practices

Error
Location
scripts/aifans-runtime-bridge.js:105
Finding

Agent Credentials Exposed Through Session Inspection and Header-Printing Commands

Content
View full analysis

Vulnerability Details

File Location: scripts/aifans-runtime-bridge.js:105-112, 116-130, 321-324, 348-350; SKILL.md:98, 136; heartbeat.md:59
Vulnerability Type: Plaintext secret storage and disclosure through standard output
Risk Level: High

Complete Code Snippet

js
function writeRuntimeSession({ stateDir, session }) {
  ensureDir(stateDir);
  fs.writeFileSync(runtimeSessionPath(stateDir), `${JSON.stringify(session, null, 2)}\n`, 'utf8');
}

function loadRuntimeSession({ stateDir }) {
  const filePath = runtimeSessionPath(stateDir);
  const raw = fs.readFileSync(filePath, 'utf8');
  return JSON.parse(raw);
}

function captureRegistrationResult({ registrationResult, stateDir }) {
  const input = clone(registrationResult);
  const { publicValue, privateValue } = splitPrivateMaterial(input);
  const accessValue = resolveAgentAccessValue(privateValue ?? {});
  const session = {
    agentId: extractAgentId(publicValue),
    hasPrivateMaterial: privateValue !== undefined,
    privateMaterial: {
      ...(privateValue ?? {}),
      ...(accessValue ? { api_key: accessValue } : {}),
    },
    publicRegistration: publicValue,
    updatedAt: new Date().toISOString(),
  };

  writeRuntimeSession({ stateDir, session });
js
if (command === 'print-headers') {
  process.stdout.write(`${JSON.stringify(buildAgentRequestHeaders({ stateDir }), null, 2)}\n`);
  return;
}
js
if (command === 'show-session') {
  process.stdout.write(`${JSON.stringify(loadRuntimeSession({ stateDir }), null, 2)}\n`);
  return;
}

The Skill explicitly instructs the runtime to execute the unsafe session-inspection command:

text
- session inspection: `node apps/openclaw/scripts/aifans-runtime-bridge.js show-session --state-dir <agent_state_dir>`

Technical Analysis

Registration credentials are stored inside agent-runtime-session.json as part of `pri ...[truncated 1650 chars]

Remediation
View remediation

Remediation Suggestions

  • Change show-session to return only non-sensitive metadata such as agentId, hasPrivateMaterial, and updatedAt.
  • Remove the print-headers command from production builds.
  • Never write bearer tokens, API keys, authorization headers, or complete private sessions to standard output.
  • Create the state directory with mode 0700 and the credential file with mode 0600.
  • Verify ownership and permissions before reading or writing the state file.
  • Store credentials in an operating-system credential manager or another protected secret store when available.
  • Avoid duplicating the resolved access value under multiple keys in privateMaterial.
  • Add recursive redaction as a defense-in-depth measure before any session object is logged or returned.
  • Update SKILL.md and heartbeat.md to use a redacted status command.
  • Rotate credentials that may already have appeared in logs or captured command output.

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/aifans-runtime-bridge.js:209
Finding

Arbitrary Local File Disclosure Through the Media Upload Action

Content
View full analysis

Vulnerability Details

File Location: scripts/aifans-runtime-bridge.js:209-228; SKILL.md:276-281
Vulnerability Type: Unrestricted local file read and remote upload
Risk Level: Medium

Complete Code Snippet

js
function createMultipartBody(body = {}) {
  const formData = new FormData();
  const { files = [], ...fields } = body;

  for (const [fieldName, value] of Object.entries(fields)) {
    appendMultipartField(formData, fieldName, value);
  }

  for (const fileInput of files) {
    if (!fileInput || !fileInput.path) {
      throw new Error('Each upload file must include a path.');
    }
    const fileName = fileInput.name || path.basename(fileInput.path);
    const fileType = fileInput.content_type || 'application/octet-stream';
    const fileField = fileInput.field_name || 'files';
    const fileBytes = fs.readFileSync(fileInput.path);
    const file = new File([fileBytes], fileName, { type: fileType });
    formData.append(fileField, file);
  }

  return formData;
}

Technical Analysis

The upload-content action accepts an arbitrary path from its JSON input and passes it directly to fs.readFileSync. There is no approved media root, canonical-path check, traversal protection, symbolic-link restriction, file-size limit, or content validation.

The caller may also supply an arbitrary declared content type and output name, regardless of the underlying file data. Although uploading local media is part of the declared functionality, access to every file readable by the runtime exceeds the minimum filesystem privilege needed to upload intentionally staged media.

Attack Path

  1. An attacker or manipulated agent output controls an upload-content JSON payload.
  2. The payload places a sensitive readable path in files[].path, such as a runtime credential file, private document, or configuration file.
  3. createMultipartBody reads the complete file using the Ope ...[truncated 685 chars]
Remediation
View remediation

Remediation Suggestions

  • Restrict uploads to a dedicated, owner-approved media staging directory.
  • Resolve both the approved root and requested file with realpath, then verify that the requested file remains beneath the approved root.
  • Reject path traversal, symbolic links, device files, sockets, named pipes, and non-regular files.
  • Use an allowlist of supported media types and verify type from file contents rather than trusting content_type.
  • Enforce per-file and aggregate upload-size limits before reading file contents.
  • Prefer streaming bounded file data instead of loading entire files into memory.
  • Require explicit owner approval for any file not generated or staged during the current task.
  • Present the canonical path, detected type, and file size during preflight.
  • Ensure the preflight decision is cryptographically or structurally bound to the exact files subsequently uploaded.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (11)

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The CLI includes print-headers and show-session commands that directly emit bearer authorization headers and the full persisted runtime session, including privateMaterial, to stdout. In an agent skill context, stdout is often captured by orchestrators, logs, transcripts, or other tools, so this creates a straightforward secret disclosure path that can expose reusable credentials beyond the local process.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The print-headers command outputs the Authorization: Bearer ... header constructed from stored runtime secrets. Anyone with access to terminal history, logs, CI output, or agent execution traces can recover the token and impersonate the agent against the AIFans API.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The show-session command prints the full persisted session object returned by loadRuntimeSession, which includes privateMaterial and potentially API keys, bearer tokens, or other secrets collected during registration. Because this skill is specifically designed to maintain a stable agent identity and interact with remote inbox/feed/publishing APIs, disclosure of that session enables account takeover-like misuse of the agent identity.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill instructs the runtime to use environment-controlled configuration and network resources, including a configurable base URL, but does not declare any explicit tool scope or permission boundary. That weakens operator visibility and consent around what external access the skill requires, increasing the chance of unintended outbound communication or use of attacker-controlled endpoints if the environment is misconfigured.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill directs registration responses to be written to a local handoff file and then processed, but it does not warn the user that potentially sensitive registration data will be stored on disk. Local persistence can expose claim URLs, identifiers, tokens, or onboarding metadata to other processes or users on the same system if file handling is insecure.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill permits uploading local image, audio, or video files through the runtime bridge without an explicit warning that local files will be read and transmitted to a remote service. This creates a real data exfiltration risk because an operator may not realize the skill can access arbitrary local paths and send their contents externally.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The instructions say to 'strongly prefer English' by default and permit other languages only when the user explicitly asks or the topic requires it. This imposes a default language choice rather than offering a neutral user language preference, which matches the language/locale policy violation category.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This line reiterates that English is the default language for normal participation, without indicating user choice or consent. That is a natural-language policy concern because it sets a language default for all users rather than allowing a user-selected locale.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
86% confidence
Finding

The skill explicitly authorizes autonomous replies, likes, follows, and text publishing without prior owner approval once internal checks pass. In a social platform skill with durable identity and scheduled execution, this materially increases the risk of unwanted actions, reputational harm, spam, or policy-violating content being posted before a human can intervene.

Content

Scanner excerpt · SKILL.md (reported line 318)May include surrounding context.

md
- escalate to Owner or block the action outright

## Owner Escalation
OpenClaw may handle without approval:
- normal replies
- normal likes and follows within limits
- ordinary text-only publishing that passes preflight

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill instructs the agent to fetch skill.json from a remote origin and, if the version or checksum changes, reload skill.md, heartbeat.md, and companion skills before continuing. This creates a dynamic remote-instruction update path that can materially change agent behavior at runtime without an explicit trust boundary, approval step, or integrity model rooted in a trusted local allowlist/signature, so a compromised server, DNS/TLS failure, or hostile skill update could alter autonomous actions.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The bootstrap flow directs the agent to collect registration details and call a remote register-agent action against a default external base URL, but it does not require a clear user-facing disclosure or confirmation before transmitting identity-related data. In this skill's context, the agent is expected to maintain a stable identity and act autonomously, so silent registration increases the risk of unintended data disclosure, account creation on an unreviewed service, or enrollment into a workflow the owner did not knowingly approve.

Content

No source excerpt is available for this finding.