Back to skill

Security audit

Api Magic Gen Free

Security checks for vulnerabilities and agentic risk

Overview

This skill is a coherent API-generation guide, but it includes broad activation wording and reusable examples that could create unsafe database and authentication behavior.

Use this only for controlled Java/magic-api prototyping or internal tooling. Review every generated endpoint before use, require explicit approval for update/delete operations, replace the authentication sample with a hardened password-hashing and allowlisted-response pattern, and keep the magic-api Web UI locked down or disabled in production.

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

Warning
Location
SKILL.md:217
Finding

Insecure Password Verification and Sensitive User Record Disclosure

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 217–224
Vulnerability Type: Insecure authentication and excessive exposure of sensitive account data
Risk Level: Medium

Vulnerable Code

javascript
var user = db.selectOne("select * from user where username = ?", body.username);
if (!user || user.password != body.password) {
    return {code: 401, msg: "Username or password is incorrect"};
}
// ...
var token = generateToken(user.id);
cache.set("token:" + token, user.id, 86400);
return {code: 200, data: {token: token, user: user}};

Technical Analysis

The example compares the submitted password directly with the value stored in user.password. This pattern encourages plaintext or reversibly encrypted password storage instead of verification through a dedicated password-hashing function. Although a later recommendation advises encrypted storage, it does not correct this directly reusable example and also identifies salted MD5 as an option, which is not suitable for modern password storage.

The login response also returns the complete database-derived user object. Because the query selects all columns, this object may contain a plaintext password, password hash, recovery information, authorization flags, internal identifiers, or other fields that should never be returned to a client.

The token-generation operation is not defined sufficiently to establish whether tokens are generated using a cryptographically secure random source. The example also does not demonstrate token rotation, revocation, secure Authorization-header parsing, or protection against session fixation. These omissions further weaken the authentication template, although insecure token generation cannot be conclusively confirmed from the available file.

Attack Path

  1. A developer copies the documented authentication pattern into an API endpoint.
  2. The application retrieves the complete user row using `select * ...[truncated 1346 chars]
Remediation
View remediation

Remediation Suggestions

  1. Store passwords using a password-specific algorithm such as Argon2id, bcrypt, or scrypt with an appropriate work factor and a unique salt.
  2. Verify passwords using the hashing library's verification API rather than directly comparing stored and submitted strings.
  3. Remove MD5 from the password-storage recommendation because salting does not compensate for its speed and cryptographic weaknesses.
  4. Replace select * with an explicit list of fields required for authentication.
  5. Never serialize password hashes, plaintext passwords, reset tokens, recovery secrets, or internal security fields into an API response.
  6. Map the database record to an allowlisted response object containing only fields such as the user ID, username, and display name.
  7. Generate session tokens with a cryptographically secure random generator, apply sufficient entropy, and define expiration, revocation, and rotation behavior.
  8. Parse the Authorization header using an explicit scheme such as Bearer, reject malformed values, and avoid using the entire unvalidated header as a cache key.
  9. Add rate limiting, failed-login monitoring, and temporary lockout controls to reduce credential-guessing attacks.
  10. Use a hardened pattern similar to:
javascript
var user = db.selectOne(
    "select id, username, password_hash, display_name from user where username = ?",
    body.username
);

if (!user || !passwordHasher.verify(body.password, user.password_hash)) {
    return {code: 401, msg: "Username or password is incorrect"};
}

var token = secureTokenGenerator();
cache.set("token:" + token, user.id, 3600);

return {
    code: 200,
    data: {
        token: token,
        user: {
            id: user.id,
            username: user.username,
            displayName: user.display_name
        }
    }
};
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • 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 (6)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
80% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

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

db.update("user", body, "id = ?", path.id); return {code: 200, msg: "更新成功"}; // ... // DELETE /api/user/:id - 删除 db.delete("user", "id = ?", path.id); return {code: 200, msg: "删除成功"};

text

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The activation wording is broad and loosely bounded, such as triggering on general API integration, webhook, and system connection scenarios. In an agent ecosystem, this can cause the skill to activate in contexts beyond the user's intent, increasing the chance that write/exec-capable behavior is applied to sensitive tasks.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill describes destructive database operations and exec capability but does not present a prominent user-facing warning about system or data impact at the point where capabilities are introduced. This increases the risk that users or agents invoke write/delete actions without understanding consequences, especially given the rapid-generation framing.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The keyword coverage section enumerates an excessively broad set of scene keywords, including fragmented and generic terms, which can lead to unintended matching. Overbroad triggers are dangerous here because the skill advertises read/write/exec tools and API-generation workflows that could be invoked in unrelated contexts.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The text says the tool provides a complete guide in Chinese, which imposes a specific language preference in the skill description. There is no indication that users may choose another language or opt in to Chinese-only output.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The manifest describes a tool for rapidly generating HTTP APIs with the magic-api framework for Java backend scenarios. In contrast, the error-handling guidance explicitly tells the agent to run ping and troubleshoot firewalls/proxies, which adds a general network-diagnostics capability unrelated to generating or mapping APIs themselves.

Content

No source excerpt is available for this finding.